Hi,
I have 120 individual data points (each representing a small airport) that I would like to perform the following analysis:
The image below is an example of one of these situations. The small green dot towards the right is the airport in consideration, the selected county is County A in this situation. Thus, County B is the county that is closest to County A for a statistic Y (e.g. most similar in population) and is intersected by the geodesic circle.
I believe this is a combination of Selection by Location and Selection by Attribute. Would Model Builder be the best approach for this problem?
Thanks ahead for the help!
Regards,
Jao
Have to tried this in modelbuilder for one case? If so you can examine the use of iterators in modelbuilder to automate the workflow. Examples are available in the help files once you get a single case working.
Hi Dan,
I'm a bit stuck on the modeling for even one case. The two specific points I'm stuck on for modeling one case is:
Any suggestions?
I was able to address Point 1, however I'm still uncertain on how to Select By Attribute based on the most similar value rather than an exact value. Any ideas?
I addressed Point 2 using a Similarity Search tool. Just need to iterate now.
I would use python for something like this:
First in arc I would cut the counties with a intersect and your circle. Using this and your airports as input to the code.
Read the columns of interest into lists (arrays) and then iterate over the lists and do the matching. Then output data to a new table.
SearchCursor http://resources.arcgis.com/en/help/main/10.1/index.html#//018w00000011000000
If you have not used python before this may look very hard at first. But it is not that bad as it is a small code project. I would think the hardest part would be the logic in the matching. That could be harder depending on the complexity of your criteria....
This sounds like fun, so I tried something and this is the result:
and this is what the connecting lines look like:
This is the code used. Change lines according to your data and needs:
import arcpy import os def main(): # inputs fc = r"D:\Xander\GeoNet\County\data.gdb\Counties_test" fld_id = "GEOID" fld_name = "NAME" fld_pop = "POP010210D" # output for validation fc_out = r"D:\Xander\GeoNet\County\data.gdb\connections03" # the geodesic distance distance = "300000 Meters" # internal settings ws_mem = "IN_MEMORY" arcpy.env.overwriteOutput = True sr = arcpy.Describe(fc).spatialReference # create featurelayer for selection arcpy.MakeFeatureLayer_management(fc, "county_lyr") # list to store output conector lines (between counties) lst_feats = [] # start search cursor over counties flds = ("SHAPE@", fld_id, fld_name, fld_pop) with arcpy.da.SearchCursor(fc, flds) as curs: for row in curs: polygon = row[0] geoid = row[1] name = row[2] pop = int(row[3]) # determine label point in input county pnt = polygon.labelPoint pntg = arcpy.PointGeometry(pnt, sr) # buffer label point fc_tmp = os.path.join(ws_mem, "tmp_buf") arcpy.Buffer_analysis(in_features=pntg, out_feature_class=fc_tmp, buffer_distance_or_field=distance, method="GEODESIC") # get first feature of buffer buf_pol = arcpy.da.SearchCursor(fc_tmp, ("SHAPE@",)).next()[0] # boundary = buf_pol.boundary() # lst_feats.append(boundary) # select by location arcpy.SelectLayerByLocation_management("county_lyr", "CROSSED_BY_THE_OUTLINE_OF", buf_pol, selection_type="NEW_SELECTION") # search selected counties for similar population min_dif = 999999 with arcpy.da.SearchCursor("county_lyr", flds) as curs_s: for row_s in curs_s: pnt_s = row_s[0].labelPoint pop2 = int(row_s[3]) dif = abs(pop - pop2) if dif < min_dif: # found a county min_dif = dif pop_found = pop2 geoid_found = row_s[1] name_found = row_s[2] pnt_found = arcpy.Point(pnt_s.X, pnt_s.Y) # create line between two counties line = arcpy.Polyline(arcpy.Array([pnt, pnt_found]), sr) lst_feats.append(line) # print result print "{0}\t{1}\t{2}\t{3}\t{4}\t{5}\t{6}".format(name, geoid, pop, name_found, geoid_found, pop_found, min_dif) # copy line features to output featureclass arcpy.CopyFeatures_management(lst_feats, fc_out) if __name__ == '__main__': main()