Geographic Information Systems Asked by Snowy on September 7, 2020
Looking for the right combination of ogr2ogr parameters to get a .shp bundle to GeoJSON and reverse the Coordinate pairs. I recognize that ESRI defines Polygons as clockwise (http://www.esri.com/library/whitepapers/pdfs/shapefile.pdf) but GeoJSON RFC defines Polygons counterclockwise.
Current command is
ogr2ogr -progress -overwrite -f GeoJSON -s_srs "EPSG: 3857" -t_srs crs:84 file0.json file0.shp
which makes GeoJSON that is invalid when consumed by other tools that follow the RFC at https://tools.ietf.org/html/rfc7946.
Any ideas? If this needs to be run twice to convert to an intermediate format that’s fine, if there is another (command line or automation) tool, I’m open to that also.
Read again the documentation of the GDAL GeoJSON driver https://gdal.org/drivers/vector/geojson.html and modify your command to produce GeoJSON that follows RFC 7946 by adding a layer creation option -lco RFC7946=YES
.
Excerpt from the documentation:
RFC 7946 write support
By default, the driver will write GeoJSON files following GeoJSON 2008 specification. When specifying the RFC7946=YES creation option, the RFC 7946 standard will be used instead.
The differences between the 2 versions are mentioned in Appendix B of RFC 7946 and recalled here for what matters to the driver: >
Coordinates must be geographic over the WGS 84 ellipsoid, hence if the spatial reference system specified at layer creation time is not EPSG:4326, on-the-fly reprojection will be done by the driver. >
Polygons will be written such as to follow the right-hand rule for orientation (counterclockwise external rings, clockwise internal rings).
The values of a “bbox” array are “[west, south, east, north]”, not “[minx, miny, maxx, maxy]”
Some extension member names (see previous section about round/tripping) are forbidden in the FeatureCollection, Feature and Geometry objects.
The default coordinate precision is 7 decimal digits after decimal separator.
There is also a note in the RFC that some developers obviously have not taken seriously:
Note: the [GJ2008] specification did not discuss linear ring winding order. For backwards compatibility, parsers SHOULD NOT reject Polygons that do not follow the right-hand rule.
Answered by user30184 on September 7, 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