IDEA
|
I don't know if this will help anyone. I haven't tested it out recently, but I have used the tool below to batch export images. https://support.esri.com/en-us/knowledge-base/how-to-batch-export-attachments-from-a-feature-class-in-000017450 I have then used this Powershell script to append the date the image was taken to the end of the image name. $shell = New-Object -ComObject shell.application $usCulture = [Globalization.CultureInfo]'en-US' Get-ChildItem | ForEach{ $folder = $shell.NameSpace($_.DirectoryName) $RawDate = ($folder.GetDetailsOf($folder.ParseName($_.Name),12) -Replace "[^\w /:]") $datetime = [DateTime]::Parse($RawDate,$usCulture) $DateTaken = $datetime.ToString("MM-dd-yyyy") Rename-Item $_.FullName ($_.BaseName + "_" + $DateTaken + $_.Extension)}
... View more
02-21-2024
09:45 AM
|
0
|
0
|
148
|
BLOG
|
@RichardFairhurst, Thank you for the code example. I was able to successfully implement it on a set of test data. The only issue I had was Null Values in the Latest_Status_Date in the Hydrant feature class. I created this field before running the script, so all of them are initially set to Null. When I ran the script I got an error referencing line 45: TypeError: can't compare datetime.datetime to NoneType. Initially, my solution was to simply field calculate a date of 1/1/2000 in the Latest_Status_Date since I knew that there wouldn't be any inspection records before then, and this would give the script a date to compare to. However, I wound up adding an additional OR operation to line 45. So it now looks like: if updateRow[1] is None or updateRow[1] < valueDict[keyValue][0] or updateRow[2] != valueDict[keyValue][1]: As I understand it, this means that if the Latest_Status_Date is Null, then transfer the data from the dictionary anyway if there is any. The use case for this script is essentially to be able to symbolize the latest data from a related table in Field Maps. For example, if the field crew creates a new inspection of a hydrant, and the hydrant needs additional work, I can now create a symbol for that. The script will run every half hour or so to update the hydrant feature class with the latest related data, and I will have a feature service set up to add a ring symbol around any hydrant that has a status of Needs Work. This way the field crew can see visually in Field Maps what Hydrants they need to go back to for additional work in the future without having to click on hydrants and viewing their inspections to see which ones need additional work. Thanks again, Chase
... View more
11-15-2021
08:38 PM
|
0
|
0
|
9078
|
BLOG
|
Hi Richard, Thank you for your in-depth blog on cursors. I've used them in a number of different projects for updating feature classes where the data is one-to-one. I'm wondering if you know of a way to use cursors with related tables. For example, I'm trying to figure out how to search through a one-to-many related table, find the latest related record, and update a field in the related feature class. I have a feature class with a key field called FacilityID, and I have a related table with a key field called HydrantID. One hydrant can have many records in the related table. I would like to search through the related records and find the latest one - I have editor tracking enabled, so I'd probably be able to use the created date or last edited date. In the related table is a status field, and I'd like to find the latest related record, take that status field value, and update a field in the feature class called Latest Status with the status from the related record. Is something like this possible?
... View more
11-09-2021
09:18 AM
|
0
|
0
|
9255
|
IDEA
|
Hi Craig, Is this also true for the ArcGIS Enterprise version of Workforce? I currently have ArcGIS Enterprise 10.9 installed, but I am getting this message when trying to select more than 100 features on the map.
... View more
11-05-2021
11:42 AM
|
0
|
0
|
640
|
POST
|
Thanks for the info Clint. Fortunately, I was able to find a different way to change the data sources. Most of our map files were created by adding the same layer file to each map, so all the layer names were the same in the TOC for every map. So I was able to search each map for a specific lyr.name, and then use lyr.replaceDataSource to change the data source (I just had to write out the instructions for each of the 30 or so feature classes). I should also point out that both the old SDE database and the new SDE database had the same schema. I was simply moving from an old SQL Express database to a full enterprise SQL database.
... View more
04-30-2020
08:40 AM
|
0
|
0
|
753
|
POST
|
Clint, I'm having the same issue, although I'm using SQL Server. Were you ever able to find a solution?
... View more
02-21-2020
06:55 AM
|
0
|
2
|
753
|
POST
|
Thanks Joshua. I will also point out that before I was using this script I was using a script that would search each mxd for the specific layer name, remove the layer, and then add the new layer which had been saved out as a layer file. This process was significantly faster (1-2 minutes per map file vs. 3-5 for replaceDataSource), but the AddLayer function only allowed me to add the layer at the top, bottom, or default in the table of contents. This was problematic because the layer was part of a group layer in some maps, and I didn't want to take it out of the group layer. I also played around with searching for the group layer, removing it, and adding a new group layer that I had saved out as a layer file. However, there was too much variation between all the map files and I didn't want to try and figure out all the different possibilities to script out.
... View more
01-10-2020
08:15 AM
|
0
|
0
|
1221
|
POST
|
Thanks Blake. Most of the maps being updated have hundreds of layers, and I had hundreds of maps to update as well. I was just curious if I had done something wrong in the script that could cause the issue.
... View more
01-10-2020
07:54 AM
|
0
|
0
|
1221
|
POST
|
Hello, I have a python script that will loop through all folders and sub folders in a specified directory searching for mxd's with a specific data source. If the data source is found it will replace that data source with a new one. The script I have works, but it is very slow. I did it on a test folder with 3 sub folders and a total of 9 maps. It took a little over 30 minutes. I am far from an expert on python scripting - is there anything anyone can see that I am doing wrong in my script that might cause it to run slow, or is there a better way to achieve what I'm trying to? Thank you. import arcpy, os, fnmatch, sys
def find(pattern, path=os.getcwd()):
for path, dirs, files in os.walk(path):
for filename in files:
if fnmatch.fnmatch(filename, pattern): yield os.path.abspath(os.path.join(path, filename))
for mxdname in find('*.mxd',r'D:\GIS Projects\TEST'):
mxd=arcpy.mapping.MapDocument(r'{}'.format(mxdname))
print mxdname
for lyr in arcpy.mapping.ListLayers(mxd):
if lyr.supports("DATASOURCE"):
if lyr.dataSource == r"C:\GIS\Cty\2017 Orthos\2017_Orthos.gdb\Orthos_2017":
lyr.replaceDataSource(r"D:\GIS\Cty\Orthos\County_Orthos.gdb", "FILEGDB_WORKSPACE", "County_Orthos")
lyr.name = "County_Orthos"
print 'Replaced Orthos'
mxd.save()
del mxd
... View more
01-09-2020
09:56 AM
|
0
|
4
|
1635
|
Online Status |
Offline
|
Date Last Visited |
a week ago
|