[gdal-dev] How to read CSV with GeoJSON correctly?

Rahkonen Jukka (MML) jukka.rahkonen at maanmittauslaitos.fi
Wed Sep 6 23:38:21 PDT 2017


Hi,

I was thinking about this question on gis.stackexchange https://gis.stackexchange.com/questions/254536/how-to-convert-txt-containing-two-columns-id-and-geojson-geometry

I copy-pasted the CSV example and edited it to use semicolon as field separator. Then I read http://www.gdal.org/drv_csv.html and had a try with ogrinfo 

ogrinfo geojson_csv.csv -al -oo GEOM_POSSIBLE_NAMES=geoJSON
INFO: Open of `geojson_csv.csv'
      using driver `CSV' successful.

Layer name: geojson_csv
Geometry: Unknown (any)
Feature Count: 1
Layer SRS WKT:
(unknown)
Geometry Column = geoJSON
Id: String (0.0)
geoJSON: String (0.0)
OGRFeature(geojson_csv):1
  Id (String) = 49518
  geoJSON (String) = {type:Polygon,coordinates:[[[29.9596,-2.3272],[29.9189,-2.7
9],[29.3706,-2.8401],[29.1497,-2.5917],[29.0405,-2.7447],[28.8619,-2.5309],[29.1
1,-1.8602],[29.3616,-1.5092],[29.8237,-1.3089],[29.9149,-1.4825],[30.0524,-1.431
,[30.8394,-1.6514],[30.8567,-2.3151],[30.1356,-2.4382],[29.9596,-2.3272]]]}

The GeoJSON geometry is not recognized but ogrinfo converts it into a string, with double quetes removed. Is there something wrong in the CSV or in my syntax?

-Jukka Rahkonen-


More information about the gdal-dev mailing list