RuntimeError: Spatial index grid is too small

1295
9
05-25-2018 01:58 PM
MatthewSanders1
Occasional Contributor

When adding features to a feature class using arcpy, two of my features (same class) give me the error in the title.

Everything I've read says to use ArcCatalog to delete the spatial index for the feature class, but before I do that I want to make sure that is safe to do. The database I am working with is a Microsoft SQL Server database and uses some form of compressed binary to store the geography. Apparently, the way it is set up means I have to delete the spatial index rather than recalculate (which would seem safer than deleting!)

If I delete the spatial index and re-create it, is there anything that may become broken? Is there any harm in doing this?

EDIT:

This is the ESRI article in question

EDIT2:

Also, if I do delete and recreate a spatial index, how do I know my existing index parameters (as referenced in link above) and the new ones I should use?

0 Kudos
9 Replies
DanPatterson_Retired
MVP Emeritus

The example they give is more interesting than the workaround.  The root seems to be an issue with differences in projections/coordinate systems.  Perhaps a projection to the required coordinate system may remove the error

MatthewSanders1
Occasional Contributor

Thanks for the reply! That seems like a good place to start looking. I am still new to arcpy/GIS in general and don't know much about working with spatial references.

I'm reading coordinates from one GIS(ish) system that uses Web Mercator (EPSG:3857), using those coordinate pairs to create points (arcpy.Point(latitude, longitude)), creating an array of those Points, then using that array to create a Polyline (arcpy.Polyline), and then using arcpy.da.InsertCursor to insert the polyline into the ArcGIS database. I read somewhere that in order to do high precision geometry, the polyline needs a spatial reference, so I've been using a blank one: 

   poly = arcpy.Polyline(point_array, arcpy.SpatialReference())

which has worked every time so far.

The ArcGIS feature class uses GCS_WGS_1984. Should I be specifying anywhere that I am using coordinates from 3857? How should I go about doing this?

Thanks for your help!

0 Kudos
DanPatterson_Retired
MVP Emeritus

If your points are in decimal degrees

arcpy.Point(latitude, longitude) is wrong

arcpy.Point(longitude, latitude) is right

and they could be defined as a GCS_WGS_1984.  Which is way better than not defining the coordinate system.

Sadly web-stuff uses that web-Mercator which mean that you had better make sure that if you are getting numbers not in the range -180 to 180 for longitude then they may be in web Mercator and you should define the coordinates as such.

MatthewSanders1
Occasional Contributor

Thanks for the correction. I was doing arcpy.Point(longitude, latitude) correctly, I just misspoke.

I just tried using web-Mercator as the spatial reference and the error went away. I am now doing

arcpy.Polyline(point_array, arcpy.SpatialReference(3857))

Does that seem like the correct solution?

0 Kudos
DanPatterson_Retired
MVP Emeritus

3857 is web Mercator not decimal degrees.. you would need big numbers to define the coordinate system as such

4326 is GCS WGS-84 http://spatialreference.org/ref/epsg/wgs-84/  Note that the bounds are in decimal degrees.

So in short... you have to define them as 'what they are' and not 'what you want them to be'

If your coordinates are in decimal degrees, then define them with wgs84, then use the Project tool

http://pro.arcgis.com/en/pro-app/tool-reference/data-management/project.htm

or its python/arcpy interface

MatthewSanders1
Occasional Contributor

Turns out you're right! I have some crazy looking lines now. So if I have decimal degrees (40.64577832, -68.655557412) I should use 4326 as my spatial reference?

0 Kudos
DanPatterson_Retired
MVP Emeritus

Most likely ... a Geographic Coordinate system  aka  GCS WGS-1984 aka  Longitude/latitude

PS... quit messing with coordinates...

Think X and Y as in a graph  (-68.655557412, 40.64577832) Long/lat for the northern hemisphere North America)

where is this?  (40.64577832, -68.655557412)  

MatthewSanders1
Occasional Contributor

I made up those coordinates to look similar to the ones I am working with.

So I changed the spatial reference to 4326 as suggested. Now I'm getting the same 'Spatial index grid is too small' error I was getting before. Any thoughts?

Edit: its worth noting that I am only getting the error on certain rows. Most of them work just fine and have for every test I've run in the last few months.

0 Kudos
DanPatterson_Retired
MVP Emeritus

you would have to show the rows.

I would create a new geodatabase and put the file in there, so you have a clean slate from which to work.

Remember Longitude then Latitude 

Longitude -180 to +180 degrees

Latitude 90 to -90 degrees

If you are putting stuff in switched, they are not of this earth except for a limited range