Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Say I have a Shapefile:


A layer file:


And a map document:


How can I add points.shp to map.mxd with the properties of symbology.lyr all using python? Again I want to thank everyone in advance for their help.

share|improve this question
If you have not done so already look at ArcPy's AddLayer method and Layer properties especially setDataSource. – PolyGeo May 1 '13 at 22:20
Are you aiming to set the symbology of points to that of the symbology.lyr? Or set ALL of the properties from one to the other? Import Symbology – gm70560 May 1 '13 at 22:21
All of the properties. – gomapping May 1 '13 at 22:24
up vote 2 down vote accepted

I just tested this and it worked!

The layer file that I added, and then changed the data source of, was saved from a layer called dummy that pointed at a dummy.shp file.

import arcpy

mxd = arcpy.mapping.MapDocument("C:\\MAPS\\map.mxd")
df = arcpy.mapping.ListDataFrames(mxd,"Layers")[0]

addLayer = arcpy.mapping.Layer("C:\\SYMBOLOGY\\symbology.lyr")
arcpy.mapping.AddLayer(df, addLayer)
lyr = arcpy.mapping.ListLayers(mxd,"dummy",df)[0]

print lyr.dataSource

lyr.replaceDataSource("C:\\DATA\\", "SHAPEFILE_WORKSPACE", "points") = "points"

print lyr.dataSource

share|improve this answer
Awesome, I am going to test this out and then I'll be back with more gratitude. – gomapping May 2 '13 at 13:55
And I'm back works amazingly. Thanks again. – gomapping May 2 '13 at 17:27

I haven't tested this out, but the easiest way should be to simply rename (or copy) symbology.lyr to points.lyr (the same basename as your shapefile). Generally speaking, when you load a shapefile into ArcMap that has a similarly name Layer file, the symbology of the layer "follows" the raw data (shapefile) and is applied on load.

share|improve this answer
Yes, but symbology.lyr is a generic file for many maps and really I just need to do exactly what is outlined above. This is just a small part of a bigger task to automate map creation. Thanks anyways though. – gomapping May 1 '13 at 22:03

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.