|
POST
|
The excel file is just a copy of the Statistics_analysis table. If you want it in a gdb and XLS, just output of Statistics_analysis to your geodatabase instead of in_memory. You can still copy it to XLS from there; no need for the extra table-to-table process.
... View more
07-19-2017
08:28 AM
|
1
|
1
|
3348
|
|
POST
|
Try this. Hopefully I didn't mess up your other logic. import arcpy
import datetime
import os
mxd = arcpy.mapping.MapDocument("Current")
date = datetime.date.today()
unitedStatesBoundary = arcpy.mapping.ListLayers(mxd, 'United States Boundary')[0]
targetFeature = arcpy.mapping.ListLayers(mxd, 'Target Feature')[0]
mapName = str(mxd.filePath).split('\\')[-1:][0][:-4]
mapFolder = str(mxd.filePath)[:23]
saveLocFS = mapFolder
folderNameFS = "{} UG {} {}".format(mapName[0:7], mapName[8:], date)
df = arcpy.mapping.ListDataFrames(mxd)[0]
stats = []
statesFS = {6:'California'}
statesAbbreviationsFS = {6:'CA'}
statesCDCCode = {6:'California CDC Code'}
for state in statesFS:
valueStatesFS = dict.get(statesFS, state)
valueStatesAbbreviationsFS = dict.get(statesAbbreviationsFS, state)
valueCDCCode = dict.get(statesCDCCode, state)
unitedStatesBoundary.definitionQuery = "Name = '{}'".format(valueStatesFS)
arcpy.RefreshActiveView()
arcpy.SelectLayerByLocation_management(targetFeature,"intersect",unitedStatesBoundary,"","NEW_SELECTION")
mxd.save()
stateMapNameXLS = "{}_{}.xls".format(valueStatesAbbreviationsFS, valueCDCCode)
outXLS = os.path.join(footageReportFolder, footageReportFolderName, stateMapNameXLS)
for field in arcpy.ListFields('Target Feature'):
if field.name == 'TotalFeet':
stats.append(['TotalFeet', "SUM"])
stateMap_stats_inmem = os.path.join("in_memory", "stateMap_stats_inmem")
try:
arcpy.Statistics_analysis('Target Feature', stateMap_stats_inmem, stats)
arcpy.TableToExcel_conversion(stateMap_stats_inmem, outXLS)
finally:
arcpy.Delete_management("in_memory")
... View more
07-18-2017
01:56 PM
|
1
|
4
|
3348
|
|
POST
|
Assign Domain To Field—Help | ArcGIS Desktop This seems to be a similar or duplicate post as https://community.esri.com/thread/198384-how-to-remove-domain-from-field-for-gdb
... View more
07-18-2017
11:28 AM
|
2
|
0
|
1057
|
|
POST
|
I'm a little unclear on your ultimate objective here. You can easily remove a domain from a field. You can also delete the domain from the geodatabase, which also removes it from all fields it was assigned. I also wrote a script that will delete unused domains from a geodatabase. EDIT: Possible duplicate post with https://community.esri.com/thread/198383-how-to-assign-domain-to-field-for-gdb
... View more
07-18-2017
11:17 AM
|
1
|
0
|
6735
|
|
POST
|
Try building the stateMapName as a full path instead of just a table name. If you want it to be a temporary table that is deleted, use in_memory workspace and delete it when finished. If you want to save the output to your custom location, just build the path with the os module.
... View more
07-18-2017
11:12 AM
|
1
|
6
|
3348
|
|
DOC
|
Is this the final document? The last line says Declaring global variable inside an addin class: The colon makes it seem as though there should be some content to follow.
... View more
07-11-2017
08:43 AM
|
0
|
0
|
1508
|
|
POST
|
This is obviously classwork so giving you a direct solution would be unfair. Creating point geometry is pretty straightforward because it's typically just an X and a Y coordinate. Check out the documentation for more information. Point—Help | ArcGIS Desktop
... View more
07-11-2017
08:34 AM
|
0
|
2
|
3885
|
|
POST
|
That is a complex set of conditional statements that should really be on separate lines. However, since your date is already a datetime object, some simple math will determine the quarter. date = datetime.date.today()
quarter = "Q{}".format((date.month-1)//3 + 1)
print quarter
... View more
07-10-2017
11:01 AM
|
1
|
1
|
4603
|
|
POST
|
Shouldn't the else be removed so it will always execute the zf.write() line? Also seems like it should be writing the zip file to the same place os.path.exists() is checking. if os.path.exists(path):
os.remove(path)
zf.write(path, os.path.basename(path))
... View more
07-07-2017
09:26 AM
|
0
|
0
|
3423
|
|
POST
|
Well, well, look at that. Mr. NumPy himself has already built his own Generate Near Table! Thanks Dan Patterson!
... View more
07-06-2017
10:08 AM
|
0
|
0
|
1550
|
|
POST
|
If you can work out a way to get an Advanced license, Generate Near Table is really what you need here because you can specify the closest_count parameter to limit the number of results. This will probably improve performance. Because you're not really doing much "processing" with the data, using dictionaries isn't likely to speed it up too much. However, you could try replacing the insert cursor with something that builds a numpy array and then use NumPyArrayToTable to create the final output table.
... View more
07-06-2017
08:46 AM
|
0
|
2
|
1550
|
|
POST
|
We're currently preparing to upgrade to 10.5.1 so I'm interested to see how this turns out.
... View more
07-05-2017
12:30 PM
|
1
|
0
|
4171
|
|
POST
|
Your append2Zip() function is using the zipfile module, which isn't affected by arcpy.env. You probably need to use the os module to check if the file/directory exists, then delete it before creating the new zip file.
... View more
07-05-2017
12:19 PM
|
1
|
5
|
3423
|
|
POST
|
Stefan Chapkanski wrote: Note that I am not rebuilding the composite locator, because it is only a reference to the simple ones. I should mention some additional steps I did before compiling my models. I went to the AGS system directory (through ArcMap) checked the locators, and manually run rebuild function just to be sure everything is OK. I needed to make a change of the reference data location by pointing to the original GDB (registered in AGS). Apologies if I'm misunderstanding your process, but I don't think you can simply rebuild the underlying locators of a composite locator. You have to recreate the composite locator each time a participating locator is rebuilt. Rebuild Address Locator—Help | ArcGIS Desktop Composite address locators cannot be rebuilt using this tool. The best practice for managing composite locators is to create a composite locator using the Create Composite Address Locator tool in a geoprocessing model. In ModelBuilder, you can also chain the tool with the Create Address Locator tool to use its outputs as the inputs to the composite locator and manage the entire process of creating or updating a composite address locator.
... View more
07-05-2017
11:50 AM
|
0
|
1
|
4193
|
|
BLOG
|
Although completely unrelated to your post, thank you for turning me onto sys.prefix and the ".." symbolic path. Not sure I have an immediate use for such a thing, but still kinda cool!
... View more
07-03-2017
10:04 AM
|
0
|
0
|
4777
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 07-10-2026 07:32 AM | |
| 1 | 10-23-2025 03:53 PM | |
| 1 | 04-28-2026 07:25 AM | |
| 1 | 03-19-2026 08:59 AM | |
| 1 | 02-12-2026 01:37 PM |