POST
|
Hi all, I've figured out a working solution for this problem. Working code is below. Thank you Marisa and Egge-Jan! # This script prompts a user for an input directory containing MXDs,
# and prompts for an output directory where PDFs are batch exported
# This script exports both normal MXDs and MXDs with data driven pages enabled.
import os, arcpy
# user sets input and output directories
input_dir = arcpy.GetParameterAsText(0)
output_dir = arcpy.GetParameterAsText(1)
arcpy.env.workspace = ws = input_dir
mxdnames = arcpy.ListFiles("*.mxd")
for documentname in mxdnames:
input = os.path.join(ws, documentname)
mxd = arcpy.mapping.MapDocument(input)
output_name = (os.path.join(output_dir, documentname[:-4]) + ".pdf")
if hasattr(mxd, "dataDrivenPages"):
ddp = mxd.dataDrivenPages
ddp.exportToPDF(output_name, "ALL")
arcpy.AddMessage('\t' + str(documentname) + ' DDP enabled mxd exported successfully.')
del mxd
else:
arcpy.mapping.ExportToPDF(mxd, output_name)
arcpy.AddMessage('\t' + str(documentname) + ' exported successfully.')
del mxd
arcpy.AddMessage(('Exports complete!'))
complete = os.startfile(output_dir)
complete
... View more
06-12-2019
06:54 PM
|
3
|
0
|
1627
|
POST
|
Thank you Marisa Claggett and Egge-Jan Pollé for your assistance. I'm so close having this in working order. Now that the map documents are stored in lists, I can't get this to export to the output folder, only to the environment/workspace. Can someone take a look at this and maybe see where my small error is? It has to do with my output directory in the if/else loop.If I fix it one way, it breaks it in another way. I think it has something to do with how map documents are treated, but I'm still a struggling novice. EDIT: Does this issue potentially stem from working with unicode objects instead of MXDs? # Script takes all .mxd files in a user defined directory and
# exports them to another user defined directory
# This script accounts for map documents with data driven pages
import os, arcpy
# user sets input and output directories
input_dir = arcpy.GetParameterAsText(0)
output_dir = arcpy.GetParameterAsText(1)
arcpy.env.workspace = ws = str(input_dir)
list = arcpy.ListFiles("*.mxd")
mxdnames = []
for item in list:
print(str(item))
mxdnames.append(str(item))
print('All Mxds - ' + str(mxdnames))
for mxd in mxdnames:
input = os.path.join(ws, mxd)
mxd = arcpy.mapping.MapDocument(input)
output_name = (os.path.join(output_dir, mxd[:-4]) + ".pdf")
if hasattr(mxd, "dataDrivenPages"):
ddp = mxd.dataDrivenPages
ddp.exportToPDF(output_name, "ALL")
arcpy.AddMessage('\t' + str(mxd) + str(' exported successfully (Data Driven Pages Enabled).'))
del mxd
else:
arcpy.mapping.ExportToPDF(mxd, output_name)
arcpy.AddMessage('\t' + str(mxd) + str(' exported successfully.'))
del mxd
arcpy.AddMessage(('Exports complete!'))
complete = os.startfile(output_dir)
complete
... View more
06-03-2019
01:39 PM
|
0
|
0
|
1627
|
POST
|
My organization has a point dataset with over 1 million records that needs to be symbolized by one of it's attributes (lets call it status). Each week approximately 10,000 statuses of the >1 million need to be updated based on what happened that week. I'm curious if the best method is to simply use the Python API to join based on ID, and calculate? Can I do this more efficiently then joining a such a small change to a large dataset?Am I over complicating this? Visual representation of the dataset below.
... View more
05-08-2019
02:05 PM
|
0
|
0
|
398
|
POST
|
Strangely enough, adding in my templates one at a time solved this issue. I guess you want update multiple templates in one fell swoop. Only one at a time.
... View more
04-17-2019
09:07 AM
|
0
|
0
|
506
|
POST
|
I can think of two examples of how this could be done with Arcade. I would read through KGerrow's blog post on how to intersect data from different layers. A second relevant read that will help you is by xander bakker, who did something quite similar to what you want to do. After you read through that, you will have an idea how to do it and you can use the API documentation to help you put together your code.
... View more
04-17-2019
07:30 AM
|
1
|
0
|
449
|
POST
|
I'm trying to add 5 new feature templates to a list of existing feature templates on a hosted feature layer in ArcGIS Online. I found documentation describing How to Update Your Hosted Feature Service Schemas in ArcGIS Online, but I've had no luck having the additions accepted into the schema. I have successfully validated my additions using JSONLINT, so it's not a syntax issue. When updating the definition I receive no errors, and the feature layer even says 'updated' after I submit them. The problem is that the added feature templates don't show up in the definition. Has anyone else successfully updated feature templates in ArcGIS Online using the update definition route? Is there another way?
... View more
04-17-2019
06:56 AM
|
0
|
1
|
588
|
POST
|
I'm looking to create two lists of mxds, one where data driven pages is enabled, and one where it is not. I have a single directory with 15 mxds inside, where 2-3 have data driven pages enabled. Is there a way for me to create two lists of MXDs based on whether or not ddp is enabled? I couldn't get it to work but I imagine it would look something like this: #need to loop through mxd_list and grab mxds in a directory where ddpIsEnabled. If true the put in list
mxd_list = arcpy.ListFiles("*.mxd",isddpEnabled = False)
ddp_list = arcpy.ListFiles("*.mxd'",isddpEnabled = True)
... View more
04-11-2019
05:47 AM
|
0
|
4
|
1792
|
POST
|
I've written a script to export all mxds in a directory to PDFs. The issue I'm running into is that some of those MXDs have data driven pages enabled, so they export only the first page. As far as I can tell I need to create a list of MXDs that have data driven pages enabled and then loop over that list and export. I get the following error when I run the code below: Traceback (most recent call last): File "C:\Users\XXXX\Documents\ArcGIS\TBX.tbx#BatchExportToPDF.py", line 14, in <module> TypeError: ListFiles() got an unexpected keyword argument 'isddpEnabled' How can I generate a list of mxds with ddp enabled, and a list of mxds without it enabled, and then loop through both of them and get all my MXDs exported ? #Script takes all .mxd files in a user defined directory and
#exports them to the user defined directory
#imports relevant modules
import os, arcpy
#user sets input and output directories
input_dir = arcpy.GetParameterAsText(0)
output_dir = arcpy.GetParameterAsText(1)
arcpy.env.workspace = ws = str(input_dir)
#need to loop through mxd_list and grab docs where variablename.ddpenabled. if true the put in list
mxd_list = arcpy.ListFiles("*.mxd",isddpEnabled = False)
ddp_list = arcpy.ListFiles("*.mxd'",isddpEnabled = True)
for mxd in mxd_list:
#creates variable that opens an arcmap document at input dir + .mxd
current_mxd = arcpy.mapping.MapDocument(os.path.join(ws, mxd))
#creates variable that stores output directory + mxd
pdf_name = (os.path.join(output_dir, mxd[:-4]) + ".pdf")
#exports the mxd to the output folder
arcpy.mapping.ExportToPDF(current_mxd, pdf_name)
arcpy.AddMessage('\t' + mxd + str(' exported successfully.'))
del mxd_list
for mxd in ddp_list:
#creates variable that opens an arcmap document at input dir + .mxd
current_mxd = arcpy.mapping.MapDocument(os.path.join(ws, mxd))
#creates variable that stores output directory + mxd
pdf_name = (os.path.join(output_dir, mxd[:-4]) + ".pdf")
#exports the ddp mxd to the output folder
ddp = current_mxd.dataDrivenPages
ddp.datadrivenpages(pdf_name, "ALL")
arcpy.AddMessage('\t' + mxd + str(' exported successfully.'))
del mxd_list
arcpy.AddMessage(('Exports complete!'))
complete = os.startfile(output_dir)
complete
... View more
04-09-2019
09:05 AM
|
0
|
0
|
748
|
POST
|
Jake, yes exactly. But how does the code tell where to put the ID from buffered layer A into the right field in layer B? In essence what I'm trying to do is this:if I create a new feature B that is within 20 feet of a feature in Layer A, take ID from Layer A and put it in ID for layer B.
... View more
04-05-2019
12:23 PM
|
0
|
2
|
989
|
POST
|
I'm trying to symbolize points by a integer value using unique symbols, but I also need to create data using feature templates on the same layer. If I try to symbolize by the integer value I get a pop-up that says 'this may change the type of objects you can create', and it doesn't allow the use of the templates I created. Why cant you have both uniquely symbolized points and feature templates?
... View more
04-05-2019
12:09 PM
|
0
|
0
|
341
|
POST
|
I was inspired by KGerrow's blog post to autogeneraet some attributes when creating a feature since it could save hundreds of hours of time. I'm looking for some feedback on my methods and code below. My aim is to autopopulate the field of one point feature layer from a field value of another point feature layer when I generate a new feature in a web map. What makes this different than what I have seen is that I have to buffer the point first to make sure the data is joined correctly. I I think I'm missing some key piece of code to put the data from layer A into layer B. When I test Define var A and field I want to extract from Define var B and field I want to put the value into Define var C - which buffers the A 20 feet so when the new feature is created next to it, it pulls the info from A into B. Return Layer A field ID into newly generated feature of Layer B into ID field. var A = FeatureSetByName($map, "A")
var B = FeatureSetByName($map, "B")
var C = Intersects(Buffer($feature, 20, 'feet'), FeatureSetByName($map, "A"))
for (var C in B)
{return C.ID} How do I take the field from the buffered layer C and put it into layer B?
... View more
04-05-2019
10:32 AM
|
0
|
4
|
1133
|
POST
|
Melita, your suggested method in your last post worked absolutely perfectly, you really know your stuff! I cannot thank you enough, this was very important to the success of my project. I have one final question for you. Could you explain why you think I had this projection issue? Is the DEM incorrectly defined in the first place? I just want to know so I understand it for next time this happens 1000 thank-yous, Shelby
... View more
06-02-2016
03:33 PM
|
0
|
1
|
1465
|
POST
|
Hi Melita, thanks for your very quick response, I appreciate your efforts. To answer your questions: The Geonet post you mentioned was a specific case where there was a question about the "true" coordinate system of the DEM. Is your DEM from the same source? No, the DEM was delivered to me in the IMAGINE format, with the ETRS_1989_UTM_Zone_30N Spatial reference. Since the original dataset was for the entire province of Andalucia in Spain, it makes sense that the coordinate system above was used. If you add the original DEM (with a definition of ETRS_1989_UTM_Zone_30N) does it look correctly positioned if you compare it with a base map or other data in "Web Mercator" or geographic coordinates (ETRS 1989 / WGS 1984)? The Polygon in my previous post perfectly lines up with the ridge of ESRI's basemaps (WGS Web Mercator). The DEM exibits the same exact spatial characteristics as in the picture, slightly north of where it should be. What's the offset of the horizontal line in the polygon to the ridge? Im not quite sure what you mean by this. The polygon lines up nicely with the ridge of the basemaps. It doesnt line up well with the ridge of the DEM. The DEM seemed to be about 500 meters offset North-Northeast. I think it only needs to be moved, not warped to fit. What's the coordinate system of the polygon. Specifically, what geographic coordinate system is it using? The coordinate system of the polygon is WGS_1984_UTM_zone_29N which lines up perfectly with the basemap. I've attached results from my own attempt to use the spatial adjustment tool (register raster) to fix it. It's better than before. I'm doing an analysis with half meter resolution ortho imagery, so I really need this to be spot on. I can privately share the DEM (5.5 GB), and the polygon with you if you need it.
... View more
06-01-2016
04:44 PM
|
0
|
3
|
1465
|
POST
|
Task is to project a DEM from ETRS_1989_UTM_Zone_30N to WGS 84 / UTM zone 29N. Easy enough right? Process succeeds, but inaccurately. I have recently read on this ESRI Geonet post by Melita Kennedy that ArcDesktop has issues with this projection because of the following: Some LAEA data uses a sphere rather than an ellipsoid/spheroid which if the metadata isn't correct can cause problems when the data is reprojected. I tried to redefine the projection from ETRS to LAEA like the link above states. No luck.
... View more
05-31-2016
12:51 PM
|
0
|
6
|
5026
|
Title | Kudos | Posted |
---|---|---|
1 | 04-17-2019 07:30 AM | |
3 | 06-12-2019 06:54 PM |
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:24 AM
|