[GRASS-dev] [GRASS GIS] #2893: Specify crs when exporting to GeoJSON

GRASS GIS trac at osgeo.org
Wed Feb 3 04:49:21 PST 2016


#2893: Specify crs when exporting to GeoJSON
--------------------------+-------------------------
  Reporter:  pmav99       |      Owner:  grass-dev@…
      Type:  defect       |     Status:  new
  Priority:  normal       |  Milestone:
 Component:  Default      |    Version:  unspecified
Resolution:               |   Keywords:  v.out.ogr
       CPU:  Unspecified  |   Platform:  Unspecified
--------------------------+-------------------------

Comment (by pmav99):

 Hmm... it seems `ogr2ogr`'s implicit choices can lead to bugs :

 If we erase the CRS field from `3857.json`:
 {{{
 $ cat 3857.json
 {
 "type": "FeatureCollection",
 "features": [
 { "type": "Feature", "properties": { }, "geometry": { "type": "Polygon",
 "coordinates": [ [ [ -9386772.821532785892487, 4162454.812297557480633 ],
 [ -9383256.718231666833162, 4193793.993894479703158 ], [
 -9377600.378138564527035, 4198533.089648159220815 ], [
 -9386772.821532785892487, 4162454.812297557480633 ] ] ] } }
 ]
 }
 }}}
 Then `ogrinfo` assumes that EPSG is 4326:
 {{{
 $ ogrinfo -so -al 3857.json
 ERROR 4: GeoJSON Driver doesn't support update.
 Had to open data source read-only.
 INFO: Open of `3857.json'
       using driver `GeoJSON' successful.

 Layer name: OGRGeoJSON
 Geometry: Polygon
 Feature Count: 1
 Extent: (-9386772.821533, 4162454.812298) - (-9377600.378139,
 4198533.089648)
 Layer SRS WKT:
 GEOGCS["WGS 84",
     DATUM["WGS_1984",
         SPHEROID["WGS 84",6378137,298.257223563,
             AUTHORITY["EPSG","7030"]],
         AUTHORITY["EPSG","6326"]],
     PRIMEM["Greenwich",0,
         AUTHORITY["EPSG","8901"]],
     UNIT["degree",0.0174532925199433,
         AUTHORITY["EPSG","9122"]],
     AUTHORITY["EPSG","4326"]]
 }}}
 reprojecting does not make any changes to the coords (which is reasonable
 I guess):
 {{{
 $ ogr2ogr -f GeoJSON -t_srs "EPSG:4326" 4326_implicit.json 3857.json

 $ cat 4326_implicit.json
 {
 "type": "FeatureCollection",
 "crs": { "type": "name", "properties": { "name":
 "urn:ogc:def:crs:OGC:1.3:CRS84" } },
 "features": [
 { "type": "Feature", "properties": { }, "geometry": { "type": "Polygon",
 "coordinates": [ [ [ -9386772.821532784029841, 4162454.812297557014972 ],
 [ -9383256.718231666833162, 4193793.993894479703158 ], [
 -9377600.378138564527035, 4198533.089648158289492 ], [
 -9386772.821532784029841, 4162454.812297557014972 ] ] ] } }
 ]
 }
 }}}
 but this particular `(coords, crs)` combination is obviously garbage:
 {{{
 $ ogr2ogr -f GeoJSON -t_srs "EPSG:3857" 3857_implicit.json
 4326_implicit.json

 Failed to reproject feature 0 (geometry probably out of source or
 destination SRS).
 ERROR 1: Terminating translation prematurely after failed
 translation of layer OGRGeoJSON (use -skipfailures to skip errors)
 }}}

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/2893#comment:1>
GRASS GIS <https://grass.osgeo.org>



More information about the grass-dev mailing list