Select to view content in your preferred language

arcpy - How to achieve that symbols have a fix size and are not scaled when zooming

789
2
Jump to solution
05-16-2023 11:58 PM
lbd_bayern
New Contributor II

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:

01_start.jpg

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):

02_after run script_same zoom level.jpg

3. When zooming out, the symbols are scaled and consequently cover a lot more area in "real world units":

03_after run script_different zoom level.jpg

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.

1 Solution

Accepted Solutions
Sven_Harpering
Esri Contributor

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.

Passionate about GIS and on the journey as an instructor for analytical insights.

View solution in original post

2 Replies
Sven_Harpering
Esri Contributor

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.

Passionate about GIS and on the journey as an instructor for analytical insights.
lbd_bayern
New Contributor II

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!