|
POST
|
I haven't tried it yet but I guess what I'm trying to do is change the dataset for a layer but do it for every MXD's. Does that make sense. Maybe you already knew that... Either way I'm looking at your code. Thanks Thats what the code is designed to do. The only changes that need to be made are setting the workspace and the workspace path for the new dataset for your layers. It makes a list of all mxds in the workspace, then goes in and changes the workspace paths for all layers in the map document to the workspace path of your new dataset.
... View more
07-03-2014
11:33 AM
|
1
|
0
|
4799
|
|
POST
|
sure thing
#Importing Modules
import arcpy
from arcpy import env
#Put file path for the folder containing mxds, where I have my sample file path
env.workspace = r"C:\Test\MXDfolder"
#Put file path for the folder, gdb, feature dataset, or sde connection containing the files your map layers will be referencing here, where I have my sample file path
replace_workspace_path = r"C:\Test\NewWorkspace"
#Looping through all filepaths in our workspace, make a map document object out of them, then replace their workspace path
for file in arcpy.ListFiles("*.mxd"):
mxd = arcpy.mapping.MapDocument(file)
mxd.findAndReplaceWorkspacePaths(" " , replace_workspace_path)
mxd.save()
del file; del mxd
So the script makes a list of the filepaths for each mxd, then loops through them, creates a python map document object, which we then call the findandReplaceWorkspacePaths method on to replace the workspace path for all layers in the map documents. I haven't tested this on anything, and there could be a few errors to debug, but it should be enough to get started. Always feel free to search the arcgis help for any method that you have questions about.
... View more
07-02-2014
11:59 AM
|
1
|
0
|
4799
|
|
POST
|
Thanks for the python nugget Mark, I thought that my suggestion was a bit too simple, but it was the only thing that struck me when i looked at it.
... View more
07-02-2014
11:23 AM
|
0
|
0
|
1061
|
|
POST
|
If your maps are in the same folder, then there are easy ways to iterate through all your map documents in a folder. If you set your workspace to the folder they are in, then use the arcpy.ListFiles("*.mxd"), you will make a list of all the map documents in the folder. You can then loop through them and put in the code for findandreplaceworkspace. If you have multiple workspaces, you can loop through workspaces as well with ListWorkspaces. Check out this link for help with ListFiles, there is also a link to ListWorkspaces in there. If you have any further questions about this, feel free to ask.
... View more
07-02-2014
10:49 AM
|
1
|
0
|
4799
|
|
POST
|
This can be done fairly easily using python and the arcpy.mapping module. For the layers, there is a method to replace the data source with a new file path, or can be done for the entire map document, say if the data sources for all layers have changed folders or something similar. Check out this link Hope this helps
... View more
07-02-2014
08:59 AM
|
0
|
0
|
4799
|
|
POST
|
It may or may not be this simply but if lyr.supports("WORKSPACEPATH"): might need to be if lyr.supports("WORKSPACEPATH") == True: since the support method returns a Boolean data type. Currently you are not actually checking it against anything for the if statement.
... View more
07-02-2014
08:04 AM
|
0
|
0
|
1061
|
|
POST
|
try
out_coor = "PROJCS['WGS_1984_UTM_Zone_18S',GEOGCS['GCS_WGS_1984',DATUM['D_WGS_1984',SPHEROID['WGS_1984',6378137.0,298.257223563]],PRIMEM['Greenwich',0.0],UNIT['Degree',0.0174532925199433]],PROJECTION['Transverse_Mercator'],PARAMETER['False_Easting',500000.0],PARAMETER['False_Northing',10000000.0],PARAMETER['Central_Meridian',-75.0],PARAMETER['Scale_Factor',0.9996],PARAMETER['Latitude_Of_Origin',0.0],UNIT['Meter',1.0]]"
from the tool help: The coordinate system to which the input raster will be projected. The default value is set based on the Output Coordinate System environment setting. Valid values for this parameter are A file with the ".prj" extension (the prj files which ship with ArcGIS can be found in "C:\Program Files\ArcGIS\Coordinate Systems"). An existing feature class, feature dataset, raster catalog (basically anything with a coordinate system). The string representation of a coordinate system. These lengthy strings can be generated by adding a coordinate system variable to ModelBuilder, setting the variable's value as desired, then exporting the model to a Python script. I generated this from model builder by making a new coordinate system variable and selecting the one you needed.
... View more
07-02-2014
07:02 AM
|
0
|
0
|
1006
|
|
POST
|
Here is a REALLY old thread I found, the only one I could find discussing converting to .dem(apparently the USGS specific DEM format). Hopefully that can help you out. Guess I'm too new to GIS to know about .dem
... View more
07-01-2014
02:34 PM
|
0
|
0
|
3314
|
|
POST
|
A DEM is a raster, just the raster values are the elevation data. So you should more or less have what you need(though you may want to rerun it so your raster has a different file type such as a .tiff, if you are saving it not in a gdb that is). You shouldn't need it to have a .dem extension.
... View more
07-01-2014
11:28 AM
|
0
|
0
|
3314
|
|
POST
|
To make a script tool, go to the toolbox you want in the catalog, and select add(not new, though you would think new would make sense right?), then script. I cut down my script a bunch, trying to make it closer to what you need. I'd do some reading up on script tools, tool parameters, so you can create your tool.
#Importing Modules
import arcpy
#Declaring Variables
ID = arcpy.GetParameterAsText(0)
OutputLocation = arcpy.GetParameterAsText(1)
#Assembling Map - Selecting MXD, Dataframe, and Selecting Layer by Attribute
#Creating a Map Document Object within python, referencing the .mxd you want to work with.
mxd = arcpy.mapping.MapDocument(r"put filepath to your map here")
#Once you have a map document object in python, you can access its various elements, now we need to access the dataframe the layer you are using is in.
#The line of code below makes a list of all the dataframes in the map document object we made. The [0] returns the first dataframe in our map document,
#if you need to access additional dataframes, you would use a different index, we now have made a dataframe object in python and can access the layers in it
df = arcpy.mapping.ListDataFrames(mxd,"*")[0]
#Now to Create a Layer Object, the line of code below returns a list of all the layers in the dataframe, with this name. The [0] returns the first layer with that name instead of the whole list
Layer = arcpy.mapping.ListLayers(mxd, "Your Layer Name here", df)[0]
#Selecting by Attribute, Zooming to Feature, and Setting Scale
#This line performs a select by attribute on our Layer object, using a new selection, with an SQL query of ID = the ID variable we created using getparameterAsText(0)
arcpy.SelectLayerByAttribute_management(Layer, "NEW_SELECTION" , "ID = " + ID)
scales = [scale 1 here , scale 2 here, scale 3 here]
for scale in scales:
#Selecting by Attribute, Zooming to Feature, and Setting Scale
#This line performs a select by attribute on our Layer object, using a new selection, with an SQL query of ID = the ID variable we created using getparameterAsText(0)
arcpy.SelectLayerByAttribute_management(Layer, "NEW_SELECTION" , "ID = " + ID)
#This zooms the dataframe to the selected feature
df.zoomToSelectedFeatures()
df.scale = scale
#Clearing selected features so they do not show up selected on map
arcpy.SelectLayerByAttribute_management(Layer, "CLEAR_SELECTION")
#Exporting map dataframe view to pdf, I have it set up to save
arcpy.mapping.ExportToPDF(mxd, OutputLocation + ID + scale + ".pdf", "Page_Layout", 640, 480)
#Cleaning out memory by deleting the python objects
del mxd; del df, del Layer
When you make the script tool, you will need to define a few input parameters, for the ID number you want and for the Output folder where you want the file, you might want one for the file name as well. THe arcpy.GetParameterAsText takes input from the tool to be used in the script. Edit: Ah heck, I went ahead and make the tool for ya, you will need to edit a few lines in the code, but otherwise should be good Edit Edit: Add the last line from the code on this thread to your script tool, by right clicking on it and selecting edit on the script tool
... View more
07-01-2014
11:19 AM
|
3
|
18
|
6323
|
|
POST
|
It can be done with arcpy using the arcpy.mapping module. http://resources.arcgis.com/en/help/main/10.2/index.html#//00s300000032000000 Hopefully, all your maps are in the same folder(or at least have a similar root folder), and you can loop through each map document, select the dataframe that layer is in, find that layer then change the symbology. If the layer is named the same(or have a name that is similar) in all the map documents, this should be a fairly easy process.
... View more
07-01-2014
10:29 AM
|
0
|
0
|
670
|
|
POST
|
Sorry I stole that multipoint solution from another thread, and didn't check for the actual tool That thread can be found here. http://gis.stackexchange.com/questions/78961/proper-workflow-for-las-to-dem-conversion Apparently it takes a few tools to build a terrain, see this link. http://resources.arcgis.com/en/help/main/10.2/index.html#//005v0000001p000000 Do you only have multipoint files, or could you obtain the .las files?
... View more
07-01-2014
10:09 AM
|
0
|
0
|
3314
|
|
POST
|
Hi Scott, If you have multipoint files, the best way I know to make a raster is to use multipoint to terrain tool, then terrain to raster. If you need to have them tiled together, I would create a mosaic dataset, then you can add each of your raster DEMs to the mosaic dataset. If you have actual .las files, you can add those directly to a mosaic dataset, or add them to a las dataset (.lasd) and use that to generate your dem. I'm not overly familiar with the multipoint route, I prefer .lasd usually, since it makes it easier to handle the points and returns, and I'm not sure of a way to convert back from multipoint to a las file. If anyone else has some good input, I'd love to here it. http://resources.arcgis.com/en/help/main/10.1/index.html#/A_quick_tour_of_lidar_in_ArcGIS/015w00000066000000/ http://resources.arcgis.com/en/help/main/10.1/index.html#//009t0000003p000000
... View more
07-01-2014
09:29 AM
|
2
|
0
|
3314
|
|
POST
|
This would probably be a python script, and from your description, you'd probably want to make a script tool, so you have an interface where you enter the ID field you want, and probably define your output name and location for the pdfs. You can do everything you want in regards to zooming to the the selected ID using the arcpy.mapping module. I have a script similar to what you need if you need a good starting point to work from, though when you say little to no programming knowledge, how little is that? The script I had need to zoom to a polygon that was added to my template map then zoom out a selected amount from that initial zoom and then export it to a pdf, while changing a few text elements in the map along the way(probably not what you need, other than the zooming to and setting scale.)
... View more
07-01-2014
08:18 AM
|
1
|
0
|
6323
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 02-22-2017 08:58 AM | |
| 1 | 10-05-2015 05:43 AM | |
| 1 | 05-08-2015 07:03 AM | |
| 1 | 10-20-2015 02:20 PM | |
| 1 | 10-05-2015 05:46 AM |
| Online Status |
Offline
|
| Date Last Visited |
11-11-2020
02:23 AM
|