|
POST
|
I don't think my original response addresses the main concern (you want to go to JPEG, not PDF). Here is another shot at it. Again, build your DDP using the complete set of features and then build your selection. Next, use the .selectedPages property on the DDP object to process only the pages of interest. Look at code examples 1 and 3 in the arcpy.mapping DDP object help topic. In example 1, change PNG to JPEG and use the selected pages optoin from example 3. I hope this helps, Jeff
... View more
06-25-2012
06:54 AM
|
0
|
0
|
2296
|
|
POST
|
This is one variation:
import os
path = r"C:\Active\ArcPY\ResourceCenter"
i = 0
for (path, dirs, files) in os.walk(path):
for file in files:
if file.endswith(".mxd"):
print os.path.join(path,file)
Jeff
... View more
06-25-2012
06:38 AM
|
0
|
0
|
736
|
|
POST
|
I don't understand, is is really a bug if it is documented to use "full paths" or "CURRENT"? I use relative paths all the time but I'm actually providing a full path to the MapDocument function:
import arcpy, os, sys
relPath = os.path.dirname(sys.argv[0])
mxd = arcpy.mapping.MapDocument(relPath + r"\project.mxd")
Jeff
... View more
06-22-2012
08:25 AM
|
0
|
0
|
623
|
|
POST
|
One possible issue is your "TRUE" statement in:
mxd.findAndReplaceWorkspacePaths(r"J:\GIS\JHill\SDE_To_Route", r"\\itdgishq\hqgis\LocalRds\SDE_To_Route", "TRUE")
Try:
mxd.findAndReplaceWorkspacePaths(r"J:\GIS\JHill\SDE_To_Route", r"\\itdgishq\hqgis\LocalRds\SDE_To_Route", True)
or because True is the default value, try:
mxd.findAndReplaceWorkspacePaths(r"J:\GIS\JHill\SDE_To_Route", r"\\itdgishq\hqgis\LocalRds\SDE_To_Route")
Jeff
... View more
06-22-2012
07:26 AM
|
0
|
0
|
2433
|
|
POST
|
There is an option when exporting DDP to use only the selected set. So I would enable DDP on all features of the index layer, then create my selection, then export. In the UI, go to File --> ExportMap --> Select PDF --> Pages Tab - check Selection (optionally you can show selection) In arcpy, the parameters are: exportToPDF (out_pdf, {page_range_type}, {page_range_string}, {multiple_files}, {resolution}, {image_quality}, {colorspace}, {compress_vectors}, {image_compression}, {picture_symbol}, {convert_markers}, {embed_fonts}, {layers_attributes}, {georef_info}, {jpeg_compression_quality}, {show_selection_symbology}) Set page_range_type = "SELECTION", optionally, set show_selection_symbology=True Jeff
... View more
06-22-2012
06:35 AM
|
0
|
0
|
2296
|
|
POST
|
I'm not sure how to find individual, contained features but have you considered using Dissolve for your second question? Jeff
... View more
06-22-2012
06:27 AM
|
0
|
0
|
817
|
|
POST
|
It was added at 10.1. It is the last parameter and is called show_selection_symbology. exportToPDF (out_pdf, {page_range_type}, {page_range_string}, {multiple_files}, {resolution}, {image_quality}, {colorspace}, {compress_vectors}, {image_compression}, {picture_symbol}, {convert_markers}, {embed_fonts}, {layers_attributes}, {georef_info}, {jpeg_compression_quality}, {show_selection_symbology}) Jeff
... View more
06-20-2012
07:25 AM
|
0
|
0
|
619
|
|
POST
|
Data frames can not be dynamically added to a map document via Python. They must be authored ahead of time in the map document. Jeff
... View more
06-19-2012
11:01 AM
|
0
|
0
|
1974
|
|
POST
|
This would probably be better in a separate post (for those trying to search and learn) but here one approach. The issue must be that your page numbers are formated as a string. Try:
>>> keys = ["2", "10", "14", "100", "23"]
>>> keys.sort()
>>> print keys
['10', '100', '14', '2', '23']
>>> keys.sort(key=lambda x: [int(y) for y in x.split('.')])
>>> print keys
['2', '10', '14', '23', '100']
... View more
06-19-2012
07:18 AM
|
0
|
0
|
2391
|
|
POST
|
This direct capability was not added at 10.1 but have you tried definition queries and page definitions (with DDP)? Jeff
... View more
06-19-2012
06:49 AM
|
0
|
0
|
3603
|
|
POST
|
I can not reproduce this. I've tried updating with layers from layer files, other MXDs (as in your example), I've done with with stand alone scripts, using CURRENT, etc. Please provide more detailed steps so I can evaluate this further. Thanks, Jeff
... View more
06-18-2012
08:48 AM
|
0
|
0
|
4983
|
|
POST
|
I would change Expression ="MER= "+MER "AND" "TWP= "+TWP "AND" "RNG= "+RNG "AND" "SEC= "+SEC to Expression ="MER= "+ MER + " AND TWP= " + TWP + " AND RNG= " + RNG + " AND SEC= " + SEC or Expression = "MER= {0} AND TWP= {1} AND RNG= {2} AND SEC= {3}".format(MER,TWP,RNG,SEC) Jeff
... View more
06-18-2012
07:41 AM
|
0
|
0
|
1979
|
|
POST
|
I was able to get this to work. Attached are some results from a sample I'd like to post to the Resource Center. [ATTACH=CONFIG]15283[/ATTACH] Jeff
... View more
06-18-2012
07:12 AM
|
0
|
0
|
3806
|
|
POST
|
Hmmm. So if you add two North arrows (one for each data frame), they don't rotate? Make sure the appropriate data frame is active when you insert each North Arrow. Each North Arrow must be associated with a data frame. Jeff
... View more
06-18-2012
06:58 AM
|
0
|
0
|
3806
|
|
POST
|
I just did something similar for a colleague. Here is the complete code snippet. Just like you suggest, I build two empty lists and append the unique values to them. Note, I'm using the new da.SearchCursor at 10.1.
import arcpy
def int_if_you_can(x):
return int(x) if x % 1.0 == 0 else x
#Reference layer and update to Unique Value renderer using layer file
mxd = arcpy.mapping.MapDocument("current")
df = arcpy.mapping.ListDataFrames(mxd, "Layers")[0]
lyr100 = arcpy.mapping.ListLayers(mxd, "interval_100")[0]
lyrFile = arcpy.mapping.Layer(r"C:\Active\ArcPY\Users\SteveLynch\interval_100.lyr")
arcpy.mapping.UpdateLayer(df,lyr100,lyrFile)
#Apply source data to layer
sym = lyr100.symbology
sym.addAllValues()
#Generate unique list of lables
classList = []
labelList = []
with arcpy.da.SearchCursor(lyr100, ("mean_cont", "low_cont", "high_cont"), sql_clause=(None,"ORDER BY mean_cont")) as rows:
for row in rows:
lowCont = str(int_if_you_can(row[1]))
highCont = str(int_if_you_can(row[2]))
if not lowCont + " - " + highCont in labelList:
classValue = in_if_you_can(row[0])
classList.append(classValue)
label = lowCont + " - " + highCont
labelList.append(label)
#Update layer with new label classes
sym.classValues = classList
sym.classLabels = labelList
arcpy.RefreshActiveView()
Jeff
... View more
06-14-2012
06:20 AM
|
0
|
0
|
1379
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 06-05-2025 11:20 AM | |
| 3 | 06-05-2025 09:21 AM | |
| 1 | 05-14-2025 01:19 PM | |
| 2 | 04-24-2025 07:54 AM | |
| 1 | 03-15-2025 07:19 PM |
| Online Status |
Offline
|
| Date Last Visited |
06-23-2026
10:29 AM
|