<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<p>Jon,</p>
<p>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.<br>
</p>
<p>Even<br>
</p>
<div class="moz-cite-prefix">Le 25/08/2021 à 16:29, Jon Morris a
écrit :<br>
</div>
<blockquote type="cite"
cite="mid:LO2P123MB4861EE05BDEEEE786B87687882C69@LO2P123MB4861.GBRP123.PROD.OUTLOOK.COM">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="Generator" content="Microsoft Word 15 (filtered
medium)">
<style>@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
font-size:11.0pt;
font-family:"Calibri",sans-serif;
mso-fareast-language:EN-US;}a:link, span.MsoHyperlink
{mso-style-priority:99;
color:#0563C1;
text-decoration:underline;}span.EmailStyle17
{mso-style-type:personal-compose;
font-family:"Arial",sans-serif;
color:black;
font-weight:normal;
font-style:normal;
text-decoration:none none;}.MsoChpDefault
{mso-style-type:export-only;
font-family:"Calibri",sans-serif;
mso-fareast-language:EN-US;}div.WordSection1
{page:WordSection1;}</style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
<div class="WordSection1">
<p class="MsoNormal"><span
style="font-family:"Arial",sans-serif;color:black">Hello
all,<o:p></o:p></span></p>
<p class="MsoNormal"><span
style="font-family:"Arial",sans-serif;color:black"><o:p> </o:p></span></p>
<p class="MsoNormal"><span
style="font-family:"Arial",sans-serif;color:black">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
</span><span style="font-family:"Courier
New";color:black">RuntimeError: Failed updating row
(The spatial index grid size is invalid.)</span><span
style="font-family:"Arial",sans-serif;color:black">.<o:p></o:p></span></p>
<p class="MsoNormal"><span
style="font-family:"Arial",sans-serif;color:black"><o:p> </o:p></span></p>
<p class="MsoNormal"><span
style="font-family:"Arial",sans-serif;color:black">I
found this ticket
<a href="https://github.com/Toblerity/Fiona/issues/388"
moz-do-not-send="true">https://github.com/Toblerity/Fiona/issues/388</a>
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.<o:p></o:p></span></p>
<p class="MsoNormal"><span
style="font-family:"Arial",sans-serif;color:black"><o:p> </o:p></span></p>
<p class="MsoNormal"><span
style="font-family:"Arial",sans-serif;color:black">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.<o:p></o:p></span></p>
<p class="MsoNormal"><span
style="font-family:"Arial",sans-serif;color:black"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier
New";color:black"> srs = osr.SpatialReference()<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier
New";color:black"> srs.ImportFromEPSG(27700)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier
New";color:black"> drv =
gdal.GetDriverByName('FileGDB')<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier
New";color:black"> temp_name =
f"/tmp/{uuid.uuid4()}.gdb"<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier
New";color:black"> ds = drv.Create(temp_name, 0, 0,
0)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier
New";color:black"> lyr = ds.CreateLayer('lyr1',
srs=srs, geom_type=ogr.wkbPolygon)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier
New";color:black"> ftr1 =
ogr.Feature(lyr.GetLayerDefn())<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier
New";color:black"> geom1 =
ogr.CreateGeometryFromWkt('POLYGON ((0 10000,10 10000,10
10010,0 10010,0 10000))')<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier
New";color:black"> geom2 =
ogr.CreateGeometryFromWkt('POLYGON ((-5000 7000,600000
7000,600000 1200000,-5000 1200000,-5000 7000))')<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier
New";color:black"> ftr1.SetGeometry(geom1)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier
New";color:black"> print(f'Add small feature (area =
{geom1.Area()})')<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier
New";color:black"> lyr.CreateFeature(ftr1)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier
New";color:black"> ftr1.SetGeometry(geom2)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier
New";color:black"> print(f'Update feature (area =
{geom2.Area()})')<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier
New";color:black"> lyr.SetFeature(ftr1)<o:p></o:p></span></p>
<p class="MsoNormal"><span
style="font-family:"Arial",sans-serif;color:black"><o:p> </o:p></span></p>
<p class="MsoNormal"><span
style="font-family:"Arial",sans-serif;color:black">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.<o:p></o:p></span></p>
<p class="MsoNormal"><span
style="font-family:"Arial",sans-serif;color:black"><o:p> </o:p></span></p>
<p class="MsoNormal"><span
style="font-family:"Arial",sans-serif;color:black">Thanks,<o:p></o:p></span></p>
<p class="MsoNormal"><span
style="font-family:"Arial",sans-serif;color:black"><o:p> </o:p></span></p>
<p class="MsoNormal"><span
style="font-family:"Arial",sans-serif;color:black">Jon<o:p></o:p></span></p>
<p class="MsoNormal"><span
style="font-family:"Arial",sans-serif;color:black"><o:p> </o:p></span></p>
<p class="MsoNormal"><b><span
style="font-family:"Arial",sans-serif;color:#F6A124;mso-fareast-language:EN-GB">Jon
Morris<o:p></o:p></span></b></p>
<p class="MsoNormal"><b><span
style="font-family:"Arial",sans-serif;color:#4A4A49;mso-fareast-language:EN-GB">Software
Developer<o:p></o:p></span></b></p>
<p class="MsoNormal"><span
style="font-family:"Arial",sans-serif;color:black;mso-fareast-language:EN-GB"><o:p> </o:p></span></p>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div dir="ltr"
style="mso-line-height-rule:exactly;-webkit-text-size-adjust:100%;direction:ltr;">
<table style="width:100%;" cellspacing="0" cellpadding="0"
border="0">
<tbody>
<tr style="font-size:0;">
<td style="vertical-align:top;" align="left">
<table style="font-size:0;" cellspacing="0"
cellpadding="0" border="0">
<tbody>
<tr style="font-size:0;">
<td style="padding:10px 0 0;vertical-align:top;"
align="left">
<table
style="font-size:0;color:#4A4A49;font-style:normal;font-weight:700;white-space:nowrap;"
cellspacing="0" cellpadding="0" border="0">
<tbody>
<tr style="font-size:14.67px;">
<td
style="padding:0;vertical-align:top;font-family:Arial;"
align="left">e: <span
style="font-family:remialcxesans;font-size:1px;color:#FFFFFF;line-height:1px;"></span></td>
<td style="padding:0 0 0
4px;vertical-align:top;color:#F6A124;font-family:Arial;font-weight:400;"
align="left"><a
href="mailto:Jon.Morris@jbarisk.com"
target="_blank" id="LPlnk689713"
style="text-decoration:none;color:#F6A124;"
moz-do-not-send="true"><strong
style="font-weight:400;">Jon.Morris@jbarisk.com</strong></a></td>
</tr>
<tr style="font-size:14.67px;">
<td
style="padding:0;vertical-align:top;font-family:Arial;"
align="left">t: </td>
<td style="padding:0 0 0
4px;vertical-align:top;color:#F6A124;font-family:Arial;font-weight:400;"
align="left"><a
href="tel:+44%20(0)1756%20799919"
target="_blank" id="LPlnk689713"
style="text-decoration:none;color:#F6A124;"
moz-do-not-send="true"><strong
style="font-weight:400;">+44 (0)1756 799919</strong></a></td>
</tr>
<tr style="font-size:0;">
<td style="padding:0;vertical-align:top;"
align="left"><br>
</td>
<td style="padding:0 0 0
4px;vertical-align:top;" align="left"><br>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr
style="color:#000001;font-size:14.67px;font-style:normal;font-weight:400;white-space:nowrap;">
<td style="vertical-align:top;font-family:Arial;"
align="left"><a href="http://www.jbarisk.com/"
target="_blank" id="LPlnk689713" title="Click to visit
our website"
style="text-decoration:none;color:#F6A124;"
moz-do-not-send="true"><strong
style="font-weight:400;">www.jbarisk.com</strong></a></td>
</tr>
<tr style="font-size:0;">
<td style="vertical-align:top;" align="left">
<table style="font-size:0;" cellspacing="0"
cellpadding="0" border="0">
<tbody>
<tr style="font-size:0;">
<td style="padding:10px 0 0;vertical-align:top;"
align="left">
<table style="font-size:0;" cellspacing="0"
cellpadding="0" border="0">
<tbody>
<tr style="font-size:0;">
<td rowspan="3" style="padding:0 0
5px;vertical-align:top;" align="left">
<table style="width:100%;font-size:0;"
cellspacing="0" cellpadding="0"
border="0">
<tbody>
<tr style="font-size:0;">
<td style="vertical-align:top;"
align="left">
<table
style="font-size:0;line-height:normal;"
cellspacing="0"
cellpadding="0" border="0">
<tbody>
<tr style="font-size:0;">
<td style="padding:10px 0
15px;vertical-align:top;" align="left"><img
src="cid:part5.44A96C1A.0052F3AE@spatialys.com"
alt=""
style="height:52px;min-height:52px;max-height:52px;font-size:0;"
class="" height="52"
border="0"></td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr style="font-size:0;">
<td style="vertical-align:top;"
align="left">
<table style="font-size:0;"
cellspacing="0"
cellpadding="0" border="0">
<tbody>
<tr style="font-size:0;">
<td style="padding:0 0
12px;vertical-align:top;"
align="left">
<table
style="height:30px;font-size:0;"
cellspacing="0"
cellpadding="0"
border="0">
<tbody>
<tr
style="font-size:0;">
<td
style="vertical-align:top;"
align="left">
<table
style="font-size:0;line-height:normal;"
cellspacing="0" cellpadding="0" border="0">
<tbody>
<tr
style="font-size:0;">
<td
style="padding:0
4px 5px
0;vertical-align:top;"
align="left"><a
href="https://www.facebook.com/TheFloodPeople" target="_blank"
id="LPlnk689713"
style="text-decoration:none;" moz-do-not-send="true"><img
src="cid:part6.092C4541.BB4C4800@spatialys.com"
title="Facebook" alt="Facebook"
style="width:34px;min-width:34px;max-width:34px;font-size:12px;"
class=""
width="34"
border="0"></a></td>
</tr>
</tbody>
</table>
</td>
<td
style="vertical-align:top;"
align="left">
<table
style="font-size:0;line-height:normal;"
cellspacing="0" cellpadding="0" border="0">
<tbody>
<tr
style="font-size:0;">
<td
style="padding:0
4px 5px
0;vertical-align:top;"
align="left"><a
href="https://www.linkedin.com/company/jba-risk-management/"
target="_blank"
id="LPlnk689713" style="text-decoration:none;" moz-do-not-send="true"><img
src="cid:part8.AB6AB991.64D8FBF6@spatialys.com" title="LinkedIn"
alt="LinkedIn"
style="width:34px;min-width:34px;max-width:34px;font-size:12px;"
class=""
width="34"
border="0"></a></td>
</tr>
</tbody>
</table>
</td>
<td
style="vertical-align:top;"
align="left">
<table
style="font-size:0;line-height:normal;"
cellspacing="0" cellpadding="0" border="0">
<tbody>
<tr
style="font-size:0;">
<td
style="padding:0
4px 5px
0;vertical-align:top;"
align="left"><a
href="https://twitter.com/JBARisk" target="_blank" id="LPlnk689713"
style="text-decoration:none;"
moz-do-not-send="true"><img
src="cid:part10.BC748512.A6631894@spatialys.com"
title="Twitter" alt="Twitter"
style="width:34px;min-width:34px;max-width:34px;font-size:12px;"
class=""
width="34"
border="0"></a></td>
</tr>
</tbody>
</table>
</td>
<td
style="vertical-align:top;"
align="left">
<table
style="font-size:0;line-height:normal;"
cellspacing="0" cellpadding="0" border="0">
<tbody>
<tr
style="font-size:0;">
<td
style="padding:0
4px 5px
0;vertical-align:top;"
align="left"><a
href="https://www.youtube.com/channel/UC0iatom2jYbW96voW0rlpCw"
target="_blank"
id="LPlnk689713" style="text-decoration:none;" moz-do-not-send="true"><img
src="cid:part12.488386AC.8D51E443@spatialys.com" title="YouTube"
alt="YouTube"
style="width:34px;min-width:34px;max-width:34px;font-size:12px;"
class=""
width="34"
border="0"></a></td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</td>
<td style="padding:0;"> </td>
</tr>
<tr style="font-size:0;">
<td style="padding:0;"> </td>
</tr>
<tr style="font-size:0;">
<td style="padding:0;"> </td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr style="font-size:0;">
<td style="vertical-align:top;" align="left">
<table style="font-size:0;" cellspacing="0"
cellpadding="0" border="0">
<tbody>
<tr style="font-size:0;">
<td style="padding:7px 0 5px;border-top:solid 1px
#4A4A49;border-right:none;border-bottom:none;border-left:none;vertical-align:top;"
align="left">
<table
style="white-space:normal;color:#444444;font-size:14.67px;font-family:Calibri,Arial,sans-serif;font-weight:400;font-style:normal;text-align:left;line-height:12px;"
cellspacing="0" cellpadding="0" border="0">
<tbody>
<tr style="font-size:9px;">
<td style="font-family:Arial;"><span
style="background-color:#FFFFFF;">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.</span><br>
<span style="background-color:#FFFFFF;">Please
notify the sender immediately by email
if you have received this email by
mistake and delete this email from
your system.</span> <br>
<span style="background-color:#FFFFFF;">JBA
Risk Management Limited is registered
in England, company number 07732946, 1
Broughton Park, Old Lane North,
Broughton, Skipton, North Yorkshire,
BD23 3FD, England</span><span
style="color:#000001;">.</span><br>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<pre class="moz-quote-pre" wrap="">_______________________________________________
gdal-dev mailing list
<a class="moz-txt-link-abbreviated" href="mailto:gdal-dev@lists.osgeo.org">gdal-dev@lists.osgeo.org</a>
<a class="moz-txt-link-freetext" href="https://lists.osgeo.org/mailman/listinfo/gdal-dev">https://lists.osgeo.org/mailman/listinfo/gdal-dev</a>
</pre>
</blockquote>
<pre class="moz-signature" cols="72">--
<a class="moz-txt-link-freetext" href="http://www.spatialys.com">http://www.spatialys.com</a>
My software is free, but my time generally not.</pre>
</body>
</html>