qgis / QGIS

QGIS is a free, open source, cross platform (lin/win/mac) geographical information system (GIS)
https://qgis.org
GNU General Public License v2.0
10.57k stars 3k forks source link

Export of geopackage to File Geodatabase creates fid type real causing subsequent vector conversions to fail. #58690

Closed newcomb-d closed 1 month ago

newcomb-d commented 1 month ago

What is the bug or the crash?

When right clicking on a file geodatabase layer in the QGIS gui and selecting export, save features as with the export type as geopackage, the default field type for fid is real. If you attempt to export with this default, you get an error screen that says export to vector file failed, Error: Creation of filed fid failed ( OGR error: Wrong field type for fid). Workaround is to uncheck the fid attribute and let it be auto generated.

Steps to reproduce the issue

  1. Load an ESRI File geodatabase into QGIS
  2. Right click on the layer
  3. Select Export save features as
  4. Save vector dialog will pop up with fid type listed as Real
  5. Type in export geopackage name and click OK
  6. Error dialog pops up with message: export to vector file failed, Error: Creation of filed fid failed ( OGR error: Wrong field type for fid)

Versions

QGIS version 3.38.2-Grenoble

Supported QGIS version

New profile

Additional context

Workaround is to uncheck the fid attribute and let the fid be auto generated.

newcomb-d commented 1 month ago

Issue also seems to be present in QGIS 3.34.10-Prizren

newcomb-d commented 1 month ago

Does not seem to be a problem where no fid is already in file geodatabase

newcomb-d commented 1 month ago

OK, this problem is an artifact of previously converting a geopackage to a File Geodatabase. The fid filed created during that process is created as type real instead of Int64. When you try to reexport the file geodatabase to another format, then you get tripped up by the fid being type real

agiudiceandrea commented 1 month ago

@newcomb-d, thanks for reporting. Please update the report with your subsequent findings and with the full QGIS version info ("In the QGIS Help menu -> About, click in the table, Ctrl+A and then Ctrl+C. Finally paste here. Do not make a screenshot.").

It would be useful if you provided a sample layer with which the issue occurs following the provided steps. Please clarify if the issue occurs exporting a GPKG layer as an ESRI FileGoedatabe layer (as it seems from the report's title) or exporting an ESRI FileGeodatabase layer to a GPKG layer (as it seems from the report's description).

newcomb-d commented 1 month ago

Full version of QGIS description:

QGIS version | 3.34.10-Prizren | QGIS code revision | 113de9e1 -- | -- | -- | -- Qt version | 5.15.13 Python version | 3.12.5 GDAL/OGR version | 3.9.2 PROJ version | 9.4.0 EPSG Registry database version | v11.004 (2024-02-24) GEOS version | 3.12.2-CAPI-1.18.2 SQLite version | 3.45.1 PDAL version | 2.6.3 PostgreSQL client version | 16.2 SpatiaLite version | 5.1.0 QWT version | 6.2.0 QScintilla2 version | 2.14.1 OS version | Windows 11 Version 2009   |   |   |   Active Python plugins Cadastral_Divisions-main | 1.2 CalcArea | 1.3.0 DataPlotly | 4.1.0 dissect_dissolve_overlaps | 0.5 geocatbridge | 4.4.2 KP_find | 3.1.0 latlontools | 3.7.2 mmqgis | 2021.9.10 multi_filter | 1.0 Multi_Ring_Buffer | 1.1 OSMDownloader | 1.0.3 panorama_viewer | 1.0 pc_filter_slider | 1.0 plugin_exporter | 0.2.1 pointsamplingtool | 0.5.4 processing_r | 4.1.0 qfieldsync | v4.10.1 qgis-project-as-utm | 1.1 qgis_stac | 1.1.2 quick_map_services | 0.19.34 realearth-main | 0.8.2 scipy_filters | 1.4 shapetools | 3.5.1 slyr | 7.5.2 spatialdistributionpattern | 0.1 splitmultipart | 1.0.0 SplitPolygonShowingAreas | 0.13 stripchart | 1.0 Submission | 0.10 verificar_sobreposicao | 0.1 grassprovider | 2.12.99 otbprovider | 2.12.99 processing | 2.12.99 QGIS version 3.34.10-Prizren QGIS code revision [113de9e1](https://github.com/qgis/QGIS/commit/113de9e1) Qt version 5.15.13 Python version 3.12.5 GDAL/OGR version 3.9.2 PROJ version 9.4.0 EPSG Registry database version v11.004 (2024-02-24) GEOS version 3.12.2-CAPI-1.18.2 SQLite version 3.45.1 PDAL version 2.6.3 PostgreSQL client version 16.2 SpatiaLite version 5.1.0 QWT version 6.2.0 QScintilla2 version 2.14.1 OS version Windows 11 Version 2009 Active Python plugins Cadastral_Divisions-main 1.2 CalcArea 1.3.0 DataPlotly 4.1.0 dissect_dissolve_overlaps 0.5 geocatbridge 4.4.2 KP_find 3.1.0 latlontools 3.7.2 mmqgis 2021.9.10 multi_filter 1.0 Multi_Ring_Buffer 1.1 OSMDownloader 1.0.3 panorama_viewer 1.0 pc_filter_slider 1.0 plugin_exporter 0.2.1 pointsamplingtool 0.5.4 processing_r 4.1.0 qfieldsync v4.10.1 qgis-project-as-utm 1.1 qgis_stac 1.1.2 quick_map_services 0.19.34 realearth-main 0.8.2 scipy_filters 1.4 shapetools 3.5.1 slyr 7.5.2 spatialdistributionpattern 0.1 splitmultipart 1.0.0 SplitPolygonShowingAreas 0.13 stripchart 1.0 Submission 0.10 verificar_sobreposicao 0.1 grassprovider 2.12.99 otbprovider 2.12.99 processing 2.12.99
newcomb-d commented 1 month ago

A sample dataset that can be used to test is the Natural Earth https://naciscdn.org/naturalearth/packages/natural_earth_vector.gpkg.zip . Unzip and open the ne_10m_admin_antarctic_claims polygon layer . Right click on this layer and export as a File geodatabase. Right click on the layer and select properties. Select the Fields option. The new layer created has an fid of Type Decimal(double) and Type name Real.

newcomb-d commented 1 month ago

Just to clarify, the root cause of the issue is when the QGIS gui is used to export a geopackage to a File Geodatabase. It is at that point that the fid field is created/converted to type Real. The fid as Real is what was initially reported as the problem to export from File Geodatabase to geopackage.

agiudiceandrea commented 1 month ago

@newcomb-d, Integer64 generic fileds (other then the objectid field) is supported in ESRI File Geodatabase layers by ArcGIS Pro 3.2 and later. QGIS uses the GDAL/OGR library to export to ESRI File Geodatabase format and GDAL/OGR supports Integer64 generic fileds in the OpenFileGDB driver since version GDAL/OGR 3.9 provided that the TARGET_ARCGIS_VERSION=ARCGIS_PRO_3_2_OR_LATER option is set as a Layer Custom Option in the "Save Vector Layer as..." dialog window as specified in the GDAL/OGR library's docs at https://gdal.org/en/latest/drivers/vector/openfilegdb.html#layer-creation-options.

For reference: https://github.com/OSGeo/gdal/pull/8866,

@rouault, wouldn't it be useful to expose the TARGET_ARCGIS_VERSION layer creation option in the Save Vector Layer as... dialog window if QGIS uses GDAL/OGR >= 3.9? (It would also be useful to have a "Consult .... driver help page for detailed explanations on options" like for importing layers)