[gdal-dev] Converting fid from GeoJSON into GeoPackage

Rahkonen Jukka (MML) jukka.rahkonen at maanmittauslaitos.fi
Mon Jun 21 08:04:30 PDT 2021


Take this GeoJSON

"type": "FeatureCollection",
"features": [{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [26.30578223, 60.26170791]

Ogrinfo knows the fid

Convert into a new GeoPackage and the native fid is lost
ogr2ogr -f gpkg one_feature.gpkg one_feature.json

Running the command with "-preserve_fid" keeps the native fid but according to ogr2ogr documentation https://gdal.org/programs/ogr2ogr.html that should not be needed:

"Use the FID of the source features instead of letting the output driver automatically assign a new one (for formats that require a FID). If not in append mode, this behavior is the default if the output driver has a FID layer creation option, in which case the name of the source FID column will be used and source feature IDs will be attempted to be preserved."

Is the error in the documentation or in the GeoJSON-GeoPackage conversion?

-Jukka Rahkonen-

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20210621/287ecf0f/attachment.html>

More information about the gdal-dev mailing list