YoYoYo
YoYoYo

Reputation: 37

ArcGIS Selecting Everything within the circles on map

I am new to ArcGIS. I have been tasked with making a python script that will select the regions within the larger circles below.

enter image description here

So in other words make a selection of everything in the larger green, red, and light blue circles above. I am not sure if this is even possible so could someone let me know if it is possible and direct me to whatever documentation or other resources I need to review on it to make this happen?

At the moment we are using Arcgis Online but may need to use ArcGIS Pro to make this work?

Upvotes: 1

Views: 48

Answers (1)

This is totally doable with agol/Arcgis Enterprise GeometryServer, or arcgis api for python. // First aproach 1 - First you merge the biggest geometry.

2- Then, you will subtract the smallest geometry. Now you have the geometry to make the selection.

3- select every FeatureLayer you want with the resultant geometry from steps 1,2

//Second aproach

1 - Make one spatial join with biggest buffer

2 - Make another spatial join with smallest buffer

3 - The result objectids should be only in the biggest buffer, use it to do the selection.

from arcgis.gis import GIS
from arcgis.features import GeoAccessor
import os
gis = GIS("home")

gdb_path = os.path.abspath('./arcgis-selecting-everything-within-the-circles-on-map.gdb')
# Get the feature layer
## you can also use the feature layer url
## big_buff = GeoAccessor.from_featureclass('https://url/FeatureServer/0')
big_buff = GeoAccessor.from_featureclass(os.path.join(gdb_path, 'mypoints_Buffer2'))
small_buff = GeoAccessor.from_featureclass(os.path.join(gdb_path, 'mypoints_Buffer'))

points = GeoAccessor.from_featureclass(os.path.join(gdb_path, 'mypoints'))


big_buff_merged = big_buff.dissolve()

p1 = points.spatial.join(big_buff, op='within').drop_duplicates(subset=['OBJECTID_left'])[['OBJECTID_left']]
p2 = points.spatial.join(small_buff, op='within').drop_duplicates(subset=['OBJECTID_left'])[['OBJECTID_left']]

result = p1.merge(p2, how='outer', indicator=True).query('_merge == "left_only"').drop(columns=['_merge'])
result = points.merge(result, how='inner', left_on='OBJECTID', right_on='OBJECTID_left').drop(columns=['OBJECTID_left'])
result

enter image description here

enter image description here

Upvotes: 1

Related Questions