# Spatial reference extent limitations ?

1907
14
07-16-2018 06:40 PM
Occasional Contributor

I would like to get features spatial reference limitations of coordinate x and y  by using snippet like:

sr = arcpy.Describe('my feature').spatialReference

dom=sr.domain.split()
xmin=float(dom[0])
ymin=float(dom[1])
xmax=float(dom[2])
ymax=float(dom[3])

...

But it seems don't  work. For  a WGS84 GCS, the result is xmin=-180, xmax=180, ymin=-90 but ymax=270 rather than 90, and more strange result for a  WGS84 PCS. Does sr.domain is not proper for my needs?

1 Solution

Accepted Solutions
Esri Notable Contributor

It's pulling the spatial reference xy domain which is square. The lower left / minimum values are good, but the max values may be blown out to either make the extent square or to make the xy resolution value a reasonable number.

The -400 is to cover data that could be in -360 to 0 longitude range, with a very generous buffer added. We just used the same value for the minimum Y (latitude) value too.

``````-400 -400 1000000000;-100000 10000;-100000 10000;8.98315284119522E-09;\
0.001;0.001;IsHighPrecision"``````

These values are (in order):

minimum X, minimum Y, inverse of xy resolution;

minimum Z, inverse of Z resolution;

minimum M, inverse of M resolution;

XY tolerance;

Z tolerance;

M tolerance

True that the spatial reference is high precision versus the original "basic" precision.

The tolerance values are actually not good if the data is using a geographic coordinate system.

Wu Teshieng, you probably want the coordinate system's "projected horizon" but I don't think that's exposed in arcpy. Here's some of the methods in ArcObjects:

The PCS horizon but in latitude/longitude. It is not guaranteed to be an inclusive horizon (it might be exclusive to show which part of the world can't be 'seen' in the particular PCS).

14 Replies
MVP Legendary Contributor

Interestingly... if you run the code snippet for a gcs wgs84 from

You get some strange results.

Perhaps Melita Kennedy‌ can offer some insight

``````wkt = "GEOGCS['GCS_WGS_1984',DATUM['D_WGS_1984',SPHEROID
['WGS_1984',6378137.0,298.257223563]],\
PRIMEM['Greenwich',0.0],UNIT['Degree',0.0174532925199433]],\
VERTCS['WGS_1984',DATUM['D_WGS_1984',SPHEROID
['WGS_1984',6378137.0,298.257223563]],\
PARAMETER['Vertical_Shift',0.0],PARAMETER['Direction',1.0],UNIT
['Meter',1.0]];\
-400 -400 1000000000;-100000 10000;-100000 10000;8.98315284119522E-09;\
0.001;0.001;IsHighPrecision"

sr = arcpy.SpatialReference() sr.loadFromString(wkt)

r.domain

'-400 -400 9006799.25474099 9006799.25474099'‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍``````
MVP Esteemed Contributor

What is your objective?  Are you most concerned with the actual Spatial Reference of your data or are you concerned with extent of your data?

If the latter, consider the snippet of code below that returns the XMin/Max YMin/Max of a given feature class (fc):

``````fc = 'YourFeatureClass'
descFC = arcpy.Describe(fc)
fc_xmin = descFC.extent.XMin
fc_ymin = descFC.extent.YMin
fc_xmax = descFC.extent.XMax
fc_ymax = descFC.extent.YMax

print 'Extents of {}, {}, {}, {}, {}'.format(fc,fc_xmin,fc_ymin,fc_xmax,fc_ymax)

‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍``````
That should just about do it....
Occasional Contributor

Thanks for your responding Joe. My concern is  the largest extent limit of any coordinate system, GCS or PCS. The problem arise from a practical problem, that is, when a polygon feature is create using ArcPy, the limit extent of the coordinate system may be exceeded and  making  the feature invalid.

MVP Esteemed Contributor

I am dealing with a similar issue with respect to extents.  (See:  Spatial Extents ).  When I append source data to a (emtpy) target the the extents are sometimes  well out of bounds my area of interest.  Allegedly, the process of appending re-calculates the extent, and I've had that happen.  But, I still get feature classes that have an extent of USA and the Philippines when all the data should reside in one county, in one state of the US.

When you define an empty feature class with a given spatial reference, it is given the extents of 0,0,0,0.  Once you add features to the feature class, the extent is supposed to be that of the features themselves...

That should just about do it....
Occasional Contributor

Yes it's helpful. But in my situation, the spatial reference of the feature is unknown in advance, so I must have a method to get the limit extent and using that in my code to avoid the out of extent error.

MVP Esteemed Contributor

If you find it let me know! I would like to restrict my extents as well, and the only thing I can come up with is clip it once it has data in it.

That should just about do it....
MVP Legendary Contributor

You set the extents to a featureclass not the actual projection itself since a projection doesn't have the extent property as you have found out.

MVP Esteemed Contributor

Dan-  how do I set the extents using arcpy?

As mentioned in my other thread that you responded to:  We take data from the authoratative source and append to a 'public' enterprise geodatabse.  The source data can be wonky with respect to extents.  I'd love to control the append in such a way that just those features within a given xmin,  ymin,  xmax, ymax extent are appended...

That should just about do it....
MVP Legendary Contributor

I set extents explicitly, but I don't rely on reading a coordinate system at all (prj etc) or even a featureclass, unless I have to.

I simply know the bounds of where I am working, set it accordingly and check the geometry (a big point in polygon def) to ensure all is where it should be.

But!  you people are using that enterprise and sde thing.... my only suggestion is to create a big Area of Interest file (AOI) and simply do a select by attribute to see if your features intersect, (or whatever) with your AOI.