I have a blank map. And I have a shapefile. I would like to add the shapefile to the map document, change its colour to grey and then save the map document.
My plan is to make a layer from the shapefile (
MakeFeatureLayer_management), add the resulting layer to the map document (
mapping.AddLayer) and then change its colour using
This is my code so far:
import arcpy, os ### Set directory arcpy.env.workspace = ... arcpy.env.overwriteOutput = 1 ### Define inputs yellow = "symbology/yellow.lyr" # Set map document mxd_city_year = arcpy.mapping.MapDocument(r"...\blank_map.mxd") DF = arcpy.mapping.ListDataFrames(mxd_city_year) # Add layers arcpy.MakeFeatureLayer_management("states/continental_US.shp", "us") basis = arcpy.mapping.Layer("us") arcpy.mapping.AddLayer(DF, basis, "AUTO_ARRANGE") arcpy.ApplySymbologyFromLayer_management(basis, yellow) # Save map mxd_city_year.saveACopy("thresh_" + city + "_" + year + ".mxd")
The code runs through (no error). However, in the resulting map document the colour still seems to be random.
What is my mistake?