POST
|
Manish, you are a godsend. It worked like a charm. Thanks so much! Gil
... View more
10-17-2020
08:48 PM
|
1
|
1
|
1398
|
POST
|
Hi Everyone: I have successfully produced a map with title, legend and statistics (number, maximum, minimum, mean). I did this within ArcPro through the desktop application, creating a template. Now I want to produce many maps, but only changing the column of data or "field" in the corresponding attribute table. I only having issues with the statistics (number, maximum, minimum, mean) where the field does not change even when the map plots do (so I have the title, legend and the map colors for each polygon on the map updating to the newer column through an earlier command "sym.renderer.classificationField = 'Sheet4.NEI2014v_1' " which switched it from the NEI2014v2_ field. This command appears to not impact the text statistics (number, max, min, mean) which are based on the listElements module under "TEXT_ELEMENT". The dynamic text tag reads as follows: Maximum: <dyn type="table" property="max" mapFrame="Map Frame" mapMemberUri="CIMPATH=map/cb_2018_us_county_500k.xml" isDynamic="true" field="Sheet4.NEI2014v2_" decimalPlaces="2" separator="true"/> In Arcpy.mp, I am able to print out this text out with: aprx = arcpy.mp.ArcGISProject(relpath + r'C:/Users/ggrodzinsky/Documents/ArcGIS/Projects/MyProject8/SavedOutput7014.aprx') m=aprx.listMaps("Map")[0] l = m.listLayers()[2] Layout = aprx.listLayouts("Layout")[0] five=Layout.listElements("TEXT_ELEMENT",'Text 2')[0] print(five.text) And it produced: Maximum: <dyn type="table" property="max" mapFrame="Map Frame" mapMemberUri="CIMPATH=map/cb_2018_us_county_500k.xml" isDynamic="true" field="Sheet4.NEI2014v2_" decimalPlaces="2" separator="true"/> Don't worry about the above coding, other than this is how I confirmed this is indeed the contents of this Text Element on the Layout I am working on. What I want to do in my program is change the dynamic text tag so the field changes to a different column of values in the attribute table ("field" is the column title on the attribute table), specifically from "Sheet4.NEI2014v2_" to "Sheet4.NEI2014v_1". So if I typed "print(five.text) again, it would show field="Sheet.NEI2014v_1" instead in the dynamic text tag. I searched around and can't find the correct command or coding to have the dynamic text tag change the "field" It is simply typing in a box in the ArcPro desktop app, but I want to mass produce this through Arcpy.mp (or at least be able to produce a dozen at a time for this case). Thanks so much for your input! Gil
... View more
10-16-2020
11:35 AM
|
0
|
3
|
1490
|
POST
|
Hi Everyone. I have a very basic question. My apologies in advance. I am able to create a map, add layers, even make a pdf and with another software create a page with four maps on it. However, I am stuck with how to use arcpy in ArcPro to simply add a title to the layout for my map before exporting it to pdf or png. My layout has no title. How do I add one? Same goes with the legend as I don't have the color legend (need to look like a continuous bar). Thanks for your help and excuse the simplicity of the question! Top priority is the title for now!
... View more
10-09-2020
02:53 PM
|
0
|
0
|
290
|
POST
|
if not hasattr(sys, 'argv'): #only use if system has issue with relpath command
sys.argv = ['']
import arcpy, os, sys, locale
relpath = os.path.dirname(sys.argv[0])
p = arcpy.mp.ArcGISProject(relpath + r'C:/Users/ggrodzinsky/Documents/ArcGIS/Projects/MyProject8/MyProject8.aprx')
m = p.listMaps()[0]
l = m.listLayers("cb_2018_us_county_500k")[0]
sym = l.symbology
if hasattr(sym, 'renderer'):
if sym.renderer.type == 'SimpleRenderer':
sym.updateRenderer('GraduatedColorsRenderer')
l.symbology = sym
sym.renderer.classificationField = 'Sheet4.AWATER'
sym.renderer.breakCount = 7
breakVal = 1000
cv = 0
lw = 1
for brk in sym.renderer.classBreaks:
brk.upperBound = breakVal
brk.label = "\u2264" + str(locale.format("%d", breakVal, grouping=True))
brk.description = "Description " + str(cv)
brk.symbol.color = {'HSV' : [cv, 100, 100, 100]}
brk.symbol.outlineColor = {'HSV' : [240-cv, 100, 100, 100]}
brk.symbol.size = lw
breakVal +=1000
cv += 40
lw += 0.5
l.symbology = sym
p.saveACopy(relpath + r'C:/Users/ggrodzinsky/Documents/ArcGIS/Projects/MyProject8/SavedOutput2.aprx')
... View more
08-28-2020
08:56 AM
|
0
|
1
|
723
|
POST
|
Hi Everyone: I have this code that works: if not hasattr(sys, 'argv'): #only use if system has issue with relpath command sys.argv = [''] import arcpy, os, sys, locale relpath = os.path.dirname(sys.argv[0]) p = arcpy.mp.ArcGISProject(relpath + r'C:/Users/ggrodzinsky/Documents/ArcGIS/Projects/MyProject8/MyProject8.aprx') m = p.listMaps()[0] l = m.listLayers("cb_2018_us_county_500k")[0] sym = l.symbology if hasattr(sym, 'renderer'): if sym.renderer.type == 'SimpleRenderer': sym.updateRenderer('GraduatedColorsRenderer') l.symbology = sym sym.renderer.classificationField = 'Sheet4.AWATER' sym.renderer.breakCount = 7 breakVal = 1000 cv = 0 lw = 1 for brk in sym.renderer.classBreaks: brk.upperBound = breakVal brk.label = "\u2264" + str(locale.format("%d", breakVal, grouping=True)) brk.description = "Description " + str(cv) brk.symbol.color = {'HSV' : [cv, 100, 100, 100]} brk.symbol.outlineColor = {'HSV' : [240-cv, 100, 100, 100]} brk.symbol.size = lw breakVal +=1000 cv += 40 lw += 0.5 l.symbology = sym p.saveACopy(relpath + r'C:/Users/ggrodzinsky/Documents/ArcGIS/Projects/MyProject8/SavedOutput2.aprx') However, I want to run it so it creates multiple maps in one efficient, condensed code with a loop instead of a lengthy code where within the code I repeat all the above and just change "AWATER" to the next column in my table and "SavedOutput2.aprx" to "SavedOutput3.aprx" to produced a series of symbolized maps. In short, how can I modify this code so the "sym.renderer.classificationField = 'Sheet4.AWATER' can be modified to allow for a loop where "AWATER" is replaced with a variable that with each loop grabs from the next column in the table. Same goes with the line: p.saveACopy(relpath + r'C:/Users/ggrodzinsky/Documents/ArcGIS/Projects/MyProject8/SavedOutput2.aprx') where instead of "SavedOutput2.aprx" it is "SavedOutput#.aprx" where # is increased by one with each step in the loop, thus making a new file with each mapped column. Thanks! GG
... View more
08-28-2020
08:44 AM
|
0
|
3
|
759
|
Title | Kudos | Posted |
---|---|---|
1 | 10-17-2020 08:48 PM |
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:24 AM
|