Python script to find out if two layers are overlapping

1448
13
01-07-2020 10:57 AM
by Anonymous User
Not applicable

As part of QAQC, I have to routinely check if all vector line data is buffered on the buffered layer. The layers are: vector line layer, buffer layer, and grid number layer. As of right now, I scan the entire county boundary to see if there is any vector line data that is not buffered on the buffer layer. If it is not buffered, I need to find out which grid number the problem resides. 

I would like to make a python script that would check to see if all vector line data (layer 1) is overlaying the buffered layer (layer 2) and if not, which grid number (layer 3) is the problem. 

Does anyone have any experience trying to write a python script that can tell if one layer is spatially overlaying another layer?

Code examples would be much appreciated. 

0 Kudos
13 Replies
AndrewLaws2
New Contributor

Can you tell it's my first time posting code to Geonet haha. Thank you for highlighting this to me.

0 Kudos
by Anonymous User
Not applicable

Thanks so much for the code example. 

Unfortunately, after running the SelectLayerByLocation_management function, I get an error stating, "ERROR 000368: Invalid input data." 

After googling, it says SelectLayerByLocation requires a layer to select features so you cant select features directly on a feature class.  Would this be solved by a preceding MakeFeatureLayer function? 

0 Kudos
JoeBorgione
MVP Emeritus

Yep.

That should just about do it....
0 Kudos
AndrewLaws2
New Contributor

Yes, it would. You may have to do it for each layer you are gonna do. 

0 Kudos