# ...snip # get all intersections ACDEFGHIJKM (see help diagrams for letters) arcpy.management.SelectLayerByLocation(fcLayer,'INTERSECT',gaLayer,selection_type='NEW_SELECTION') # copy to a temp layer, snap, then remove those outside but touching snapFC = prefix+fcAbbrev+"_snap" arcpy.management.CopyFeatures(fcLayer,snapFC) arcpy.management.MakeFeatureLayer(snapFC,touchLayer) # Have no selection to start arcpy.management.SelectLayerByLocation(gaLayer,'INTERSECT',fcLayer,selection_type='ADD_TO_SELECTION') arcpy.edit.Snap(touchLayer,[[gaLayer,'VERTEX',4],[gaLayer,'EDGE',4]]) # get outside touching to exclude DIJ (help diagram cases) arcpy.management.SelectLayerByLocation(touchLayer,'BOUNDARY_TOUCHES',gaLayer,selection_type='NEW_SELECTION') arcpy.management.SelectLayerByLocation(touchLayer,'WITHIN',gaLayer,selection_type='REMOVE_FROM_SELECTION') arcpy.management.SelectLayerByLocation(touchLayer,'CONTAINS',gaLayer,selection_type='REMOVE_FROM_SELECTION') # subtract outside touching if any DIJ (see help) cTouch = int(arcpy.management.GetCount(touchLayer).getOutput(0)) if cTouch == 0: arcpy.analysis.SpatialJoin(fcLayer,gaLayer, prefix+fcAbbrev,'JOIN_ONE_TO_MANY','KEEP_COMMON',"#",'INTERSECT') count = int(arcpy.management.GetCount(prefix+fcAbbrev).getOutput(0)) if count > 0: dCount[fcAbbrev] = count msg = "GA %s %s %s %d" % (aggregate_area,arcpy.management.GetCount(gaLayer),fcAbbrev,dCount[fcAbbrev]) logging.info(msg) print msg else: arcpy.management.Delete(prefix+fcAbbrev) else: lstPar = [row.par_id for row in arcpy.SearchCursor(touchLayer)] if len(lstPar) > 0: if len(lstPar) == 1: expr = "PAR_ID = "+str(lstPar[0]) else: expr = "PAR_ID in "+str(tuple(lstPar)) # print "touching outside",cTouch #,expr # remove from list of new parcels of interest try: arcpy.management.SelectLayerByAttribute(fcLayer,"REMOVE_FROM_SELECTION",expr) except: print "error",expr # if int(arcpy.management.GetCount(fcLayer).getOutput(0)) > 0: arcpy.analysis.SpatialJoin(fcLayer,gaLayer, prefix+fcAbbrev,'JOIN_ONE_TO_MANY','KEEP_COMMON',"#",'INTERSECT') count = int(arcpy.management.GetCount(prefix+fcAbbrev).getOutput(0)) if count > 0: dCount[fcAbbrev] = count # tag touched GA layers arcpy.management.SelectLayerByLocation(gaLayer,'INTERSECT',fcLayer,selection_type='ADD_TO_SELECTION') msg = "GA %s %s %s %d" % (aggregate_area,arcpy.management.GetCount(gaLayer),fcAbbrev,dCount[fcAbbrev]) logging.info(msg) print msg else: arcpy.management.Delete(prefix+fcAbbrev)
Angemeldete Mitglieder können Beiträge verfassen, Updates folgen und mehr. Neu hier? Registriere ein kostenloses Konto.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.