OSGeo / gdal

GDAL is an open source MIT licensed translator library for raster and vector geospatial data formats.
https://gdal.org
Other
4.79k stars 2.51k forks source link

ogr2ogr OpenFileGDB writer, postgis source - ERROR 6: Unsupported geometry type #6124

Closed smnorris closed 2 years ago

smnorris commented 2 years ago

Expected behavior and actual behavior.

Using OpenFileGDB writer with PostGIS reader fails to create output layer with ERROR 6: Unsupported geometry type Using a GPKG as the source seems to produce the same error.

Steps to reproduce the problem.

$ docker run --rm -v /Users:/Users osgeo/gdal:ubuntu-small-latest ogr2ogr \
  -f OpenFileGDB \
  $PWD/pg2gdb.gdb \
  PG:postgresql://postgres@host.docker.internal:5432/mydb \
  -nln test \
  -sql 'select 1 as id, ST_SetSRID(ST_MakePoint(-71.1, 42.3), 4326) as geom'
ERROR 6: Unsupported geometry type
ERROR 1: Terminating translation prematurely after failed
translation from sql statement.

Writing to .gdb from shapefile works fine:

$ docker run --rm -v /Users:/Users osgeo/gdal:ubuntu-small-latest ogr2ogr \
-f OpenFileGDB \
$PWD/shp2gdb.gdb \
$PWD/test.shp

Operating system

MacOS 12.5

GDAL version and provenance

$ docker pull osgeo/gdal:ubuntu-small-latest
$ docker run --rm -v /Users:/Users osgeo/gdal:ubuntu-small-latest ogrinfo --version
GDAL 3.6.0dev-125fafc0ea22262a8c80d86d6b81a3683ee857a5, released 2022/06/25

Docker is 4.10.1 (82475)

Postgis is 3.21.

select postgis_full_version();
                                                                                                                      postgis_full_version
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 POSTGIS="3.2.1 5fae8e5" [EXTENSION] PGSQL="140" GEOS="3.11.0-CAPI-1.17.0" PROJ="9.0.1" GDAL="GDAL 3.5.0, released 2022/05/10" LIBXML="2.9.14" LIBJSON="0.16" LIBPROTOBUF="1.4.0" WAGYU="0.5.0 (Internal)" (core procs from "3.1.4 ded6c34" need upgrade) RASTER
(1 row)
jratike80 commented 2 years ago

Maybe you should tell the geometry type of the layer with -nlt. The SQL in this case creates a point but you can as well create any kind of geometry with altered SQL, or some kind of SQL (for example ST_Intersection) can return mixed geometry types.

smnorris commented 2 years ago

Of course, thanks. That works great and if I remember correctly the ESRI FGDB driver generally requires -nlt as well.