| @@ -1,4 +1,6 @@ | |||||
| { | { | ||||
| "minify.minifyExistingOnSave": true, | "minify.minifyExistingOnSave": true, | ||||
| "editor.snippetSuggestions": "top" | |||||
| "editor.snippetSuggestions": "top", | |||||
| "python.pythonPath": "C:\\Users\\hausss\\.pyenv\\pyenv-win\\versions\\3.8.2\\python.exe", | |||||
| "python.formatting.provider": "black" | |||||
| } | } | ||||
| @@ -12136,6 +12136,13 @@ const attributionData = { | |||||
| "cdc" | "cdc" | ||||
| ] | ] | ||||
| }, | }, | ||||
| { | |||||
| prefix: "./media/naturals/global-cities", | |||||
| all: "https://openstreetmap.org", | |||||
| authors: [ | |||||
| "openstreetmap" | |||||
| ] | |||||
| }, | |||||
| { | { | ||||
| prefix: "./media/food/plants/", | prefix: "./media/food/plants/", | ||||
| files: [ | files: [ | ||||
| @@ -0,0 +1,6 @@ | |||||
| <?xml version="1.0"?> | |||||
| <svg xmlns="http://www.w3.org/2000/svg" version="1.2" baseProfile="tiny" width="800" height="468" viewBox="0 0 800 468" stroke-linecap="round" stroke-linejoin="round"> | |||||
| <g id="Hong Kong"> | |||||
| <path d="M 1 12.5029 159.7196 13.1004 258.993 53.9479 307.1794 28.7672 309.312 27.7151 360.0881 1.1058 405.4491 1 439.5504 20.8298 539.2083 78.9138 608.6921 119.0946 608.714 237.1806 799 466.0911 361.8514 466.9506 2.336 170.0917 1.8257 118.8377 1 12.5029 Z"/> | |||||
| </g> | |||||
| </svg> | |||||
| @@ -0,0 +1,6 @@ | |||||
| <?xml version="1.0"?> | |||||
| <svg xmlns="http://www.w3.org/2000/svg" version="1.2" baseProfile="tiny" width="800" height="808" viewBox="0 0 800 808" stroke-linecap="round" stroke-linejoin="round"> | |||||
| <g id="Melbourne"> | |||||
| <path d="M 2.1114 675.1822 1 653.8534 2.2459 607.5496 6.218 594.3641 16.1125 573.7801 22.5415 563.5946 39.7181 543.7578 61.3825 523.2763 72.6371 509.552 80.844 495.6147 81.7729 489.5048 80.4948 469.5689 71.6721 428.0917 72.6771 401.0805 80.0273 359.0609 100.9202 297.7427 106.8441 283.592 115.9852 267.9396 121.6578 262.8999 130.6341 259.6812 136.5619 260.108 144.6943 266.1077 150.8779 266.7488 156.5509 262.3525 162.8159 254.4188 165.0999 244.9858 163.6583 238.448 154.8466 227.089 143.3248 217.3388 134.8535 212.3039 120.4524 204.9121 96.4798 196.7749 83.2635 188.3126 60.3901 177.2822 53.6117 171.7116 49.8821 165.175 48.1482 153.0865 55.177 149.4391 61.1885 143.327 65.5228 132.8211 67.1957 126.4965 78.8015 129.1712 83.9569 98.6218 88.3578 87.9017 94.8765 76.9664 140.2715 43.2944 174.3392 88.515 205.896 129.7509 215.6372 129.1055 275.1182 137.1434 276.0117 141.7447 288.063 143.4868 296.5515 144.3153 297.2312 139.4683 299.1929 139.2655 348.967 146.0199 353.54 141.1395 358.7416 136.7833 364.6464 132.8365 367.263 131.4419 363.6212 125.011 365.9082 122.9744 366.4163 118.9013 361.079 102.7167 355.9947 68.7396 353.4528 58.986 339.3879 25.8673 346.9279 27.153 344.4706 19.5432 348.4521 14.9341 353.7888 1 443.8464 14.827 535.5951 28.7722 546.0998 30.4892 555.5862 40.6735 557.6179 48.3911 557.1075 59.1093 558.2076 64.7903 561.0868 70.1501 567.5239 75.8322 564.045 103.3777 614.2761 110.0359 604.6849 181.2058 666.7689 189.6906 645.2902 349.0681 789.4939 368.6347 794.3983 369.1602 799 368.7006 779.8997 512.1452 770.001 581.7086 769.152 586.6386 769.3184 592.5338 770.1236 597.4947 769.9484 600.8698 745.1648 753.8751 738.3219 807.3138 708.2161 802.4724 689.1784 736.341 665.0856 652.4086 659.926 640.7238 652.6241 630.196 637.4529 615.8662 633.4361 610.1736 631.6497 605.4569 630.4677 600.5583 629.3957 584.6035 621.597 587.5028 589.0997 599.3126 583.0708 601.5803 560.5583 572.8499 550.4005 565.8808 545.321 565.0224 514.8424 568.9832 491.2387 564.0881 478.269 560.3963 383.5338 541.6421 376.3373 540.892 365.0634 540.0841 343.0829 540.41 324.9658 542.0385 307.5965 544.5515 285.7226 549.1889 232.3634 562.7847 223.8395 565.495 211.1012 571.6845 145.6233 614.5652 140.9428 617.3652 132.775 621.0978 144.2682 638.6295 146.8608 642.7799 149.0034 650.8995 150.8862 659.3354 151.7671 661.0501 156.1836 678.166 152.6846 679.1745 154.733 687.0015 154.6612 687.709 131.2273 703.426 133.237 709.0471 135.7854 713.3357 135.0796 713.725 137.2858 717.4543 137.9237 716.6073 155.748 746.1243 168.2499 767.479 170.2849 771.3284 169.2681 773.363 150.6753 784.6276 147.7343 784.6757 133.35 792.9694 134.9251 795.6099 131.6369 797.5852 99.0313 742.8982 96.2735 744.5316 91.8034 726.8589 88.8165 727.1836 82.4637 713.6896 80.3946 714.6936 78.7637 711.0576 82.473 709.5781 80.0589 703.4514 80.402 687.6461 77.9264 686.3683 76.1544 683.429 73.0874 682.7925 68.6367 682.7974 65.5575 683.4107 50.7682 687.1124 58.7871 712.8747 65.8846 736.6287 71.8237 756.1871 88.373 783.2581 86.0977 790.678 84.2559 792.3207 82.2962 795.4532 70.8932 792.7662 56.9831 783.9808 30.1262 744.2214 14.1352 713.5671 11.7766 705.8318 5.7589 690.186 2.1114 675.1822 Z"/> | |||||
| </g> | |||||
| </svg> | |||||
| @@ -0,0 +1,6 @@ | |||||
| <?xml version="1.0"?> | |||||
| <svg xmlns="http://www.w3.org/2000/svg" version="1.2" baseProfile="tiny" width="800" height="826" viewBox="0 0 800 826" stroke-linecap="round" stroke-linejoin="round"> | |||||
| <g id="New York City"> | |||||
| <path d="M 1.0561 788.2065 1 777.3387 2.1667 767.919 7.1776 753.9592 7.7408 753.257 19.6889 743.4714 19.1733 736.4749 15.8736 720.7461 13.3214 704.1587 17.9216 690.3615 29.6574 681.827 40.4142 673.0447 50.6596 674.5046 59.8983 675.0064 63.8565 669.7765 72.9478 639.1146 73.9196 634.4372 76.8201 616.5994 80.5664 608.8086 86.5397 599.7098 86.713 594.7037 80.4569 583.8498 81.4772 568.5276 83.3042 560.1669 80.6623 549.4937 82.5341 541.4227 82.8237 536.9431 90.3487 527.6947 92.2497 524.2845 100.8143 513.8887 106.5968 508.6254 112.6555 507.7397 141.1976 511.9367 167.0395 516.0196 168.8902 515.8074 180.3772 513.1629 192.2836 512.5518 199.2728 509.8708 214.55 505.0949 237.7126 504.7098 247.8808 498.3096 269.3732 498.0398 291.9685 498.1703 300.7628 479.6251 322.4152 432.5049 334.1048 407.6323 341.5273 355.8684 347.7376 322.6019 352.0345 300.9703 358.6023 287.8066 369.7353 267.6859 375.4431 256.4031 381.8621 245.1209 393.2143 224.0307 407.5275 199.0553 417.2192 180.4394 424.1978 168.7848 437.3029 129.1168 445.2703 109.4343 455.5957 87.0625 471.6742 52.6575 478.5913 29.4796 485.7705 5.8358 486.6346 1 498.6878 2.5126 505.9317 5.4402 518.8261 10.1494 533.9526 15.9489 545.5334 20.2474 568.6755 29.3636 571.9034 30.458 571.4816 27.2665 574.8983 25.9494 575.172 23.1314 576.1325 20.4576 579.2885 18.8063 579.7124 16.9238 578.1805 15.918 580.9419 12.7192 581.8192 14.7301 580.1841 17.3644 583.6203 19.0284 584.7734 17.1541 589.3155 19.8299 592.277 20.9438 592.3827 23.4552 597.3647 23.4545 598.4235 28.683 600.46 32.324 599.7907 36.2509 601.6447 42.4899 622.0886 50.1477 623.6005 48.121 645.4861 55.539 653.5608 58.1403 664.6384 62.0114 682.9989 67.9299 711.7578 77.8488 730.1523 84.3164 715.1862 134.2234 684.3419 169.6909 685.3996 196.7366 704.6433 222.1964 718.9944 240.397 727.3763 251.2121 737.2245 259.9178 770.1668 286.6302 785.0664 298.5909 796.9393 308.4605 799 332.6772 788.0651 354.864 783.1966 356.0929 774.9618 357.5745 761.621 362.476 756.357 365.4167 760.852 386.957 761.2636 400.4902 762.2471 427.3981 763.0196 445.6907 762.2481 449.6626 760.3684 455.7907 758.8834 471.5088 759.981 472.8796 760.3207 480.4336 761.9338 483.7511 763.3448 488.4758 763.3261 490.6436 764.279 493.2219 764.3148 496.0761 763.1463 497.6811 756.8398 500.4197 749.5203 501.8498 741.5906 505.4311 740.8332 507.1528 739.8273 514.086 740.0064 517.7148 738.7917 518.7764 742.4823 524.0536 743.8135 528.5943 740.7569 529.7987 738.8398 529.0409 741.0203 525.0451 739.1456 523.6385 736.9913 524.4268 735.1874 531.1473 733.1752 532.546 704.1997 547.477 704.6175 557.1062 705.7411 567.3354 708.0561 568.48 714.2457 574.0486 720.9779 575.6083 720.857 576.4054 728.3334 573.2589 732.7166 572.6742 734.9688 573.056 738.6729 581.1526 738.0962 581.765 741.1122 584.906 742.2637 586.7535 745.4253 589.0286 745.6077 590.2915 745.3276 602.7658 749.4943 602.8167 749.5599 606.7939 738.4603 607.7571 731.7379 609.9402 718.0648 622.8766 716.2268 722.1046 708.8452 721.3476 700.5062 719.7375 696.3997 718.6497 688.355 715.9196 684.1644 714.1625 679.2353 715.5271 664.4458 719.0464 658.331 720.2807 652.7153 722.4787 642.6668 726.0336 631.9031 730.8584 625.3639 734.7063 616.123 739.5363 605.4403 744.4472 596.4827 747.8227 590.0361 750.7859 582.3721 753.5775 572.94 757.6178 556.5738 763.8266 547.5478 766.7544 540.0489 768.7917 531.7078 770.2957 527.0882 770.7313 509.0903 796.5336 399.5656 745.2945 311.1386 766.1914 288.991 771.366 259.5459 778.8798 230.3692 785.5898 175.1875 797.4201 153.8584 802.0977 45.0623 825.4271 31.1041 818.1502 9.1673 806.5092 3.4849 793.3998 1.0561 788.2065 Z M 304.68 426.1053 305.8958 424.1208 308.9712 425.8869 309.3327 428.5393 307.6986 428.8741 304.68 426.1053 Z"/> | |||||
| </g> | |||||
| </svg> | |||||
| @@ -0,0 +1,6 @@ | |||||
| <?xml version="1.0"?> | |||||
| <svg xmlns="http://www.w3.org/2000/svg" version="1.2" baseProfile="tiny" width="800" height="429" viewBox="0 0 800 429" stroke-linecap="round" stroke-linejoin="round"> | |||||
| <g id="Paris"> | |||||
| <path d="M 1.1452 241.2205 1 237.4829 2.1328 227.4492 3.8836 218.8229 8.4641 204.13 11.3579 196.1589 14.4675 183.4708 15.7986 180.4028 21.3915 170.6974 26.9436 161.953 29.4376 160.7348 44.1514 154.5423 51.6202 151.7761 54.1888 150.2388 56.0911 148.321 63.6112 139.1991 70.9714 128.1625 100.8005 139.4708 102.7382 138.5696 112.4966 109.7808 114.0565 108.8772 174.4375 120.3797 182.4735 116.7342 185.5204 96.5354 185.8323 95.7863 200.9981 77.9056 218.9065 64.5675 219.976 63.6594 231.4765 61.6421 242.6681 52.6493 258.0757 41.7699 272.0884 31.5974 287.6312 22.7171 300.0525 16.893 307.723 13.4764 313.6483 7.9305 331.5708 6.9704 345.5326 6.6003 368.5479 5.7682 416.1706 4.3133 420.347 4.0003 438.5662 3.6567 475.0873 2.5099 521.5698 1 541.8911 6.7889 557.5976 20.2028 564.8641 38.3118 567.6716 54.3482 568.1255 59.1892 569.512 69.708 569.6096 83.5956 572.4573 91.5148 576.9334 97.4611 584.2356 103.0152 595.389 107.7814 602.3415 108.9589 612.7805 128.1864 616.4009 146.8594 617.698 164.9807 617.2517 188.9443 617.9049 196.3457 621.9079 232.832 622.704 238.9878 624.9111 258.9437 625.6949 264.3738 623.2927 282.5603 619.4085 301.6744 616.2449 318.2206 612.2388 334.6925 609.1393 337.8099 613.927 339.2173 619.0464 339.4845 625.4606 338.3477 633.6625 334.8177 642.5383 329.7021 644.4034 328.4087 642.8408 324.1905 641.2906 314.8797 639.2743 306.8233 635.9069 300.1726 635.4266 295.4789 636.9834 292.4363 636.9122 290.8374 644.132 285.5408 645.6529 287.0118 649.3197 294.48 652.7689 299.0006 653.6947 299.2198 681.6139 302.8338 681.7472 301.8122 693.161 303.289 695.5707 285.1316 703.9244 286.2198 704.7413 278.4668 723.4533 279.2642 723.0822 283.3038 732.7695 284.7466 746.6826 287.7546 760.9506 290.5341 769.9684 293.1572 774.4105 294.9781 777.8523 296.8727 782.0482 300.041 785.656 303.9295 787.9813 306.9883 790.7637 312.0208 794.7559 318.0489 797.5162 321.754 799 325.3792 798.8225 329.4728 797.1244 335.7583 795.2192 338.7431 789.1749 343.4788 787.1008 345.796 785.1668 349.0039 783.9179 352.7719 782.4255 360.0605 782.0167 363.7881 782.3349 368.6401 785.0004 368.916 787.4315 370.0799 786.0863 375.2698 784.4308 384.0923 782.5515 390.1272 776.8558 405.2945 775.9919 409.5386 776.5295 411.0947 762.9898 421.068 758.3827 421.0456 749.7177 420.4731 745.7121 419.7031 737.6102 417.1755 733.7481 416.4239 727.1661 416.114 718.6206 416.5062 711.112 416.4775 707.7882 416.0807 702.4687 414.5486 693.8093 415.21 694.1954 410.8374 692.561 409.5624 689.2951 408.3981 686.6993 408.158 683.5003 409.9791 683.8935 405.6608 671.1023 392.2274 672.1393 390.4802 666.4668 387.7609 662.8448 386.6554 655.7548 385.494 650.3183 385.4448 640.0215 386.1085 636.9657 385.9562 628.336 383.1917 624.623 382.5828 613.3897 382.7343 607.4978 381.5768 603.6547 379.7666 599.3825 376.453 596.0463 373.1307 588.3551 364.4839 586.2374 362.5792 580.4532 358.915 558.5518 368.3838 554.0212 369.4701 539.1604 379.3157 536.0247 381.857 512.3089 394.6717 509.8134 398.253 488.3938 408.9958 487.5844 408.8845 465.0423 420.4199 453.4683 426.06 429.1192 426.495 417.6804 413.8513 399.8731 427.0262 391.7846 425.8368 391.994 428.4576 387.3042 426.0353 382.7958 424.6658 373.0349 423.9704 356.9253 422.5892 350.5307 421.2929 352.581 415.4646 316.6505 403.2678 268.503 387.0692 254.9724 382.3763 239.7271 377.3908 222.0958 371.3221 193.3232 352.9182 179.3269 345.088 168.7117 358.6129 158.8035 367.3444 142.7554 367.7404 142.1015 367.1602 141.1275 349.4285 150.0047 342.2832 146.2674 338.2972 143.2491 334.5354 141.6916 334.2855 137.4956 335.1422 127.0375 337.8626 101.6768 333.3605 90.313 313.1035 88.941 293.4265 93.2311 280.211 87.1915 279.9208 60.399 269.497 53.5435 260.2613 50.3471 257.7561 1.1452 241.2205 Z"/> | |||||
| </g> | |||||
| </svg> | |||||
| @@ -881,6 +881,19 @@ const cityData = [["Perris, CA", 81964684.1824094, 17340.390703739322], | |||||
| ["Santa Barbara, CA", 50991347.46845491, 7484.009670940266], | ["Santa Barbara, CA", 50991347.46845491, 7484.009670940266], | ||||
| ["Rio Rancho, NM", 269136968.1901309, 23814.351777786604]]; | ["Rio Rancho, NM", 269136968.1901309, 23814.351777786604]]; | ||||
| const globalCityData = [ | |||||
| ["London", 1595951001.243258, 45078.7351319594], | |||||
| ["Paris", 105295835.99015382, 9638.711635935364], | |||||
| ["Melbourne", 37645388.45504674, 8374.051389167866], | |||||
| ["Sydney", 4324012960.9402275, 89922.41773568685], | |||||
| ["Berlin", 889606455.0316621, 37503.65910136853], | |||||
| ["Moscow", 2556449120.0771136, 97614.50005992019], | |||||
| ["Seoul", 607651322.3035502, 30365.92222630693], | |||||
| ["Madrid", 605538730.8845485, 36915.51233779266], | |||||
| ["Hong Kong", 152936581.1183557, 11981.32777728141], | |||||
| ["Beijing", 16426832679.115694, 178940.11723688344], | |||||
| ] | |||||
| function makePlanet(name, diameter, mass, image) { | function makePlanet(name, diameter, mass, image) { | ||||
| return { | return { | ||||
| name: name, | name: name, | ||||
| @@ -928,7 +941,7 @@ function makeMountains() { | |||||
| }; | }; | ||||
| } | } | ||||
| function makeGIS(data, category) { | |||||
| function makeGIS(data, category, rename=true) { | |||||
| const baseLength = math.unit(1, "meters"); | const baseLength = math.unit(1, "meters"); | ||||
| const baseArea = math.unit(1, "meters^2"); | const baseArea = math.unit(1, "meters^2"); | ||||
| return { | return { | ||||
| @@ -960,7 +973,7 @@ function makeGIS(data, category) { | |||||
| name: name, | name: name, | ||||
| rename: true, | rename: true, | ||||
| image: { | image: { | ||||
| source: "./media/naturals/" + category.toLowerCase().replace(/ /g, "-") + "/" + name.toLowerCase().replace(/ /g, "-") + ".svg" | |||||
| source: "./media/naturals/" + category.toLowerCase().replace(/ /g, "-") + "/" + (rename ? name.toLowerCase().replace(/ /g, "-") + ".svg" : name + ".svg") | |||||
| } | } | ||||
| } | } | ||||
| }); | }); | ||||
| @@ -1087,6 +1100,13 @@ function makeNaturals() { | |||||
| "Cities" | "Cities" | ||||
| )); | )); | ||||
| results.push(makeGIS( | |||||
| globalCityData.sort((s1, s2) => { | |||||
| return s1[0].localeCompare(s2[0]) | |||||
| }), | |||||
| "Global Cities", | |||||
| false | |||||
| )); | |||||
| results.push(makeSkylines( | results.push(makeSkylines( | ||||
| [ | [ | ||||
| ["Los Angeles", math.unit(1018, "feet")], | ["Los Angeles", math.unit(1018, "feet")], | ||||
| @@ -0,0 +1,2 @@ | |||||
| *.svg | |||||
| *.json | |||||
| @@ -0,0 +1,10 @@ | |||||
| London | |||||
| Paris | |||||
| Melbourne | |||||
| Sydney | |||||
| Berlin | |||||
| Moscow | |||||
| Seoul | |||||
| Madrid | |||||
| Hong Kong | |||||
| Beijing | |||||
| @@ -0,0 +1,88 @@ | |||||
| import requests | |||||
| import sys | |||||
| import urllib.parse | |||||
| import json | |||||
| import subprocess | |||||
| import os | |||||
| def get_polygon(name): | |||||
| if not os.path.isfile(name + ".json"): | |||||
| url = "https://nominatim.openstreetmap.org/search.php?q={0}&polygon_geojson=1&format=jsonv2".format( | |||||
| urllib.parse.quote(name) | |||||
| ) | |||||
| r = requests.get(url) | |||||
| data = json.loads(r.text) | |||||
| if data is None: | |||||
| raise ValueError("Bogus results") | |||||
| osm_id = None | |||||
| for entry in data: | |||||
| if "boundary" in entry["category"] and entry["osm_type"] == "relation": | |||||
| osm_id = entry["osm_id"] | |||||
| break | |||||
| if not osm_id: | |||||
| raise ValueError("No id") | |||||
| url = "http://polygons.openstreetmap.fr/get_geojson.py?id={0}¶ms=0".format(osm_id) | |||||
| with open(name + ".json", "w") as file: | |||||
| file.write(requests.get(url).text) | |||||
| else: | |||||
| data = json.load(open(name + ".json")) | |||||
| info = subprocess.check_output( | |||||
| [ | |||||
| "mapshaper", | |||||
| "-i", | |||||
| "{0}.json".format(name), | |||||
| "-each", | |||||
| "console.log(this.centroidX, this.centroidY, this.area)"], | |||||
| shell=True, | |||||
| stderr=subprocess.STDOUT, | |||||
| ).decode("utf-8") | |||||
| lon, lat, area = list(map(float, info.split(" "))) | |||||
| if area is not None: | |||||
| info = subprocess.check_output( | |||||
| [ | |||||
| "mapshaper", | |||||
| "-i", | |||||
| "{0}.json".format(name), | |||||
| "-proj", | |||||
| "+proj=nsper", | |||||
| "+h=100000", | |||||
| "+lat_0={0}".format(lat), | |||||
| "+lon_0={0}".format(lon), | |||||
| "-simplify", | |||||
| "resolution=500x500", | |||||
| "-each", | |||||
| "console.log(\"HEIGHT:\" + this.height)", | |||||
| "-o", | |||||
| "{0}.svg".format(name), | |||||
| ], | |||||
| shell=True, | |||||
| stderr=subprocess.STDOUT, | |||||
| ).decode("utf-8") | |||||
| height = None | |||||
| for line in info.split("\n"): | |||||
| if "HEIGHT:" in line: | |||||
| height = float(line.split(":")[1].strip()) | |||||
| print("[\"{0}\", {1}, {2}],".format(name, area, height)) | |||||
| if __name__ == "__main__": | |||||
| if len(sys.argv) < 2: | |||||
| print("Usage: {0} list-of-cities".format(sys.argv[0])) | |||||
| else: | |||||
| city = None | |||||
| try: | |||||
| for city in open(sys.argv[1]).readlines(): | |||||
| try: | |||||
| get_polygon(city.strip()) | |||||
| except ValueError as e: | |||||
| print(city + " failed") | |||||
| print(e) | |||||
| except Exception as e: | |||||
| print(city + " failed") | |||||
| print(e) | |||||
| @@ -0,0 +1,41 @@ | |||||
| import subprocess | |||||
| import sys | |||||
| import json | |||||
| def get_centroids(file, field_name): | |||||
| results = {} | |||||
| for entry in subprocess.check_output( | |||||
| [ | |||||
| "mapshaper", | |||||
| "-i", | |||||
| file, | |||||
| "-each", | |||||
| "\"console.log(JSON.stringify({{name: {0}, lon: this.centroidX, lat: this.centroidY}}))\"".format(field_name) | |||||
| ], | |||||
| shell = True, | |||||
| stderr = subprocess.STDOUT | |||||
| ).decode("utf-8").split("\n"): | |||||
| print(entry) | |||||
| parts = json.loads(entry) | |||||
| results[parts["name"]] = { | |||||
| "lon": float(parts["lon"]), | |||||
| "lat": float(parts["lat"]) | |||||
| } | |||||
| return results | |||||
| def extract_shape(file, field_name, field_value): | |||||
| lat, lon = subprocess.check_output( | |||||
| [ | |||||
| "mapshaper", | |||||
| "-i", | |||||
| file, | |||||
| "-filter", | |||||
| "\"{0} == {1}\"".format(field_name, field_value), | |||||
| "-each", | |||||
| "\"console.log(this.centroidX, this.centroidY)" | |||||
| ] | |||||
| ) | |||||
| if __name__ == "__main__": | |||||
| print(get_centroids(sys.argv[1], sys.argv[2])) | |||||