Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

#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)

gdal_2x_fail.json (136.5 KB ) - added by hbgdal 7 years ago.
Json that fails for 2.x but works for 1.9
gdal_2x_succeeds_with_dummy_geom.json (161.0 KB ) - added by hbgdal 7 years ago.
Added dummy geometry fields to the json for gdal 2.x parsing.
gdal_shp.dbf (176.9 KB ) - added by hbgdal 7 years ago.
dbf file generated by old gdal.

Download all attachments as: .zip

Change History (10)

by hbgdal, 7 years ago

Attachment: gdal_2x_fail.json added

Json that fails for 2.x but works for 1.9

comment:1 by hbgdal, 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 Jukka Rahkonen, 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 hbgdal, 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 hbgdal, 7 years ago

Added dummy geometry fields to the json for gdal 2.x parsing.

comment:4 by hbgdal, 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

by hbgdal, 7 years ago

Attachment: gdal_shp.dbf added

dbf file generated by old gdal.

comment:5 by Even Rouault, 7 years ago

Resolution: fixed
Status: newclosed

In 40341:

ESRIJson: recognize documents that lack geometry fields (fixes #7071)

comment:6 by Even Rouault, 7 years ago

In 40342:

ESRIJson: recognize documents that lack geometry fields (fixes #7071)

comment:7 by Even Rouault, 7 years ago

Milestone: 2.2.3
Note: See TracTickets for help on using tickets.