Skip to content

Instantly share code, notes, and snippets.

@simboli
Created November 7, 2022 09:42
Show Gist options
  • Save simboli/ff57bff0c1412a2437e07cf10d56967f to your computer and use it in GitHub Desktop.
Save simboli/ff57bff0c1412a2437e07cf10d56967f to your computer and use it in GitHub Desktop.
geoJson loader Shapely 2.0
Display the source blob
Display the rendered blob
Raw
{
"type": "FeatureCollection",
"generator": "overpass-ide",
"copyright": "The data included in this document is from www.openstreetmap.org. The data is made available under ODbL.",
"timestamp": "2022-11-07T09:26:39Z",
"features": [
{
"type": "Feature",
"properties": {
"@id": "relation/41470",
"admin_level": "8",
"boundary": "administrative",
"name": "Ariccia",
"ref:ISTAT": "058009",
"ref:catasto": "A401",
"type": "boundary",
"wikidata": "Q241744",
"wikipedia": "it:Ariccia"
},
"geometry": {
"type": "Polygon",
"coordinates": [
[
[
12.6339066,
41.6719345
],
[
12.6341764,
41.671614
],
[
12.6345747,
41.6712367
],
[
12.63515,
41.6709348
],
[
12.6357771,
41.6705413
],
[
12.6358201,
41.6704681
],
[
12.6359819,
41.6701926
],
[
12.6363465,
41.6697623
],
[
12.6383818,
41.6691845
],
[
12.6385791,
41.6691287
],
[
12.6395571,
41.6686745
],
[
12.6410727,
41.6679466
],
[
12.6417932,
41.6678787
],
[
12.6419546,
41.6678617
],
[
12.6427313,
41.6675968
],
[
12.6430795,
41.6673696
],
[
12.6437424,
41.6668668
],
[
12.6443874,
41.6666572
],
[
12.6448292,
41.6667197
],
[
12.6455094,
41.6668422
],
[
12.6461081,
41.6668907
],
[
12.6466823,
41.6669445
],
[
12.6470951,
41.6668369
],
[
12.64727,
41.6666512
],
[
12.6464384,
41.6654897
],
[
12.6462644,
41.6652468
],
[
12.6457488,
41.6642232
],
[
12.6453322,
41.6631468
],
[
12.645198,
41.6625387
],
[
12.64522,
41.6619167
],
[
12.6455283,
41.6610514
],
[
12.6455302,
41.6603399
],
[
12.6456933,
41.6598125
],
[
12.6455354,
41.6595293
],
[
12.644433,
41.6584792
],
[
12.6433002,
41.6576102
],
[
12.6426409,
41.6572439
],
[
12.6416663,
41.6569552
],
[
12.6415202,
41.6566806
],
[
12.6417934,
41.6561092
],
[
12.6422003,
41.6551552
],
[
12.6423618,
41.6546909
],
[
12.6428295,
41.6543743
],
[
12.643577,
41.6542831
],
[
12.6449053,
41.6544165
],
[
12.6460942,
41.6547389
],
[
12.646738,
41.6548716
],
[
12.6478241,
41.6543958
],
[
12.6485968,
41.6542857
],
[
12.6490854,
41.6547114
],
[
12.6491601,
41.6553169
],
[
12.6493368,
41.6557345
],
[
12.6495697,
41.6561957
],
[
12.6496165,
41.6562884
],
[
12.6495045,
41.656888
],
[
12.6494523,
41.6571671
],
[
12.6489762,
41.6577181
],
[
12.6488654,
41.6581088
],
[
12.6486147,
41.6584139
],
[
12.6479626,
41.6588399
],
[
12.6476155,
41.6591391
],
[
12.6476351,
41.659305
],
[
12.6476719,
41.6595395
],
[
12.6479711,
41.6599202
],
[
12.6486488,
41.6601058
],
[
12.6493821,
41.6604382
],
[
12.6498013,
41.6611092
],
[
12.6500002,
41.6612695
],
[
12.6504477,
41.6611787
],
[
12.6508455,
41.6611526
],
[
12.6510667,
41.6613346
],
[
12.6515599,
41.6616431
],
[
12.6518373,
41.6616118
],
[
12.6521231,
41.6616612
],
[
12.652359,
41.6617843
],
[
12.6526054,
41.661961
],
[
12.6529328,
41.6620131
],
[
12.6528926,
41.6621589
],
[
12.6554421,
41.6639219
],
[
12.6572532,
41.6650784
],
[
12.6574407,
41.6656748
],
[
12.6550865,
41.667841
],
[
12.6531587,
41.6676858
],
[
12.6530514,
41.6682388
],
[
12.6521287,
41.6690403
],
[
12.6533196,
41.6696093
],
[
12.6534698,
41.672262
],
[
12.6543925,
41.6729832
],
[
12.6550362,
41.6738808
],
[
12.6561949,
41.6760926
],
[
12.6567743,
41.677567
],
[
12.6578042,
41.6792338
],
[
12.6587698,
41.6796986
],
[
12.6596067,
41.6816377
],
[
12.6605723,
41.6829358
],
[
12.6626322,
41.6832563
],
[
12.6648853,
41.6838492
],
[
12.6654432,
41.6840095
],
[
12.6646278,
41.6855318
],
[
12.6648853,
41.6861247
],
[
12.6641879,
41.6881358
],
[
12.6648745,
41.6891693
],
[
12.6660547,
41.6903871
],
[
12.6659903,
41.6905474
],
[
12.6663229,
41.691004
],
[
12.667031,
41.6915408
],
[
12.667664,
41.6926865
],
[
12.6673636,
41.6928787
],
[
12.6671812,
41.6932072
],
[
12.6671598,
41.6935277
],
[
12.6675353,
41.6939122
],
[
12.6664731,
41.694465
],
[
12.6659152,
41.6949697
],
[
12.6653573,
41.6953142
],
[
12.6657114,
41.6961633
],
[
12.6674495,
41.6963075
],
[
12.6688549,
41.6967081
],
[
12.6703355,
41.697381
],
[
12.6718268,
41.6982702
],
[
12.6742515,
41.7003289
],
[
12.6762471,
41.7016987
],
[
12.6762257,
41.7025478
],
[
12.6805279,
41.7099809
],
[
12.6818361,
41.7108659
],
[
12.6833274,
41.7123316
],
[
12.6848471,
41.7132245
],
[
12.6855552,
41.7132245
],
[
12.6877761,
41.7130082
],
[
12.6897609,
41.712808
],
[
12.6905119,
41.714586
],
[
12.6910125,
41.7148191
],
[
12.691278,
41.7160026
],
[
12.6913895,
41.7171594
],
[
12.6915089,
41.7176792
],
[
12.691549,
41.7178539
],
[
12.6917108,
41.718558
],
[
12.6929275,
41.7221023
],
[
12.6930219,
41.7224961
],
[
12.6931868,
41.7229538
],
[
12.6940443,
41.7240858
],
[
12.6956578,
41.7264537
],
[
12.6969907,
41.7282116
],
[
12.6986411,
41.7300453
],
[
12.7003169,
41.7313551
],
[
12.701278,
41.732085
],
[
12.7067121,
41.7337178
],
[
12.7076019,
41.7339734
],
[
12.7086779,
41.734193
],
[
12.7101253,
41.7343803
],
[
12.710169,
41.7343822
],
[
12.6954864,
41.7400372
],
[
12.694435,
41.7403895
],
[
12.6940687,
41.7398311
],
[
12.6932458,
41.7388243
],
[
12.6925729,
41.7382414
],
[
12.6885214,
41.7351521
],
[
12.6865236,
41.7337503
],
[
12.6817535,
41.7311184
],
[
12.6800798,
41.7308942
],
[
12.6758741,
41.7308462
],
[
12.6748012,
41.731871
],
[
12.6693724,
41.7269748
],
[
12.6681285,
41.7246057
],
[
12.6661445,
41.7263416
],
[
12.6637179,
41.7241356
],
[
12.6640947,
41.7231235
],
[
12.6642887,
41.7227921
],
[
12.664227,
41.7225076
],
[
12.6642303,
41.7219322
],
[
12.66419,
41.7218693
],
[
12.6641131,
41.7217949
],
[
12.6633827,
41.7214866
],
[
12.6627509,
41.7211752
],
[
12.6610673,
41.7203091
],
[
12.6598318,
41.7197144
],
[
12.6582115,
41.7189248
],
[
12.6574353,
41.7184044
],
[
12.656854,
41.7187909
],
[
12.6566779,
41.7188176
],
[
12.6549602,
41.7184685
],
[
12.6537591,
41.7179746
],
[
12.653385,
41.7177585
],
[
12.6528877,
41.7173583
],
[
12.6518659,
41.7166634
],
[
12.6514111,
41.7163732
],
[
12.6510436,
41.7162253
],
[
12.6491502,
41.7158834
],
[
12.6484938,
41.7157425
],
[
12.647684,
41.7155147
],
[
12.6465281,
41.7153185
],
[
12.6442557,
41.7148267
],
[
12.6439346,
41.71478
],
[
12.6433851,
41.7153879
],
[
12.6431347,
41.7156261
],
[
12.6420798,
41.7165028
],
[
12.641138,
41.7174535
],
[
12.6399971,
41.7183557
],
[
12.6395261,
41.7180472
],
[
12.639087,
41.7177875
],
[
12.6383608,
41.7174386
],
[
12.6376518,
41.71717
],
[
12.6362802,
41.7169218
],
[
12.6356041,
41.7169084
],
[
12.6351136,
41.7169147
],
[
12.6348989,
41.7168691
],
[
12.6340222,
41.7165618
],
[
12.6315568,
41.7156041
],
[
12.6307198,
41.7151827
],
[
12.6304238,
41.7149646
],
[
12.6295715,
41.7155897
],
[
12.6288428,
41.7160698
],
[
12.6281801,
41.7164422
],
[
12.6232968,
41.718334
],
[
12.622579,
41.7187269
],
[
12.6220956,
41.718122
],
[
12.62337,
41.7159118
],
[
12.6233716,
41.7151594
],
[
12.6229259,
41.7136547
],
[
12.6218295,
41.7135224
],
[
12.6216797,
41.7136392
],
[
12.6212601,
41.7137287
],
[
12.6207055,
41.7135349
],
[
12.6209125,
41.7130787
],
[
12.6212068,
41.7122161
],
[
12.6216674,
41.7106498
],
[
12.621862,
41.70996
],
[
12.6220887,
41.7093529
],
[
12.6223523,
41.7088653
],
[
12.62274,
41.7083391
],
[
12.6233467,
41.7077217
],
[
12.6239719,
41.7072378
],
[
12.6248728,
41.7067164
],
[
12.6258532,
41.7062257
],
[
12.6340611,
41.7023527
],
[
12.6361822,
41.7013835
],
[
12.6367011,
41.7010969
],
[
12.637109,
41.700845
],
[
12.6374896,
41.7005457
],
[
12.6379827,
41.7000685
],
[
12.6383079,
41.6997166
],
[
12.639877,
41.6999977
],
[
12.6408708,
41.7001526
],
[
12.6419505,
41.7004508
],
[
12.6427482,
41.7007471
],
[
12.6434629,
41.7009191
],
[
12.6441678,
41.7007742
],
[
12.6443935,
41.7007937
],
[
12.6446343,
41.7008599
],
[
12.6457402,
41.7012116
],
[
12.6460218,
41.7013659
],
[
12.6464276,
41.7014757
],
[
12.6474903,
41.7018205
],
[
12.6458214,
41.7030838
],
[
12.6444596,
41.7042164
],
[
12.6442059,
41.7043918
],
[
12.6446774,
41.7046144
],
[
12.6454417,
41.7049247
],
[
12.6458323,
41.7051814
],
[
12.6472647,
41.704554
],
[
12.6475841,
41.7044095
],
[
12.6479477,
41.7042324
],
[
12.6483376,
41.7040182
],
[
12.648923,
41.7035444
],
[
12.6490846,
41.7033795
],
[
12.6493518,
41.7035445
],
[
12.649591,
41.7037395
],
[
12.6497364,
41.703921
],
[
12.6499015,
41.7038602
],
[
12.6504194,
41.7035082
],
[
12.6505995,
41.7034171
],
[
12.650772,
41.7033729
],
[
12.6509846,
41.7032733
],
[
12.6512974,
41.7030626
],
[
12.6521624,
41.7023691
],
[
12.6527782,
41.7019253
],
[
12.6533028,
41.7016245
],
[
12.6542179,
41.7012152
],
[
12.6553918,
41.7016692
],
[
12.6554092,
41.7018192
],
[
12.6552481,
41.7022319
],
[
12.6550087,
41.7029199
],
[
12.6547692,
41.7037299
],
[
12.6545373,
41.7046013
],
[
12.6555548,
41.7047633
],
[
12.6557269,
41.7046907
],
[
12.6558092,
41.7044225
],
[
12.6559065,
41.7040483
],
[
12.6560112,
41.7035679
],
[
12.6561085,
41.7030372
],
[
12.6561833,
41.702568
],
[
12.656333,
41.7022384
],
[
12.6565051,
41.7019814
],
[
12.6567181,
41.7016153
],
[
12.6571383,
41.7004431
],
[
12.6577311,
41.6994367
],
[
12.6578416,
41.6993729
],
[
12.6583728,
41.6992723
],
[
12.6586735,
41.6989401
],
[
12.6580764,
41.6981094
],
[
12.6579862,
41.6978937
],
[
12.6578831,
41.6976272
],
[
12.6577885,
41.6974295
],
[
12.6576242,
41.6973075
],
[
12.6571864,
41.6971275
],
[
12.6566282,
41.6968339
],
[
12.656157,
41.69656
],
[
12.6556985,
41.6962293
],
[
12.6551615,
41.695776
],
[
12.6547596,
41.6955117
],
[
12.6543323,
41.6952
],
[
12.653858,
41.6949267
],
[
12.6533657,
41.6946262
],
[
12.6530796,
41.6943907
],
[
12.6528533,
41.694104
],
[
12.6524622,
41.6938693
],
[
12.6524023,
41.6937595
],
[
12.6524347,
41.6935492
],
[
12.6524106,
41.6933652
],
[
12.6518821,
41.6928917
],
[
12.6518021,
41.6927003
],
[
12.6518053,
41.692533
],
[
12.6519195,
41.6922359
],
[
12.6520002,
41.6921277
],
[
12.6520977,
41.6920591
],
[
12.6524828,
41.6918673
],
[
12.6510878,
41.6873075
],
[
12.6511554,
41.6868315
],
[
12.6512601,
41.6862685
],
[
12.6515866,
41.6857397
],
[
12.6522248,
41.684706
],
[
12.6526495,
41.6840265
],
[
12.6525572,
41.6838472
],
[
12.6524537,
41.6836462
],
[
12.6523308,
41.6835268
],
[
12.6344585,
41.6760224
],
[
12.6341922,
41.6749922
],
[
12.633375,
41.6732103
],
[
12.6339066,
41.6719345
]
]
]
},
"id": "relation/41470"
},
{
"type": "Feature",
"properties": {
"@id": "node/72963067",
"@relations": [
{
"role": "admin_centre",
"rel": 41470,
"reltags": {
"admin_level": "8",
"boundary": "administrative",
"name": "Ariccia",
"ref:ISTAT": "058009",
"ref:catasto": "A401",
"type": "boundary",
"wikidata": "Q241744",
"wikipedia": "it:Ariccia"
}
}
]
},
"geometry": {
"type": "Point",
"coordinates": [
12.6713481,
41.720709
]
},
"id": "node/72963067"
}
]
}
import json
from shapely.geometry import MultiPolygon, Poing, shape
bound_multply = []
bound_names = []
geoJsonFileName="Ariccia.geojson"
with open(fname, encoding="utf-8") as geoJsonFile:
GeoData = json.load(geoJsonFileName)
for bound in GeoData['features']:
if bound.get('properties').get('type')=='boundary':
bound_shape = shape(bound['geometry'])
bound_multply.append(bound_shape)
bound_names.append(bound['properties']['name'])
bound_polygon = MultiPolygon(bound_multply)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment