|
POST
|
I believe what is happening is each time a raster is added, the df extent is being set only to that raster. You will need to set the df extent prior to export to PDF. The following worked on my 10.1 machine. (note the paths are different). import arcpy, os from arcpy import env # Workspace inDir = (r'C:\Temp\Images') # Specify map document mxd = arcpy.mapping.MapDocument(r'C:\Temp\Images\Imagery.mxd') # Specify data frame df = arcpy.mapping.ListDataFrames(mxd, 'Layers')[0] # Import file dirList = os.listdir(r'C:\Temp\Images') for fname in dirList: if fname.endswith('.TIF'): print inDir + os.sep + fname lyrFile = arcpy.mapping.Layer(inDir + os.sep + fname) arcpy.mapping.AddLayer(df, lyrFile) #set df extent newExtent = df.extent newExtent.XMin, newExtent.YMin = 1017500, 629600 newExtent.XMax, newExtent.YMax = 1023000, 639200 df.extent = newExtent arcpy.mapping.ExportToPDF(mxd, r'C:\Temp\Images\Imagery.pdf' Note you found a loophole in using arcpy.mapping.Layer. It is intended to add layer files, not source data. The rasters may not render the way that you want them. Jeff
... View more
01-22-2013
05:43 AM
|
0
|
0
|
1109
|
|
POST
|
Python does not provide access to this property. But with arcpy.mapping you can get the extent of a dataframe. Knowing the extent coordinates you could determine if the extent changed. Jeff
... View more
01-17-2013
06:06 AM
|
0
|
0
|
581
|
|
POST
|
After moving to 10x, you will want to look into Data Driven Pages and/or arcpy.mapping. http://resources.arcgis.com/en/help/main/10.1/#/What_are_Data_Driven_Pages/00s90000003m000000/ http://resources.arcgis.com/en/help/main/10.1/#/Introduction_to_arcpy_mapping/00s300000032000000/ Jeff
... View more
01-13-2013
04:33 PM
|
0
|
0
|
685
|
|
POST
|
I can not reproduce. What types of layer are you trying to move? What is your reference layer type. Are you working with elements in a group layer. Jeff
... View more
01-13-2013
04:27 PM
|
0
|
0
|
1135
|
|
POST
|
This is an unintended feature. The Layer function was originally designed to work only with layer files. We have been made aware of its other uses. Because users are starting to use it we avoided preventing it from working but choose not to update the help because of unknown, untested consequences. Also - The Layer function is the same name as the Layer Class, just like the MapDocument function has the same name as the MapDocument Class. They were designed to work the same way. This issue is being evaluated. Thanks, Jeff
... View more
01-13-2013
04:12 PM
|
0
|
0
|
1653
|
|
POST
|
The feature class "metadata" description is independent from the layer description. If you add a FC directly into ArcMap and via the UI look at the layer properties, the layer description is blank. Layer decscriptions can be saved in layer files. Jeff
... View more
01-02-2013
07:51 AM
|
0
|
0
|
3346
|
|
POST
|
I just tested this using arcpy.mapping.UpdateLayer. http://resources.arcgis.com/en/help/main/10.1/#/UpdateLayer/00s30000003p000000/ Steps: - I created a new MXD and added BingMapsAerial. In the TOC, it is added as Basemap\BingMapsAerial. - I also added the Esri Imagery basemap (Basemap\World_Imagery). I right clicked on the BaseMap group name and saved it out to a layer file (Basemap.lyr). - I removed the Esri basemap (I added it just to create the layer file). - Next I ran the following code from the Python window in ArcMap:
mxd = arcpy.mapping.MapDocument("current")
df = arcpy.mapping.ListDataFrames(mxd)[0]
lyr = arcpy.mapping.ListLayers(mxd, "Basemap")[0] #this is the bing group layer
lyrFile = arcpy.mapping.Layer(r"C:\Temp\Basemap.lyr")
arcpy.mapping.UpdateLayer(df, lyr, lyrFile, False)
arcpy.RefreshActiveView()
Jeff
... View more
01-02-2013
07:39 AM
|
0
|
0
|
776
|
|
POST
|
The following code will generate 5 MXDs based on each great lake name.
import arcpy
mxd = arcpy.mapping.MapDocument(r"C:\Temp\GreatLakes.mxd")
ddp = mxd.dataDrivenPages
for pageNum in range(1, ddp.pageCount + 1):
ddp.currentPageID = pageNum
print "Saving %s.mxd" %(ddp.pageRow.getValue(ddp.pageNameField.name))
mxd.saveACopy(r"C:\Temp\\" + ddp.pageRow.getValue(ddp.pageNameField.name) + ".mxd")
del mxd
Jeff
... View more
01-02-2013
06:55 AM
|
0
|
0
|
6779
|
|
POST
|
The symbology object only supports a limited number of renderers (e.g., Unique Value, Graduated Color, Graduated Symbol, and Raster Classified). You are trying to .AddAllValues to a single symbol renderer. You can't do that. The help topic from http://resources.arcgis.com/en/help/main/10.1/#/UniqueValuesSymbology/00s30000005s000000/ shows a code sample:
import arcpy
mxd = arcpy.mapping.MapDocument("current")
lyr = arcpy.mapping.ListLayers(mxd, "Population")[0]
if lyr.symbologyType == "UNIQUE_VALUES":
lyr.symbology.valueField = "SUB_REGION"
lyr.symbology.addAllValues()
arcpy.RefreshActiveView()
arcpy.RefreshTOC()
del mxd
Jeff
... View more
12-28-2012
06:53 AM
|
0
|
0
|
5611
|
|
POST
|
If you are simply trying to export all pages using the page name as the output pdf name, try: import arcpy mxd = arcpy.mapping.MapDocument(r"S:\GIS\Appalachia\Map Projects\Midstream\Exhibits\Gathering Maps\Gathering Mapbook.mxd") ddp = mxd.dataDrivenPages ddp.exportToPDF(r"C:\Temp\Page", "ALL", multiple_files = "PDF_MULTIPLE_FILES_PAGE_NAME" Will produce a bunch of pages using the DDP index name field with a "Page" prefix. Jeff
... View more
12-26-2012
07:32 AM
|
1
|
0
|
6779
|
|
POST
|
The 2 immediate issues I see is that 1) you don't have [0]'s after your list functions and 2) you have a for loop but no indentation. import arcpy mxd = arcpy.mapping.MapDocument("My_MAP") mainDF = arcpy.mapping.ListDataFrames(mxd, "DFA")[0] locatorDF = arcpy.mapping.ListDataFrames(mxd, "DFB")[0] for DDP_Page in range(1, mxd.dataDrivenPages.pageCount + 1): mxd.dataDrivenPages.currentPageID = DDP_Page Rotate = mxd.dataDrivenPages.pageRow.Rotate #where Rotate is the name of the field in the attribute with the rotation values locatorDF.rotation = Rotate Another way to do this is to get the rotation property value from one DF and apply to the other. For example, locatorDF.rotation = mainDF.rotation You are not exporting or saving so your current code won't show immediate results. There is an enhancement request on "link to another data frame's extent" to automatically include rotation. Jeff
... View more
12-20-2012
05:47 AM
|
0
|
0
|
927
|
|
POST
|
Is the scale bar wrong or is it just resizing when your new scale is very different than a previous scale? What is your scalebar "when resizing ..." property set to: Adjust width Adjust division value (default) - that is what I'm seeing for you. Adjust number of divisions Adjust divisions and division values If you set the scale in the UI, do you get the same scale bar? Jeff
... View more
12-20-2012
05:31 AM
|
0
|
0
|
950
|
|
POST
|
Can you send a map package and your script to [email protected]. I'll take a look. If you can't send me a map package, at least send my your script so I can look at it. Jeff
... View more
12-19-2012
07:21 AM
|
0
|
0
|
1729
|
|
POST
|
If you call multiple MXDs and export, the export functions will use the settings saved in each MXD. For example:
mxd1 = arcpy.mapping.MapDocument("c:/path/largeSize.mxd")
arcpy.mapping.ExportToPDF(mxd1, outputPath)
mxd2 = arcpy.mapping.MapDocument("c:/path/smallSize.mxd")
arcpy.mapping.ExportToPDF(mxd2, outputPath)
Will produce two different PDFs, each at different page sizes. If you are using "CURRENT" and trying to load properties from other MXDs, that is NOT possible. As suggested, pagesize and orientation can not be modified within an MXD. Jeff
... View more
12-19-2012
07:18 AM
|
0
|
0
|
1448
|
|
POST
|
The "layer" in the select statement is from arc.getParameterAsText(0) with data type in properties parameters set to Layer. Try this: Set the layer name parameter as a string type. Enter a string value that is equal to the layer name in the TOC. Then try:
lyrName = arcpy.getParameterAsText(0)
mxd = arcpy.mapping.MapDocument (r"T:\1_DOUGLAS_PROJECTS\......\_SINGLE_PARCEL.mxd")
df = arcpy.mapping.ListDataFrames (mxd, "Layers")[0]
lyr = arcpy.mapping.ListLayers(mxd, lyrName, df)[0]
arcpy.SelectLayerByAttribute_management(lyr, "NEW_SELECTION", selstring)
Jeff
... View more
12-19-2012
06:13 AM
|
0
|
0
|
1729
|
| 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
|