Select to view content in your preferred language

Re: Select Layer by Location works in ArcGIS Pro Python window but not standalone

1767
11
Jump to solution
11-03-2021 12:35 PM
curtvprice
MVP Esteemed Contributor

I'm assuming there is a feature class Test_Points in the gdb. This is a feature class, not a layer.

If you want to do selections on it, you need to create a new layer in memory from it using the Make Feature Layer tool. 

When running the script in Pro I am assuming there is a layer in the currently active map named Test_Points and also a feature class in your gdb; the layer takes precedence which is why it works in a pro window.

By the way I also recommend using the arcpy.da cursors instead, they are dramatically more efficient than the (older) arcpy cursors.

NOTE: original post is below in the thread

0 Kudos
11 Replies
curtvprice
MVP Esteemed Contributor

Thanks for sharing all the details Jonathon, this is useful info!

I think it is the case in ArcMap that these tools will not work at all correctly unless you have the inputs in the same coordinate system, and have always taught my students to have the inputs in the same CS before doing a Select Layer By Location.

If you are up to trying something else, I wonder if setting the arcpy.env.outputCoordinateSystem would help with your standalone script if your inputs are different coordinate systems. I think I'd rather take your approach though to avoid surprises. (Sometimes we should not tempt fate.)

JoeBorgione
MVP Emeritus

Interesting...

 

That should just about do it....
0 Kudos