[gdal-dev] Error when trying to create layer in FileGDB

Even Rouault even.rouault at spatialys.com
Wed Jul 17 01:51:12 PDT 2019


Casper,

I can reproduce. I tried a few things (including adding at hand definitions 
for MOrigin, MScale, MPrecision and LatestWKID that appear in the XML 
definition of the existing layer & feature dataset), but without success. It 
appears this is specific to creating the layer with FEATURE_DATASET=Data. 
Without that, it works. And there must be something specific to the SRS of the 
Data FeatureDataset too, because we have a test in the autotest suite that 
works:

    srs = osr.SpatialReference()
    srs.SetFromUserInput("WGS84")

    ds = ogrtest.fgdb_drv.CreateDataSource('tmp/test.gdb')
    ds.CreateLayer('layer1', srs=srs, geom_type=ogr.wkbPoint, 
options=['FEATURE_DATASET=featuredataset'])
    ds.CreateLayer('layer2', srs=srs, geom_type=ogr.wkbPoint, 
options=['FEATURE_DATASET=featuredataset'])
    ds = None

The joys of working with closed source software...

Even

> Hi all,
> 
> I am trying to create a layer in an existing feature dataset in an existing
> File Geodatabase (FileGDB, not Open) using python and GDAL/OGR from OSGeo.
> 
> The layout of the FileGDB is:
> 
> MyData.gdb
>      Data
>           Polygon
> 
> The following is my code attempt:
> >>> from osgeo import ogr
> >>> ds = ogr.Open('MyData.gdb', 1)
> >>> l = ds.CreateLayer('Line', None, ogr.wkbLineString,
> >>> options=['FEATURE_DATASET=Data'])
> ERROR 1: Failed at creating table for \Data\Line (Invalid spatial
> reference.)
> Yes I didn't provide a spatial reference, but if None is invalid I might as 
well pick one used by an existing layer inside the feature dataset:
> >>> l2 = ds.GetLayerByIndex(0)
> >>> p2 = l2.GetSpatialRef()
> >>> l2.GetName()
> 
> 'Polygon'
> 
> >>> l = ds.CreateLayer('Line', p2, ogr.wkbLineString,
> >>> options=['FEATURE_DATASET=Data'])
> ERROR 1: Failed at creating table for \Data\Line (Invalid spatial
> reference.)
> 
> In both cases I get the same error, is this to be expected?
> 
> Regards, Casper


-- 
Spatialys - Geospatial professional services
http://www.spatialys.com


More information about the gdal-dev mailing list