[gdal-dev] Recalculating spatial index with FileGDB driver

Even Rouault even.rouault at spatialys.com
Wed Aug 25 08:12:53 PDT 2021


Jon,

I believe this is a bug/feature of the (closed source) FileGDB SDK 
itself when it . Not sure we can do much about that. Or according to 
some mysterious parts of the documentation of the SDK perhaps we could 
offer to the user, as layer creation options, the possibility to specify 
the values of the 3 grid sizes used to compute the spatial index instead 
of letting the SDK guess it, but I'm not sure if this is really possible 
and if users could reasonably infer such values. I've tried to modify 
the driver to not disable bulk-loading in SetFeature() as the SDK doc 
suggested this might be possible, but this resulted in another error.

Even

Le 25/08/2021 à 16:29, Jon Morris a écrit :
>
> Hello all,
>
> I'm using GDAL 3.2.1 on Python 3.6.8 and am looking for more 
> information on FileGDB spatial indexes. I have a File GDB layer 
> containing some features and where the geometry is below a certain 
> size, I'm trying to replace it with a larger geometry. However, I'm 
> getting the error RuntimeError: Failed updating row (The spatial index 
> grid size is invalid.).
>
> I found this ticket https://github.com/Toblerity/Fiona/issues/388 
> <https://github.com/Toblerity/Fiona/issues/388> which suggests that 
> the spatial index is being calculated using the first feature added to 
> the layer, then when you add a much larger feature, it is not 
> compatible. Is it possible to recalculate the index using OGR? All the 
> results I have found suggest you need to use Esri tools to update the 
> spatial index.
>
> As a workaround, I can delete the layer and start again, or I can 
> write a large dummy feature to the layer first, but I wondered if 
> there was a better solution. There is a repro case below if anyone 
> wants to see the issue.
>
>     srs = osr.SpatialReference()
>
>     srs.ImportFromEPSG(27700)
>
>     drv = gdal.GetDriverByName('FileGDB')
>
>     temp_name = f"/tmp/{uuid.uuid4()}.gdb"
>
>     ds = drv.Create(temp_name, 0, 0, 0)
>
>     lyr = ds.CreateLayer('lyr1', srs=srs, geom_type=ogr.wkbPolygon)
>
>     ftr1 = ogr.Feature(lyr.GetLayerDefn())
>
>     geom1 = ogr.CreateGeometryFromWkt('POLYGON ((0 10000,10 10000,10 
> 10010,0 10010,0 10000))')
>
>     geom2 = ogr.CreateGeometryFromWkt('POLYGON ((-5000 7000,600000 
> 7000,600000 1200000,-5000 1200000,-5000 7000))')
>
>     ftr1.SetGeometry(geom1)
>
>     print(f'Add small feature (area = {geom1.Area()})')
>
>     lyr.CreateFeature(ftr1)
>
>     ftr1.SetGeometry(geom2)
>
>     print(f'Update feature (area = {geom2.Area()})')
>
>     lyr.SetFeature(ftr1)
>
> If you add a feature with the larger geom before doing the update, it 
> works fine. The error is only when you try and update the existing 
> small feature.
>
> Thanks,
>
> Jon
>
> *Jon Morris*
>
> *Software Developer*
>
> e: ​ 	*Jon.Morris at jbarisk.com* <mailto:Jon.Morris at jbarisk.com>
> t: 	*+44 (0)1756 799919* <tel:+44%20(0)1756%20799919>
>
> 	
>
> *www.jbarisk.com* <http://www.jbarisk.com/>
>
> Facebook <https://www.facebook.com/TheFloodPeople>
>
> 	
> LinkedIn <https://www.linkedin.com/company/jba-risk-management/>
>
> 	
> Twitter <https://twitter.com/JBARisk>
>
> 	
> YouTube <https://www.youtube.com/channel/UC0iatom2jYbW96voW0rlpCw>
>
> 	
>
> All JBA Risk Management's email messages contain confidential 
> information and are intended only for the individual(s) named. If you 
> are not the named addressee you should not disseminate, distribute or 
> copy this e-mail.
> Please notify the sender immediately by email if you have received 
> this email by mistake and delete this email from your system.
> JBA Risk Management Limited is registered in England, company number 
> 07732946, 1 Broughton Park, Old Lane North, Broughton, Skipton, North 
> Yorkshire, BD23 3FD, England.
>
>
> _______________________________________________
> 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.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20210825/a9f53a39/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image733132.png
Type: image/png
Size: 9886 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20210825/a9f53a39/attachment-0005.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image909374.png
Type: image/png
Size: 651 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20210825/a9f53a39/attachment-0006.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image836014.png
Type: image/png
Size: 715 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20210825/a9f53a39/attachment-0007.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image407826.png
Type: image/png
Size: 966 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20210825/a9f53a39/attachment-0008.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image616029.png
Type: image/png
Size: 784 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20210825/a9f53a39/attachment-0009.png>


More information about the gdal-dev mailing list