[gdal-dev] SQLite: create layer with wkbNone

Even Rouault even.rouault at spatialys.com
Wed Oct 30 05:02:19 PDT 2024


Martin,

Add the "-oo LIST_ALL_TABLES=YES" open option to your ogrinfo call: 
https://gdal.org/en/latest/drivers/vector/sqlite.html

(GPKG has a gpkg_contents table where non-spatial layers that are user 
facing are listed. There is no such thing in "pure" SQLite, and 
historically the driver has chosen to only list the ones registered in 
the geometry_columns table)

Even

Le 30/10/2024 à 12:46, Martin Landa via gdal-dev a écrit :
> Hi all,
>
> I have problem creating a new layer (no geometry) in SQLite data source:
>
> """
> from osgeo import ogr
>
> driver_name = "SQLite"
> filename = "test.db"
>
> driver = ogr.GetDriverByName(driver_name)
>
> with driver.CreateDataSource(filename) as ds:
>     layer = ds.CreateLayer("test", geom_type=ogr.wkbNone)
>     field = ogr.FieldDefn("label", ogr.OFTString)
>     layer.CreateField(field)
>
>     layer_defn = layer.GetLayerDefn()
>     feat = ogr.Feature(layer_defn)
>     feat.SetField("label", "test")
>     layer.CreateFeature(feat)
> """
>
> Created datasource doesn't contain any layer, no errors reported.
>
> When I switch to GPKG driver, everything works fine:
>
> ogrinfo  test.gpkg test
> ...
> OGRFeature(test):1
>   label (String) = test
>
> I have GDAL: 3.9.2, do you have any idea what is wrong?
>
> Thanks in advance for your help, best regards, Martin
>
> -- 
> Martin Landa
> https://geomatics.fsv.cvut.cz/en/employees/martin-landa/
> http://gismentors.cz/mentors/landa
>
> _______________________________________________
> 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.
Butcher of all kinds of standards, open or closed formats. At the end, this is just about bytes.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20241030/dad1dfe9/attachment.htm>


More information about the gdal-dev mailing list