[gdal-dev] ogr2ogr - id field in database table is not being written to geojson file
David McKelvie
dmck at interactive.co.uk
Fri Sep 14 09:26:47 PDT 2018
Thanks Even;
>> There's a specific processing for the 'id' field indeed. It is written at the
>> 'id' JSon member, at the same level of 'properties'. And thus on reading, it
>> is exposed in the OGR Feature ID, not as an attribute.
Im not getting the id field at all. Each feature just has 'type', 'properties'
and 'geometry' fields.
-------------------------------------
"features": [
{ "type": "Feature",
"properties": { "type": "division", "name": "Divn 01", ... },
"geometry": { "type": "Polygon", "coordinates": [ [ [ -38056.0, -3762079.68 ], ... ] ] } },
{ "type": "Feature", "properties": { "type": "division", "name": "Divn 02",... },
"geometry": { "type": "Polygon", "coordinates": [ [ [-36255.78, -3757480.03 ], ... } },
--------------------------------------
>> Note: There have been some variations in recent GDAL versions about this
>> behaviour (particularly if the id field is string)
So maybe Ive got a version that just drops the 'id' field.
I think the www.gdal.org/drv_geojson.html page should be updated to say
something about this.
I have a work around where I use
-sql 'select location,id,name from areas'
in the ogr2ogr call, and that does add 'id' to the properties.
David
More information about the gdal-dev
mailing list