The GDAL vector driver for FlatGeobuf
format has the layer creation option SPATIAL_INDEX=[YES/NO]
. How can we check - with ogrinfo
or similar - whether a previously created layer has a spatial index?
1 Answer
I don't think it's possible with ogrinfo
but you can use the GDAL python API to check using osgeo.ogr.Layer.TestCapability
. The capability to test is OLCFastSpatialFilter
.
E.g.
from osgeo import ogr
ds = ogr.Open("has_index.fgb")
lyr = ds.GetLayer(0)
print(lyr.TestCapability(ogr.OLCFastSpatialFilter))
ds = ogr.Open("no_index.fgb")
lyr = ds.GetLayer(0)
print(lyr.TestCapability(ogr.OLCFastSpatialFilter))
Output:
True
False
-
1Perfect, thank you very much. This is exactly what I was looking for. Commented Dec 6 at 9:00