Original thread located here: Get smallest extent from a list of rasters
I had issues with that method, if some extents do not overlap, arcgis extent is "empty" while the above minof is (always?) still a rectangle!
In the docs it is said thats minof is the intersection of inputs. But that seems not to be a Intersect_analyst-equivalent. I tried with three extent objects, two do not overlap and one overlaps all other.
Message was edited by: Xander Bakker (branched to new thread)
Solved! Go to Solution.
... or one can use the polygon property of the extent and use the intersect method of the polygon like this:
import arcpy ext1 = arcpy.Extent(1, 1, 4, 4) ext2 = arcpy.Extent(2, 2, 5, 5) print ext1.polygon.intersect(ext2.polygon, 4).extent
which returns:
2,00000190734863 2,00000190734863 4,00000190734863 4,00000190734863 NaN NaN NaN NaN
It will return:
1,#QNAN 1,#QNAN 1,#QNAN 1,#QNAN NaN NaN NaN NaN
... when there is no intersecting polygon.
Xander... and to add... make sure there is a defined coordinate system or the extent values will be returned in single precision rather than double as evidenced by your examples.
This looks really good, thought about something like this, but had no success. Do you think it is "enough", testing the overlaps in a single for-loop? If I understand the code right, you take the first extent and compare to it to the remaining. For example if the first extent in list overlaps all others, but the second does not overlaps the third. Could we somehow "sort" the polygons or should we use a nested for-loop to check every combination. I tend to look inside an open source product to find a similar operation...
I tried out a few example extents: It works, order seems not to be important.
So, thank you very, very much for contributing your code!
Could you mark the post that answered your question as the correct answer? This way other members will be able to find the answer to similar question more easy. Thank you!
To explain a bit what the loop pretends to do:
There is no need to validate overlaps (intersects) between all extents. If in some situation there is no intersect, it will abort the loop and return None (which you should check for).
So true, that's why you store the return of getOverlapExtents in ext, oversawed this... clever!
you should then mark Xander's correct ... assumed answered ... is usually used by moderators, not by people who post questions
I tried before, the only option I had was "richtige Antwort" (correct answer) and then it gets "assumed answered"...
you fixed it...