#7071 closed defect (fixed)
Bug in geojson parsing
Reported by: | hbgdal | Owned by: | warmerdam |
---|---|---|---|
Priority: | normal | Milestone: | 2.2.3 |
Component: | default | Version: | unspecified |
Severity: | normal | Keywords: | |
Cc: |
Description
The attached geojson can be parsed by old version of gdal but not new version of gdal. Versions that fail(all in Ubuntu 14.04)
GDAL 2.2.2, released 2017/09/15 GDAL 2.2.1, released 2017/06/23
Version that still works
GDAL 1.9.2, released 2012/10/08
I am trying to move one of our projects from old GDAL to new version, and this is the bottleneck for us. I would appreciate 1) Any workarounds. 2) Patches for 2.x series./ Pointers to code changes. 3)
Attachments (3)
Change History (10)
by , 7 years ago
Attachment: | gdal_2x_fail.json added |
---|
comment:1 by , 7 years ago
Upon some more investigation, I realized this geojson file does not have any "geometry" field. Its just that old gdal used to work.
Please feel free to close the bug, if gdal behavior is as expected.
comment:2 by , 7 years ago
Your data are json but not GeoJSON that must follow either the older specification http://geojson.org/geojson-spec.html or the newer one https://tools.ietf.org/html/rfc7946. File is not either of the ESRI json variant which is also supported by the driver as documented in http://www.gdal.org/drv_geojson.html.
This is not a bug because it is not supposed to work. However, if older GDAL could find some data from such plain json file and 2.x does not then there has perhaps happened some undocumented regression. What does your old GDAL report with
-ogrinfo -al -so gdal_2x_fail.json
comment:3 by , 7 years ago
It is a ESRI json variant. The file comes from an ArcGIS REST server. If I add dummy geometry fields with each record, gdal 2.x also parses fine. (Will attach the modified json. The output you requested is given below).
ogrinfo -al -so gdal_2x_fail.json ERROR 4: GeoJSON Driver doesn't support update. Had to open data source read-only. INFO: Open of `gdal_2x_fail.json'
using driver `GeoJSON' successful.
Layer name: OGRGeoJSON Geometry: None Feature Count: 1000 Layer SRS WKT: (unknown) FID Column = OBJECTID OBJECTID: Integer (0.0) PIN: String (20.0) SiteAddres: String (100.0) PrmaryName: String (50.0)
by , 7 years ago
Attachment: | gdal_2x_succeeds_with_dummy_geom.json added |
---|
Added dummy geometry fields to the json for gdal 2.x parsing.
comment:4 by , 7 years ago
Some more informationi. old ogr2ogr is able to convert it to shapefile (creates only dbf file as there is no geometry).
I am able to use both old and new gdal to upload just the dbf file to postgres/postgis.
# command to generate gdal_shp.dbf
ogr2ogr -f 'ESRI Shapefile' gdal_shp.shp gdal_2x_fail.json
# sample command to upload the dbf file as table. ogr2ogr -f "PostgreSQL" -overwrite PG:"dbname=mydb tables=dummy" gdal_shp.dbf -nln tmpxx
comment:7 by , 7 years ago
Milestone: | → 2.2.3 |
---|
Json that fails for 2.x but works for 1.9