Ensure hasSpatialIndex method on Describe object report correctly when data is compressed

901
2
07-24-2022 03:48 PM
Status: Closed
DuncanHornby
MVP Notable Contributor

So here is a screen shot of the properties of a dataset note it is UNCOMPRESSED and has a SPATIAL INDEX

DuncanHornby_2-1658702483793.png

DuncanHornby_3-1658702506383.png

 

When I run the following code in the Python console in ArcPro 3.0 I get the expected results

desc = arcpy.Describe('centerline_reprojected')
desc.hasSpatialIndex
True

 

Now... I run the compress file geodatabase tool to compress the dataset, and to prove I did this here are the properties

DuncanHornby_4-1658702681840.png

Now if I run the same bit of code I get False

desc.hasSpatialIndex
False

 

Finally if I un-compressed the data it clearly states in the properties that the spatial index exists.

It would good if this method reports the presence of the index correctly. If there is some technical reason why this can't be done the Help file needs updating to explain that it won't report the existence of a spatial index.

2 Comments
HannesZiegler
Status changed to: Closed

Hi Duncan, thank you for your post.

This one is in a bit of a grey area tilting towards reporting a potential bug rather than idea, so it seems Technical Support would be the better avenue for this one. However, we took a look at your concern and confirmed this is not a bug and is working as expected.

When the database is compressed, hasSpatialIndex should return False (as it does). You can also see this on the layer properties dialog.

Here's where it gets confusing: When compressed, the compressed spatial element is indexed, but in a different way, meaning that there is no spatial index on the shape column as you would expect with an uncompressed dataset. This is why hasSpatialIndex returns False as it is looking for a spatial index on the shape column. However, A grid value is maintained through the compress / uncompress process which seeds the regeneration of the original spatial index on the field, yielding "the same" spatial index it had before.  

Documentation was updated to add a note for hasSpatialIndex - Compressed datasets do not have a spatial index on the shape column and will return False. Note that you won't be able to see this update until the ArcGIS Pro 3.1 release. 

Thanks again

 

DuncanHornby

Hannes,

Thanks for the update and your solution to document this behaviour is welcomed.

Duncan