2

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 1

3

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
1
  • 1
    Perfect, thank you very much. This is exactly what I was looking for.
    – christoph
    Commented Dec 6 at 9:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.