Thursday, 9 July 2015

Does ArcPy have spatial search function for geometry?



My problem: Using ArcPy I want to loop over buffers and select geometry_features inside each buffer and do something (update) only the objects found within that specific buffer. The code below explains what I want to do (more or less):


def _update_connections_inside_buffers(self):
buffers = arcpy.SearchCursor(self.__buffer_class_name)
in_layer = "connections"
for i_buffer in buffers:
shape = i_buffer.shape
# can not use a geometry to do a selection.. very inconvenient!!
connections = arcpy.SelectLayerByLocation_management(in_layer, "WITHIN", shape)
self._update_connections(connections)


However: this will not work because SelectLayerByLocation_management() does not accept a geometry, "shape" as an argument but expects a feature_class_name (layer name). Is there a arcpy method that can do a search using a spatial predicate. I could not find how to do this from the ESRI manual.




No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...