[gdal-dev] Converting fid from GeoJSON into GeoPackage

Even Rouault even.rouault at spatialys.com
Mon Jun 21 08:08:30 PDT 2021


Jukka,

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.

Even

Le 21/06/2021 à 17:04, Rahkonen Jukka (MML) a écrit :
>
> Hi,
>
> Take this GeoJSON
>
> {
>
> "type": "FeatureCollection",
>
> "features": [{
>
> "type": "Feature",
>
> "id":12425552,
>
> "properties":
>
> {
>
> },
>
> "geometry": {
>
> "type": "Point",
>
> "coordinates": [26.30578223, 60.26170791]
>
> }
>
> }]
>
> }
>
> Ogrinfo knows the fid
>
> OGRFeature(one_feature):12425552
>
> Convert into a new GeoPackage and the native fid is lost
>
> ogr2ogr -f gpkg one_feature.gpkg one_feature.json
>
> OGRFeature(one_feature):1
>
> Running the command with “-preserve_fid” keeps the native fid but 
> according to ogr2ogr documentation 
> https://gdal.org/programs/ogr2ogr.html 
> <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-
>
>
> _______________________________________________
> gdal-dev mailing list
> gdal-dev at lists.osgeo.org
> https://lists.osgeo.org/mailman/listinfo/gdal-dev

-- 
http://www.spatialys.com
My software is free, but my time generally not.

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


More information about the gdal-dev mailing list