Hello all.
I wrote an arcpy script to change the symbols for the (point) data of a layer.
I am able to adjust the size of the symbol, its color, its outline width, its outline color, and also to replace the symbol with another symbol from the gallery.
However, what I have not been able to achieve is to set the symbol size to a fixed size such that it is not scaled when zooming - i.e. the symbol should get bigger when zooming in and smaller when zooming out.
In the documentation of the symbol class (https://pro.arcgis.com/de/pro-app/latest/arcpy/mapping/symbol-class.htm), the property useRealWorldUnits is listed which - from the description - should be exactly what I need. However, the use of
symbol.useRealWorldUnits = True
has no effect, the symbols are still scaled (I also tried setting the boolean to False but this also does not change anything).
Here an excerpt of my code, already having the reference to the layer for which I want to alter the symbol:
symbology = layer.symbology
renderer = symbology.renderer
symbol = renderer.symbol
symbol.size = 100
symbol.useRealWorldUnits = True # does not work..?
symbol.color = {'RGB' : [255, 0, 128, 60]}
symbol.outlineWidth = 0.2
symbol.outlineColor = {'RGB' : [255, 0, 0, 60]}
layer.symbology = symbology
and its effects in ArcGIS Pro:
1. Before running the script, the map looks like this:
2. For testing purposes, I alter the symbology for a point data layer such that the symbols are huge (and also have a very noticeable color):
3. When zooming out, the symbols are scaled and consequently cover a lot more area in "real world units":
Does anyone know how I can fix the symbol size to the real world units by use of arcpy?
I am using ArcGIS Pro 2.9.2, and the arcpy version is also 2.9.2.
Solved! Go to Solution.
Hi,
in my opinion you have to use the property "referenceScale" on the map. Looks like this:
aprx = arcpy.mp.ArcGISProject(r"CURRENT")
map = aprx.activeMap
map.referenceScale = 5000
Now the symbols have a fixed size in the map. I am not sure if you can set a fixed size for the layer directly.
Hi,
in my opinion you have to use the property "referenceScale" on the map. Looks like this:
aprx = arcpy.mp.ArcGISProject(r"CURRENT")
map = aprx.activeMap
map.referenceScale = 5000
Now the symbols have a fixed size in the map. I am not sure if you can set a fixed size for the layer directly.
Hi @Sven_Harpering ,
thanks so much for your answer (and sorry for my late response). Using the "referenceScale" does the job for me and is sufficient to achieve the desired result. Cheers!