Extent check using Python Script

4556
9
08-27-2014 11:01 PM
MANESK
by
Occasional Contributor

I have two feature class... I ve to check whether Feature class 1 falls within the extent of the Feature Class2...

Is there any tool or procedure to check it using python script...

0 Kudos
9 Replies
DanPatterson_Retired
MVP Emeritus

There is no tool to check the whole feature classes at once, but you could determine the Minimum Bounding Geometry for each file, then get their extents and compare.  you will have to decide which type of geometry is best suited for your purposes (maybe a convex hull).  This is one quick way

0 Kudos
MANESK
by
Occasional Contributor

Thanks Dan.. I ve to report whether FC 1 falls within FC 2..  FC2 has a larger spatial extent.... The job is to check N no of FCs falls within the extent...We just want to automate the process... Kindly suggest..

0 Kudos
DanPatterson_Retired
MVP Emeritus

The rest would have to be scripted, which I presume, you were hoping for a ready made one and not advise on procedure.

0 Kudos
IanMurray
Frequent Contributor

If you write a script that adds both fc to a map document, you can use the arcpy.mapping module, you can return an layers extent with the layer.getExtent method.  You might have to get a bit creative to determine a method for determining if one contains the other, but it should be possible.

DarrenWiens2
MVP Honored Contributor

It depends on your definition of "extent".

If you mean the encompassing rectangle around the entire feature class, you can Describe the Dataset to get the extent (see the example here).

If you just want the overlapping features, use Intersect.

JoshuaBixby
MVP Esteemed Contributor

To follow-up on what Darren Wiens​ suggests, the Extent object (obtained through the Describe object) got support for JSON and polygon properties at ArcGIS 10.3 (What's new in ArcGIS 10.3).  Having the Extent object support polygon properties greatly eases working with them in situations like this one.

A couple of comments/thoughts:

  • Extent objects work with Minimum Bounding Rectangles (MBRs), a.k.a. "bounding box."  In comparing MBRs of two datasets, it is completely possible that one dataset or MBR of a dataset will fall within the MBR of another dataset while none of the features from either dataset intersect.
  • With the Esri Extent object, and particularly with SDE datasets, I haven't tested whether the Extent object pulls information from existing statistics on a dataset or whether the extent is newly computed when the object is created.  If the former, it could be possible the MBR returned isn't accurate if the statistics are stale on a dataset.  I can't say one way or another.  If it is important enough, I suggest you verify the behavior before relying on it.
DanPatterson_Retired
MVP Emeritus

just to be careful, the Extent object usually defines the box/rectangle with axes parallel to the X and Y axes (talking 2D Euclidean space here).  Minimum Bounding Rectangles (MBR) should be viewed in this context since the mathematically more interesting ones are the Minimum Area Bounding Rectangle (MABR) or perhaps the Minimum Perimeter Bounding Rectangle (MPBR).  There is no guarantee, that  MBR will equal MABR or MPBR.  So the often missing 2nd word can be important as Darren is alluding to

0 Kudos
JoshuaBixby
MVP Esteemed Contributor

Interesting point.  Not surprisingly, the documentation for the Extent object isn't very specific.  Does the Extent object always return the minimum axis-aligned bounding rectangle or does/can it return a different minimum bounding rectangle in certain situations?

0 Kudos
DanPatterson_Retired
MVP Emeritus

I can't remember, I use my Bounding Containers for version 10.2.x, it works in 10.3 but I haven't posted the NumPy-ed version on ArcScript 2.0 Beta yet...sometime soon if it gets upgraded from Beta before the UC.  It does Extent rectangles (your MBR), MABR, Minimum area Circle, convex hull of course and I have code not included for MPBR (not hard to alter MABR) and W.H. and I worked on MABE (min area bounding ellipse) but not posted.  Will tidy it up with variants of Concave Hulls/Alpha Shapes plus some other esoteric containers of which there are many.

0 Kudos