Geographic Information Systems Asked by Michael Smith on December 28, 2020
I’ve generated a GeoJSON file using ogr2ogr from an ESRI Shapefile for UK Protected Wrecks provided by Historic England – the standard format for the outputted GeoJSON is:
{
"type":"Feature",
"properties":{
"ListEntry":1000043,
"Name":"HMS/m A1",
"DesigDate":"1998-11-04",
"LegacyUID":"911782",
"SInumber":"1998/2708n2004/2395",
"AmendDate":"2004-10-05",
"Latitude":50.74251829,
"Longitude":-0.92132,
"Easting":476206.35448699998,
"Northing":94211.245704100002,
"AREA_HA":28.238722280800001,
"Hyperlink":"https://historicengland.org.uk/listing/the-list/list-entry/1000043"
},
"geometry":{
"type":"Polygon",
"coordinates":[
[
[
-0.921053211377258,
50.73982686135377
],
[
-0.921319931341618,
50.739821495575519
],
[
-0.921586803074952,
50.739826860085856
],
[
-0.921852682712183,
50.739842785133959
],
[
-0.922116371451876,
50.739869271337817
],
[
-0.922376888692504,
50.739906321342211
],
[
-0.922633365181112,
50.7399535934995
],
[
-0.922884493925816,
50.740010922885169
],
[
-0.923129584259222,
50.740078151175176
],
[
-0.923367458509566,
50.740155096669646
],
[
-0.923597287801228,
50.740241260747069
],
[
-0.923818068308893,
50.740336480412466
],
[
-0.924028957585509,
50.740440414306129
],
[
-0.924229287896487,
50.740552393541655
],
[
-0.924418045383537,
50.740672256842259
],
[
-0.924594739643904,
50.740799325270572
],
[
-0.924758346006215,
50.740933102915804
],
[
-0.924908391860252,
50.741073245542815
],
[
-0.925044338137426,
50.741219091749898
],
[
-0.925165544011153,
50.74136996660507
],
[
-0.925271655704711,
50.741525532356611
],
[
-0.925362020321129,
50.74168495837651
],
[
-0.925436613517539,
50.741847568207319
],
[
-0.925494781956336,
50.742012858550453
],
[
-0.925536695696425,
50.742180327392205
],
[
-0.925561674431689,
50.74234897656109
],
[
-0.925570218797828,
50.742518288189977
],
[
-0.925561834889821,
50.742687603046342
],
[
-0.92553669807626,
50.742856248271508
],
[
-0.925494958265783,
50.743023548966583
],
[
-0.925436614923385,
50.743188839631216
],
[
-0.925362185343822,
50.74335161870443
],
[
-0.925271820479418,
50.743511043109173
],
[
-0.925165709857077,
50.74366644278242
],
[
-0.925044507360034,
50.743817481077109
],
[
-0.924908556401517,
50.743963330163851
],
[
-0.924758513608514,
50.744103473554809
],
[
-0.924594904369409,
50.744237246965092
],
[
-0.924418382556721,
50.744364318233174
],
[
-0.924229624442886,
50.744484182739008
],
[
-0.924029291798829,
50.744596165762381
],
[
-0.923818230418854,
50.744700098786211
],
[
-0.923597453373799,
50.744795318429468
],
[
-0.923367623351867,
50.744881484525848
],
[
-0.923129744951845,
50.744958429135977
],
[
-0.922884658916512,
50.74502565187327
],
[
-0.922633373217608,
50.745083148513451
],
[
-0.922377054461851,
50.745130426189689
],
[
-0.922116371725032,
50.745167303099166
],
[
-0.921852675624734,
50.745193792596282
],
[
-0.921586809412671,
50.745209720799288
],
[
-0.921319929911502,
50.745215084902021
],
[
-0.921053045996393,
50.745209720665699
],
[
-0.920787339075089,
50.745193789203327
],
[
-0.920523483667514,
50.74516730485864
],
[
-0.920262970215599,
50.745130426227497
],
[
-0.920006486412283,
50.745083148907732
],
[
-0.919755356425044,
50.745025649760215
],
[
-0.919510273383637,
50.744958426254769
],
[
-0.919272399531752,
50.744881483802203
],
[
-0.919042565497366,
50.744795317561852
],
[
-0.918821616421575,
50.744700099086522
],
[
-0.918610729602765,
50.744596162188252
],
[
-0.918410395610808,
50.744484178747165
],
[
-0.918221636749465,
50.744364317474066
],
[
-0.918045113561331,
50.744237252728396
],
[
-0.917881329203046,
50.744103475752183
],
[
-0.917731294775485,
50.743963330518682
],
[
-0.9175955121779,
50.74381748361975
],
[
-0.917474309783834,
50.743666442657378
],
[
-0.917368195573496,
50.743511038844467
],
[
-0.91727783748625,
50.743351619255684
],
[
-0.917203237273505,
50.743188839530276
],
[
-0.917145066817832,
50.743023550374907
],
[
-0.917103327344731,
50.742856244639682
],
[
-0.91707818436289,
50.74268760464593
],
[
-0.917069801141472,
50.742518286607833
],
[
-0.917078177369341,
50.742348972192566
],
[
-0.917103327216529,
50.742180329705135
],
[
-0.917145071689608,
50.742012861079012
],
[
-0.917203405919222,
50.741847568966222
],
[
-0.917277837611697,
50.741684959572424
],
[
-0.917368364924271,
50.741525536455896
],
[
-0.917474473418709,
50.741369968377484
],
[
-0.917595680142749,
50.741219096151177
],
[
-0.917731637253649,
50.741073249242191
],
[
-0.917881672908469,
50.740933103032319
],
[
-0.91804528976143,
50.740799326426547
],
[
-0.918221806744875,
50.740672259280146
],
[
-0.91841073060137,
50.740552395170582
],
[
-0.918610893458338,
50.740440413868789
],
[
-0.918821955716995,
50.740336477639616
],
[
-0.919042731243519,
50.740241261593553
],
[
-0.919272563496759,
50.740155092331399
],
[
-0.919510443619816,
50.740078149305738
],
[
-0.91975552696369,
50.740010929149008
],
[
-0.920006654851573,
50.739953595550006
],
[
-0.920263133331028,
50.739906318307099
],
[
-0.920523643334552,
50.739869273128996
],
[
-0.920787338647848,
50.739842781300474
],
[
-0.921053211377258,
50.73982686135377
]
]
]
}
},
I want to store the data in MongoDB to work with MongoDB GeoSpatial queries – I’m interested in performing queries against the Latitude and Longitude in the "properties" key of the GeoJSON entry so I’m considering adding a Point to the GeoJSON data.
As it’s my data store I can sort of fudge the data to make it work but I’m curious – can a Point and a Polygon be added to a single GeoJSON feature entry? My reading of RFC 7946 (Section 3.1) seems to indicate that you can’t add both a Point and a Polygon to a single entry and you’d effectively need to duplicate the entry if you wanted both items stored as geometries.
You can use a GeometryCollection
as stated in the specs e.g https://tools.ietf.org/html/rfc7946#section-3.1.8
You can find in the same spec in the appendix an example e.g https://tools.ietf.org/html/rfc7946#appendix-A.7 or a more complete sample at https://github.com/openlayers/openlayers/issues/8873
Correct answer by ThomasG77 on December 28, 2020
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP