Skip to content

Commit 9a35637

Browse files
author
tiffanychu90
committed
Add notes to arcgis steps
1 parent 8cb49a7 commit 9a35637

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

open_data/arcgis_script.py

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,13 @@
3535
# Export metadata using FGDC
3636
translator = directory + 'Metadata\Translator\ArcGIS2FGDC.xml'
3737

38-
# Convert shapefile layer to gdb feature class
38+
## (1) Convert shapefile layer to gdb feature class
3939
for f in in_features:
4040
# construct the filename, which is takes form of routes_assembled/routes_assembled.shp
4141
shp_file_name = f + '/' + f + '.shp'
4242

43-
# Need this try/except because arcpy won't let you overwrite, and will error if it finds it
43+
# Need this try/except because arcpy won't let you overwrite,
44+
# and will error if it finds it
4445
try:
4546
arcpy.management.Delete(staging_location + '/' + f)
4647
except:
@@ -57,7 +58,9 @@
5758
print(field.name)
5859

5960

60-
# Rename fields
61+
## (2) Rename fields where needed
62+
# Do this once it's a feature class, so we can preserve the new column names
63+
# before metadata is created
6164
need_renaming = [
6265
'ca_hq_transit_areas',
6366
'ca_hq_transit_stops',
@@ -90,6 +93,7 @@
9093
field.name, RENAME_CA_HQTA[field.name])
9194

9295

96+
## (3) Export metadata associated with file gdb feature class in FGDC format
9397
for f in in_features:
9498
# Construct XML filename
9599
# Spit out one that's before it's manually changed
@@ -101,10 +105,12 @@
101105

102106

103107

104-
### UPDATE XML METADATA SEPARATELY IN PYTHON OUTSIDE OF ARCGIS
108+
### (4) UPDATE XML METADATA SEPARATELY IN PYTHON OUTSIDE OF ARCGIS
105109

106-
# Run this after putting the updated XML in the file gdb
107-
# Clean up the open_data file gdb
110+
## (5) Copy the feature class from staging location to out location
111+
# In the out location, we can drop the new XML and use it to sync
112+
# Use staging location and out location because otherwise, arcpy errors when it detects
113+
# another XML when you try and update the layer in a subsequent update
108114
for f in in_features:
109115
# Delete the feature class in this gdb, because we don't want _1 appended to end
110116
try:
@@ -117,7 +123,7 @@
117123
out_location + '/',
118124
f)
119125

120-
126+
## (6) Sync the XML with the feature class
121127
for f in in_features:
122128
# This is the one after it's manually changed. Keep separate to see what works.
123129
updated_xml_file = out_location + '/' + f + '.xml'
@@ -129,8 +135,9 @@
129135
"ENABLED")
130136

131137

132-
# Clean up XML file in staging.gdb
133-
# If not, next time, it will error because it can't output an XML file when one is present (no overwriting)
138+
## (7) Clean up XML file in staging.gdb
139+
# If not, next time, it will error because it can't output an XML file
140+
# when one is present (no overwriting)
134141
for f in in_features:
135142
try:
136143
os.remove(xml_file)

0 commit comments

Comments
 (0)