2

I'm now facing a problem using Disjoint in Arcpy to check if 2 extents are intersected.

I have 2 extents like this:

  • Ext1: 33206887.500051 5890587.49999999 33460887.500051 6060887.49999999 NaN NaN NaN NaN
  • Ext2: 33346031.7877 5892265.95 33395320.8209 5927481.3861 NaN NaN NaN NaN

According to my shape and raster, the shape with Ext2 is completely inside the raster with Ext1.

But unfortunately, using

Ext1.disjoint(Ext2)

leads to the "True"-result, which indicates that the 2 extents share no common intersection.

It drives me really crazy.

1

Extents need to be in the same projection for disjoint to work.

Here I have an mxd with two data frames. Each data frame has the same extent but two different projections. In this case disjoint returns True:

>>> mxd = arcpy.mapping.MapDocument ("CURRENT")
>>> dfs = arcpy.mapping.ListDataFrames (mxd)
>>> df1 = dfs [0]
>>> df2 = dfs [1]
>>> ex1 = df1.extent
>>> ex2 = df2.extent
>>> ex1.disjoint (ex2)
True

I project my second extent into the same projection as my first and disjoint returns False:

>>> sr = ex1.spatialReference
>>> ex2proj = ex2.projectAs (sr)
>>> ex1.disjoint (ex2proj)
False
>>> 

enter image description here

  • It seems to be really the problem! Thank you so much! – PDUY Feb 12 at 16:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.