[gdal-dev] Converting fid from GeoJSON into GeoPackage
Rahkonen Jukka (MML)
jukka.rahkonen at maanmittauslaitos.fi
Mon Jun 21 08:22:37 PDT 2021
I believe this resolves my previous problem by the same. The indirect_sqlite dialect is not so handy in this case because it wants do download the whole collection from OAPIF.
So because OAPIF is sending data as GeoJSON there is no name for the FID column and it is obligatory to use ogr2ogr with "-preserve_fid" if the aim is to preserve FID. I will see if there is something to improve with this in the documentation. I had some trouble with joining edited data with the original because 15 million feature ids changed into counting numbers.
Lähettäjä: Even Rouault <even.rouault at spatialys.com>
Lähetetty: maanantai 21. kesäkuuta 2021 18.09
Vastaanottaja: Rahkonen Jukka (MML) <jukka.rahkonen at maanmittauslaitos.fi>; 'gdal-dev at lists.osgeo.org' <gdal-dev at lists.osgeo.org>
Aihe: Re: [gdal-dev] Converting fid from GeoJSON into GeoPackage
Automatic FID preservation requires that the source layer reports a non-empty column name for the FID column, which isn't the case of the GeoJSON driver. Mostly only SQL-based drivers will report a non-empty FID column name.
Le 21/06/2021 à 17:04, Rahkonen Jukka (MML) a écrit :
Take this GeoJSON
"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?
gdal-dev mailing list
gdal-dev at lists.osgeo.org<mailto:gdal-dev at lists.osgeo.org>
My software is free, but my time generally not.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the gdal-dev