SelectLayerByLocation Alternatives?

4926
22
Jump to solution
09-29-2017 11:46 AM
JamesCrandall
MVP Frequent Contributor

Being a bit greedy here, I know but has anyone come up with more efficient/faster alternatives to arcpy.SelectLayerByLocation_management?

I'd say for the vast majority (ie. 99%) implementing this is entirely acceptable.  However, I've run into a couple of instances lately that require several of these calls to be made in order to build a list/set of results that ultimately return an expected response.

...or in another instance, there are a large amount of point features (85 million) that need to be identified as COMPLETELY_WITHIN a simple single polygon feature.  In most cases it's sub 30 seconds to return the expected result.

However if these processes are to be published as synchronous GP services, the processing times can be excessive in that context.

numpy? dictionaries? pandas? Anything at all that you may have tried to exceed the performance of arcpy.SelectLayerByLocation_management???

Case / scenario: select by location on points within a simple polygon feature and return a yes or no if the count is > 0

0 Kudos
22 Replies
ChrisSnyder
Regular Contributor III

Very nice!

Maybe the 'Dice' tool would provide a more "optimal" way to break the polygon geometry up?

JamesCrandall
MVP Frequent Contributor

Thanks for the idea!  I implemented it and it performed well, very close to the Fishnet approach I laid out.  Unfortunately, the Dice_management requires an Advanced license level, which is not available on the ArcGIS Server this GP service will be published too.

This also has me back at the drawing board to get the output Fishnet line features converted to polygons too because the FeatureToPolygon_management I implemented in my example solution requires that same Advanced license.

0 Kudos
JamesCrandall
MVP Frequent Contributor

ah ha!  The solution is to implement arcpy.GridIndexFeatures_cartography along with the fishnet output.  No Advanced licensing needed and still keeps processing sub-10secs

0 Kudos