|
POST
|
This may work well for your specific scenario but there are many other scenarios where uses cases would NOT want the name to dynamically change. BUT ... this can be fully automated using arcpy.mapping. There are several approaches. The simplest my be finding the layer of interest in the TOC, changing its datasource to the new location and then simply changing its name property. Here is an example:
mxd = arcpy.mapping.MapDocument(path)
lyr = arcpy.mapping.ListLayers(mxd, "some layer name")[0]
lyr.findAndReplaceWorkspacePath(path1, path2)
lyr.name = "some new name"
mxd.save()
Jeff
... View more
02-12-2014
06:18 AM
|
0
|
0
|
1285
|
|
POST
|
Arcpy.mapping only allows you to clone/delete graphic elements on a layout. I believe the only other way to accomplish what you need is with ArcObjects. Jeff
... View more
02-10-2014
05:14 AM
|
0
|
0
|
812
|
|
POST
|
Update layer is NOT the ideal function for managing data sources. It was orginally designed to update layer symbology and other layer properties. The doc says that if you set symbology_only = False, then all other properties get overwritten, including the data source. There are several other methods designed specifically for updating data sources. Please review the following help topic. http://resources.arcgis.com/en/help/main/10.2/#/Updating_and_fixing_data_sources_with_arcpy_mapping/00s30000004p000000/ I hope this helps you, Jeff
... View more
01-31-2014
06:39 AM
|
0
|
0
|
653
|
|
POST
|
If the string is always 3 lines and you know exactly where to insert a new line then simply append each line of text with a newline escape character. For example:
str = "line 1 \nline 2 \nline 3" or
str = "line 1" + "\n" + "line 2" + "\n" + "line 3" etc
If you don't know where to break the lines you could try updating a paragraph text element. Or you can try using the Python textwrap function. http://docs.python.org/2/library/textwrap.html Jeff
... View more
01-30-2014
06:01 AM
|
0
|
0
|
5280
|
|
POST
|
It is not in the arcpy.mapping API. It was never a requirement for map automation. Perhaps this is something we can consider for a future release. Please put it on the ideas web site (http://ideas.arcgis.com/). A possible work-around would be using comtypes - a Python module that provides access to ArcObjects from Python. Jeff
... View more
01-23-2014
05:38 AM
|
0
|
0
|
899
|
|
POST
|
A fix will be provided with ArcGIS 10.2.2. If you are interested in tracking the issue, the tracking number is NIM098086. Jeff
... View more
01-22-2014
11:53 AM
|
0
|
1
|
2076
|
|
POST
|
Go to: http://support.esri.com/en/ Then you have an option to contact via email or by phone. Jeff
... View more
01-21-2014
06:52 AM
|
0
|
0
|
5128
|
|
POST
|
Can you please open an incident with technical support so we can evaluate the situtation. Jeff
... View more
01-17-2014
05:11 AM
|
0
|
0
|
5128
|
|
POST
|
I can't see the error in your code. Are you running this from ArcMap? You can NOT create new legends with arcpy.mapping. You can only alter existing legends on a page layout. If you add layers to a data frame, those layers can automatically be added to the legend. You can control column count, positioning, etc Jeff
... View more
01-16-2014
05:46 AM
|
0
|
1
|
2534
|
|
POST
|
The easiest method is to export a layout. Set the layout to be the size of the image your want to create, set the scale, set the data frame to be the size of the layout, and then export to tif. BUT - because you want a geoTiff, you can't export a layout, you must export the Data Frame. You are going to have to manipulate the the df_export_width and df_export_height parameters to achieve the result you want. The help topic talks about this further: "Controlling graphic quality of the generated image differs for page layout exports versus data frame exports. When exporting a page layout, control image detail by changing the resolution parameter. When exporting a data frame, keep the resolution parameter at its default value, and change the df_export_width and df_export_height parameters to alter image detail. The height and width parameters directly control the number of pixels generated in the export file and are only used when exporting a data frame. Images with larger numbers of pixels will have higher image detail. For most page layout exports, the default parameter values should generate good results and nice looking export images on the first try. For data frame exports, you may need to experiment with the df_export_width and df_export_height values a few times before getting the result you want." You want to make sure your data frame in the application is the same aspect ratio as the width/height parameters for export. If your resolution is 96 dpi and you export using the default width/height parameters (640,480) then your image will be 6.6" x 5". So adjust your width/height until you get the desired scale. Jeff Jeff
... View more
01-14-2014
06:18 AM
|
0
|
0
|
2969
|
|
POST
|
You don't need an arcgis online account to download these samples. You are correct about "Show ..." checkbox. The wording and design of the website has changed since this was orginally posted. Thanks, Jeff
... View more
01-13-2014
05:10 AM
|
0
|
0
|
2593
|
|
POST
|
The code sample you have below is identical to the help sample for the Legend Class. I don't see any changes and wonder if your data supports these lines of code. Is this the actual code you are running aginst your data. I'm confused by the error. This line should return a proper legend element, if one exists:
legend = arcpy.mapping.ListLayoutElements(mxd, "LEGEND_ELEMENT")[0]
Jeff
... View more
01-13-2014
05:07 AM
|
0
|
0
|
2534
|
|
POST
|
I would do this using a gp script tool. The tool would have two parameters: Select Mall ID and Select Store ID. The script tool would also have a validation script that would control: when the script tool is first opened, only the Select Mall ID parameter would display a list of mall ids in a parameter pulldown box. Once you select a mall id, then the validation script would display on the Store IDs for that mall. The script tool would then pass the two parameters to the calling python script that would automagically set a layer def query. Here is a sample main python script that the script tool would call. mallID = arcpy.GetParameterAsText(0) #the first parameter in script tool storeID = arcpy.GetParameterAsText(1) #the second parameter in script tool mxd = arcpy.mapping.MapDocument("current") lyr = arcpy.mapping.ListLayers(mxd, "My Mall Layer")[0] lyr.definitionQuery = '"MallID" = ' + str(mallID) + ' AND "StoreID" = ' str(storeID) arcpy.RefreshActiveView() The validation script (a property of the script tool) would look something like: def initializeParameters(self): #THIS IS CALLED WHEN THE SCRIPT TOOL OPENS AND AUTO POPULATES THE FIRST PARAMETER """Refine the properties of a tool's parameters. This method is called when the tool is opened.""" #Generate unique list of Mall IDs import arcpy mxd = arcpy.mapping.MapDocument("CURRENT") mlyr = arcpy.mapping.ListLayers(mxd, "My Mall Layer") fieldName = "MallID" rows = arcpy.SearchCursor(mlyr.dataSource) uniqueMallList = [] for row in rows: if row.getValue(fieldName) not in uniqueMallList: uniqueMall.append(row.getValue(fieldName)) uniqueMallList.sort() self.params[0].filter.list = uniqueMallList return def updateParameters(self): #THIS IS CALLED WHEN THE FIRST PARAMETER IS SELECTED AND POPULATES 2ND PARAMETER """Modify the values and properties of parameters before internal validation is performed. This method is called whenever a parmater has been changed.""" import arcpy if self.params[0].value: #Generate unique list of Store IDs slyr = arcpy.mapping.ListLayers(mxd, "My Store Layer") fieldName = "StoreID" rows = arcpy.SearchCursor(slyr.dataSource) uniqueStoreList = [] for row in rows: if row.getValue(fieldName) not in uniqueStoreList: uniqueStoreList.append(row.getValue(fieldName)) uniqueStoreList.sort() self.params[1].filter.list = uniqueStoreList return This code is untested and I'm sure has some silly typos but all the parts are here. I hope this helps, Jeff
... View more
01-10-2014
05:59 AM
|
0
|
0
|
980
|
|
POST
|
Is it possible for you to send me a simplified map package with your difference layers in it? I'll try to see what is going on. Send to [email protected]. Jeff
... View more
01-10-2014
05:25 AM
|
0
|
0
|
1247
|
|
POST
|
I could reproduce the issue. That for a nicely organized package and script. The original reported bug was resetting the outlines on the graduated color (symbology). This scenario is a little different because it uses graduated symbol (size) but each color is also graduated (its sort of a combination of graduated color and graduated symbol). We are looking into providing a fix. Jeff
... View more
01-09-2014
12:27 PM
|
0
|
0
|
2076
|
| 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 |
a month ago
|