|
POST
|
Researching to see if there is a way to use Python to export multiple tables in a File Geodatabase to a single Excel file. I would like for each sheet name to have the same name as the table. My current situation is that I ran a Python script to take all the domains a GDB and create a table within the GDB. The article referenced from: https://community.esri.com/thread/163889 def main():
import arcpy, os
gdb = r"Z:\GIS_Projects\zUpdatesBrian\Scripts\ListDomains\ListDomains.gdb"
arcpy.env.overwriteOutput = True
for dom in arcpy.da.ListDomains(gdb):
if dom.domainType == 'CodedValue':
arcpy.DomainToTable_management(in_workspace=gdb,
domain_name=dom.name,
out_table=os.path.join(gdb, dom.name),
code_field="item",
description_field="descrip",
configuration_keyword="")
print " - domain '{0}' of type '{1}' exported to table".format(dom.name, dom.domainType)
else:
print " - domain '{0}' of type '{1}' skipped".format(dom.name, dom.domainType)
if __name__ == '__main__':
main()
... View more
05-16-2018
09:05 AM
|
0
|
11
|
7661
|
|
POST
|
I received a table of data, and in that table is a field with latitude and longitude coordinates in one field. An example is: 45.4000/-122.700 I added two fields, latitude and longitude. Using field calculator I can successfully extract values after the '/' into the longitude field so that it is populated only with -122.700. The expression is: !Latitude_Longitude![!Latitude_Longitude!.rindex('/')+1:] I am not able to extract the values for latitude so that the latitude field will be populated just with 45.4000. I can also not perform this by using an exact number of characters, as the table of coordinates can have anywhere from 2 to 5 decimal places. Any help on how to extract all values to the left of the '/' would be appreciated.
... View more
05-09-2018
03:49 PM
|
0
|
1
|
1458
|
|
POST
|
This was not resolved as our project decided to export PDFs manually instead of via Python. This is because the number of pages per each location relates to the number of stories at a building, which involves exporting PDF for floor 1, checking off floor 1 and checking on floor 2, exporting, so on.
... View more
04-19-2018
02:17 PM
|
0
|
0
|
1704
|
|
POST
|
In several MXDs, I have symbology displayed based on a rotation field. In each MXD, I rotate the data frame based on the site plan. When I export to a PDF within ArcMap, the symbols stay rotated as they should. I have already gone into ArcMap Advanced Settings Utility and checked off Rotate marker symbols with dataframe. Sample when exporting to PDF from ArcMap: When I use arcpy.mapping.ExportToPDF, the PDF exports correctly, but it will not honor the rotation. I would like to use Python because I have several dozen MXDs that will be updated on a monthly basis. Sample when using arcpy.mapping.ExportToPDF Sample Code: import arcpy, os
folderPath = r"J:\GIS\PrePlans"
for filename in os.listdir(folderPath):
fullpath = os.path.join(folderPath, filename)
if os.path.isfile(fullpath):
basename, extension = os.path.splitext(fullpath)
if extension.lower() == ".mxd":
mxd = arcpy.mapping.MapDocument(fullpath)
mapPath = mxd.filePath
fileName = os.path.basename(mapPath)
print "Exporting " + fileName
txtFile.write("Exported " + fileName +'\n')
arcpy.mapping.ExportToPDF(mxd, basename + '.pdf')
... View more
01-12-2018
02:32 PM
|
0
|
5
|
2105
|
|
POST
|
From a prior posting here, I was looking for a solution on how to turn the relative path on in batch. The solution generated will grab any MXD in a root folder and enable the relative paths to be turned on in any sub folder using this code: import os
from glob import glob
import arcpy
PATH = r'C:\Users\mclbr\Desktop\GIS_Maintenance'
arcpy.env.workspace = PATH
result = [y for x in os.walk(PATH) for y in glob(os.path.join(x[0], '*.mxd'))]
for map in result: # map will be complete path to map file
print "Processing: {}".format(map) # keep track of what's happening
mxd = arcpy.mapping.MapDocument(map)
#set relative paths property
mxd.relativePaths = True
#save map document change
mxd.save() One issue that I have come across is that we have users on 10.2.2 and users on 10.3.1. The code above works on 10.3.1, but when run it updates all 10.2.2 MXDs to 10.3.1. The other issue is that when run on a 10.2.2 machine, the script will fail once it reaches an MXD that was last saved in 10.3.1. I am taking a shot in the dark, but would anyone know of a way to create code that will only select versions of ArcGIS Desktop for version 10.2.x, then one for 10.3.x? If that is possible, I would run the routine on a 10.3.1 machine and insert the code to only update MXDs that are a 10.3.1 document, and do the same for the 10.2.2 machine and documents.
... View more
12-01-2017
11:48 AM
|
0
|
3
|
1714
|
|
POST
|
So combined code would be: import os
import arcpy, os
from glob import glob
PATH = r'C:\Users\mclbr\Desktop\GIS_Maintenance'
result = [y for x in os.walk(PATH) for y in glob(os.path.join(x[0], '*.mxd'))]
for mxd in result:
print mxd # continue here with processing your files
import arcpy, os
#workspace to search for MXDs
Workspace = r"C:\Users\mclbr\Desktop\GIS_Maintenance"
arcpy.env.workspace = Workspace
#list map documents in folder
mxdList = arcpy.ListFiles("*.mxd")
#set relative path setting for each MXD in list.
for file in mxdList:
#set map document to change
result = os.path.join(Workspace, file)
mxd = arcpy.mapping.MapDocument(filePath)
#set relative paths property
mxd.relativePaths = True
#save map doucment change
mxd.save()
... View more
11-29-2017
03:22 PM
|
0
|
2
|
1992
|
|
POST
|
I have a series of strings that I need to eliminate a series of text. The text can be variable in length, so doing any trim or strip functions will not work. The string is: <img src="X:\UB_Routing\images\ServiceOrders\150 E MAIN ST.png"><br>150 E MAIN ST or <img src="X:\UB_Routing\images\ServiceOrders\3207 SE ROSESPRING DR.png"><br>3207 SE ROSESPRING DR As a few examples, but they can be any address. I am looking for a Python field calculator solution to remove everything before and including the value of <br> From the examples above, the only values left would be: 150 E MAIN ST 3207 SE ROSESPRING DR
... View more
11-29-2017
01:13 PM
|
0
|
5
|
21064
|
|
POST
|
I am trying to find a way to set relative paths in MXDs using Python for several sub folders within a main folder. Using this Tech Support article, it allows it to be done on MXDs in the folder listed as the workspace. What I am looking for is not only the folder listed in the workspace, but MXDs that exist in subfolders. The goal would be for the Python to open all MXDs under the parent folder and subfolder, check on Set Relative Path Name, Save and Close MXD.
... View more
11-29-2017
10:57 AM
|
0
|
4
|
2585
|
|
POST
|
Seems like the XSL style sheet allows for some formatting. I might need to work my team for an SRSS report or something similar about modifying the HTML output.
... View more
09-18-2017
04:07 PM
|
0
|
0
|
1010
|
|
POST
|
I am using Model Builder to route water meter shut offs and services for a daily route. The output is an HMTL document with the directions. I have not found a way to add the map at each stop for the GP Tool located at Network Analyst Tools \ Analysis \ Directions. I know that you can add maps from the Directions tool on the Network Analyst toolbar, however I am trying to find this option on a more automated approach in Model Builder or Python.
... View more
09-12-2017
11:47 AM
|
0
|
3
|
1189
|
|
POST
|
Checking the values of the Oneway field worked. Before, if the street allowed travel in both directions the value was NULL. I updated my data to show that if the street allows travel in both directions, a 'B' value gets populated in the Oneway field. Than you for your help.
... View more
09-07-2017
09:55 AM
|
1
|
0
|
4594
|
|
POST
|
Confirmed that the Oneway Parameters are set to Prohibited. I tried changing the Field Evaluators to: Pre-Logic Script Code: restricted = False Select Case UCase([Oneway]) Case "N","TF","T":restricted = False End Select Value = Restricted Still the same results of not honoring oneway field.
... View more
09-07-2017
08:37 AM
|
0
|
0
|
4594
|
|
POST
|
I have built a network dataset with a oneway field to honor one way travel directions step for step from the tutorials: - http://support.esri.com/en/technical-article/000008060 Image 01.JPG shows an sample area of my data before any route is performed with the oneway field digitized with directional arrows. Image 02.JPG displays stop 1 on the right side and stop 2 on the left side. By the arrows, the route should go around the block the long way, however the oneway field is not being honored it is showing the shortest route. This violates the oneway restriction. Image 03.JPG displays my Network Dataset Properties Attributes tab, then the Evaluators, then the Field Evaluators for the Oneway attribute. My Field Evaluators are set up as: Pre-Logic Script Code:
restricted = False
Select Case UCase([Oneway])
Case "N","TF","T":restricted = True
End Select
Value:
restricted For the other oneway, just switch "TF" to "FT". Any help would be appreciated.
... View more
09-06-2017
04:47 PM
|
0
|
4
|
5380
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | Wednesday | |
| 5 | 12-10-2025 03:48 PM | |
| 1 | 12-10-2025 12:19 PM | |
| 1 | 11-13-2025 07:02 AM | |
| 2 | 12-08-2025 08:14 AM |
| Online Status |
Offline
|
| Date Last Visited |
yesterday
|