arcpy.SelectLayerByLocation_management("ProjectsLayer", "INTERSECT", "RegionOverlay")
import arcpy arcpy.env.workspace = 'PATH_TO_RESOURCE' arcpy.env.overwriteOutput = True inFeatureClass = arcpy.GetParameterAsText(0) if inFeatureClass == "Elderly block groups": selectedLayer = 'PATH_TO_RESOURCE' elif inFeatureClass == "Minorities": selectedLayer = 'PATH_TO_RESOURCE' mxd = arcpy.mapping.MapDocument("CURRENT") df = arcpy.mapping.ListDataFrames(mxd,"*")[0] newlayer = arcpy.mapping.Layer(selectedLayer) projects = 'PATH_TO_RESOURCE' projectsLayer = arcpy.mapping.Layer(projects) arcpy.mapping.AddLayer(df, newlayer) arcpy.mapping.AddLayer(df, projectsLayer, "TOP") arcpy.MakeFeatureLayer_management(projects, "ProjectsLayer") arcpy.MakeFeatureLayer_management(newlayer, "RegionOverlay") arcpy.SelectLayerByLocation_management("ProjectsLayer", "INTERSECT", "RegionOverlay") arcpy.MakeFeatureLayer_management("ProjectsLayer", "OverlayProjects")
Solved! Go to Solution.
import arcpy, os mxd = arcpy.mapping.MapDocument("current") df = arcpy.mapping.ListDataFrames(mxd)[0] rootPath = r"V:\Projects\Shared\RouteLogSystem\ArcGIS_10_Prototype\Prototype_V10" LyrFile1 = arcpy.mapping.Layer(os.path.join(rootPath, r"LayerFiles\rtlogpts.lyr")) #points LyrFile2 = arcpy.mapping.Layer(os.path.join(rootPath, r"LayerFiles\envelope.lyr")) #polygon arcpy.mapping.AddLayer(df, LyrFile1, "TOP") Lyr1 = arcpy.mapping.ListLayers(mxd, "rtlogpts")[0] arcpy.mapping.InsertLayer(df, Lyr1, LyrFile2, "AFTER") Lyr2 = arcpy.mapping.ListLayers(mxd, "envelope")[0] arcpy.SelectLayerByLocation_management(Lyr1, "INTERSECT", Lyr2)
import arcpy, os mxd = arcpy.mapping.MapDocument("current") df = arcpy.mapping.ListDataFrames(mxd)[0] rootPath = r"V:\Projects\Shared\RouteLogSystem\ArcGIS_10_Prototype\Prototype_V10" LyrFile1 = arcpy.mapping.Layer(os.path.join(rootPath, r"LayerFiles\rtlogpts.lyr")) #points LyrFile2 = arcpy.mapping.Layer(os.path.join(rootPath, r"LayerFiles\envelope.lyr")) #polygon arcpy.mapping.AddLayer(df, LyrFile1, "TOP") Lyr1 = arcpy.mapping.ListLayers(mxd, "rtlogpts")[0] arcpy.mapping.InsertLayer(df, Lyr1, LyrFile2, "AFTER") Lyr2 = arcpy.mapping.ListLayers(mxd, "envelope")[0] arcpy.SelectLayerByLocation_management(Lyr1, "INTERSECT", Lyr2)