|
POST
|
I'm not sure how this would work with personal geodatabase The solution is to stop using Personal Geodatabases!
... View more
08-06-2015
10:50 AM
|
2
|
1
|
2365
|
|
POST
|
Yes, that's exactly what I was getting at. Thanks for taking the time to put that together, Ian.
... View more
08-04-2015
04:42 PM
|
0
|
0
|
4388
|
|
POST
|
Xander Bakker had a great suggestion for me (here) to use the Add Geometry Attributes tool. I found that if you copy the data to an in memory workspace, it calculates the geometry more quickly, then you can export the result.
... View more
08-04-2015
09:39 AM
|
2
|
0
|
1199
|
|
POST
|
You can use both, I think Greg Keith just forgot to add it in his code sample. with arcpy.da.UpdateCursor(fc,["Shape@XY","Latitude"]) as ucur:
for row in ucur:
x,row[1] = row[0]
ucur.updateRow(row)
... View more
08-04-2015
09:28 AM
|
2
|
1
|
3196
|
|
POST
|
When I set the environment on the second GDB, I lose access to the feature classes in the first GDB. Could you clarify exactly what you're experiencing here? As long as you have the file name and path for the feature class, you can always "access" it. Setting the environment workspace or using ListFeatureClasses() doesn't cause the feature class to be unavailable to anything. You should be able to use any of the suggestions from Ian Murray.
... View more
08-04-2015
09:22 AM
|
0
|
4
|
4388
|
|
POST
|
I'm running into this issue to (started with AttributeError: 'NoneType' object has no attribute 'dataFrames'). From my testing, it looks like it has to do with older MXD's (mine was from around 2010) that have something that's somehow not compatible with the arcpy stuff. I tried Save As and Save a Copy and the problem persisted. Copying and pasting the dataframe doesn't work either. However, if I create a new dataframe in the MXD and copy the layers into it and delete the old data frame, it works fine; so it can't be something with the MXD in general. I think the solution is to print the MXD path and try to manually fix the dataframe(s) in there before continuing. If you have a lot of MXD's and touching each one isn't reasonable, the next best solution is probably what Stacy Rendall mentioned about using a try, except block to catch the AttributeError exception and skip that MXD if there's an error. Not the cleanest, but it works. try:
# Do stuff with MXD using arcpy.mapping
except AttributeError:
print "This MXD has unreadable dataframes\n{}".format(mxd.filePath)
pass
... View more
08-03-2015
05:18 PM
|
0
|
1
|
2274
|
|
POST
|
I don't have any experience with Workflow Manager, sorry. Maybe you can find something useful from this Esri blog post? Leveraging Geoprocessing in ArcGIS Workflow Manager – Part 2 | ArcGIS Blog
... View more
08-03-2015
02:03 PM
|
0
|
0
|
741
|
|
POST
|
The Esri support technician did try this though. It makes sense and would be a logical first step.
... View more
07-31-2015
04:18 PM
|
0
|
0
|
6284
|
|
BLOG
|
I just fixed a little bug with my code. The tempConn variable I'm assigning to arcpy.CreateDatabaseConnection_management() is actually a result object (even though it prints the full path to the connection file). Although it works with describe workspace, it fails when trying to use it in os.path.join() with RuntimeError: ResultObject: Error in getting output. You just need to format it as a string with tempConn = str(tempConn) I'll update the code in my original post. I also managed to use tempfile.NamedTemporaryFile() to generate a unique file name to use: with tempfile.NamedTemporaryFile(dir=tempDir, delete=True)as temporaryFile: tempFileDir, tempFileName = os.path.split(temporaryFile.name) Then just concatenate the tempFileName with the ".sde" extension when you create the connection. Alternatively, you could also specify the suffix parameter when you create the file name, but I decided to keep it separate.
... View more
07-31-2015
09:45 AM
|
0
|
0
|
2798
|
|
POST
|
With the suggestions posted so far and the example posted in the Clip Analysis Help, you should be able to get started. Here's what the list and the for loop might look like... clip_features = [
'Lake_Ontario_Plains_FDRA_Boundary',
'Another_FDRA_Boundary',
'Some_FDRA_Boundary',
'Other_FDRA_Boundary'
]
for fc in clip_features:
out_feature_class = in_features+fc ## Naming is up to you
arcpy.Clip_analysis(in_features, fc, out_feature_class)
... View more
07-28-2015
09:47 AM
|
0
|
0
|
3282
|
|
POST
|
I believe these orphaned table names in the Table_Registry were caused by dropping the table or view from Toad instead of ArcCatalog. After speaking with Esri support, they recommended cleaning this up by following these steps: Identify "layer_id" for "table_name" in the SDE_LAYERS table Identify "Registration_ID" for "table_name" in the SDE_TABLE_REGISTRY table Identify "ID" for "Name" in the GDB_items table Identify "g_table_name" for "f_table_name" in the SDE_GEOMETRY_COLUMNS table Delete "f" and "s" tables for "g_table_name" found in Step 4. If "f" table is "f22" then "s" table is "s22". Delete entry for "Name" in GDB_Items. Delete entry for "f_table_name" in SDE_GEOMETRY_COLUMNS Delete entry for "table_name" in SDE_LAYERS Delete "i" table for "Registration_ID" (Step 4) Remove all "table_name" entries in "SDE_COLUMN_REGISTRY". Remove "table_name" entry in "SDE_TABLE_REGISTRY" ArcGIS Help 10.2 - System tables of a geodatabase stored in Oracle Basically, go through these six system tables and delete any rows that reference the object you are trying to delete. SDE.LAYERS SDE.TABLE_REGISTRY SDE.COLUMN_REGISTRY SDE.GDB_ITEMS SDE.GEOMETRY_COLUMNS SDE.COLUMN_REGISTRY
... View more
07-28-2015
09:29 AM
|
4
|
5
|
6284
|
|
POST
|
Here's what I've come up with so far for Rebuild Indexes and Analyze Datasets. Looks at SDE.Table_Registry to get all schema owners and compiles it into a Python list. Creates a temporary directory in which to create temporary connection files as each schema owner. If the owner is SDE, then it uses an existing connection and sets the include_system parameter to gathered on the states and state lineages tables (which can only be done as an admin. Otherwise the other owners use the NO_SYSTEM option. Once a connection file is made, it gathers the name of all visible tables for that owner into a Python list. Then it runs Rebuild Indexes and Analyze Datasets using the visible tables list as input for the in_datasets parameter. import arcpy
from contextlib import contextmanager
import os
import shutil
import tempfile
def main():
try:
sdeInstance = "GTEST"
# Get all schema owners from SDE table registry
sde_sdeconn = r"C:\GISConnections\SDE@{}.sde".format(sdeInstance)
in_table = os.path.join(sde_sdeconn, "SDE.TABLE_REGISTRY")
sql_prefix = "DISTINCT OWNER"
schemaOwners = [
row[0] for row in arcpy.da.SearchCursor(
in_table,
"OWNER",
sql_clause=(sql_prefix, None)
)
]
# Rebuild indexes and update statistics for all objects under each schema owner
with makeTempDir() as temp_dir:
for owner in sorted(schemaOwners):
print "\n---\n"
## Set passwords, options, and workspace with owner
if owner.upper() == "SDE":
## Must be geodatabase administrator to gather statistics on
## the states and state lineages tables (include_system option).
include_system = "SYSTEM"
arcpy.env.workspace = sde_sdeconn
else:
## Create connection file with owner
arcpy.CreateDatabaseConnection_management(
temp_dir, ## out_folder_path
owner+".sde", ## out_name
"ORACLE", ## database_platform
sdeInstance+".WORLD", ## instance
"DATABASE_AUTH", ## account_authentication
owner, ## username
ownerPass, ## password
)
print arcpy.GetMessages()
include_system = "NO_SYSTEM"
arcpy.env.workspace = os.path.join(temp_dir, owner+".sde")
# Get a list of all the objects owner has access to
workspace = arcpy.env.workspace
tables = arcpy.ListTables(owner+'.*')
tables += arcpy.ListFeatureClasses(owner+'.*')
tables += arcpy.ListRasters(owner+'.*')
for dataset in arcpy.ListDatasets(owner+'.*'):
tables += arcpy.ListFeatureClasses(feature_dataset=dataset)
try: # Rebuild Indexes
arcpy.RebuildIndexes_management(
workspace, ## input_database
include_system,
tables,
"ALL"
)
except Exception as err:
## Print exception error only if it's not from Esri
if not arcpy.GetMessages(2):
print err
finally:
if arcpy.GetMessages():
print arcpy.GetMessages()
try: # Analyze Datasets
arcpy.AnalyzeDatasets_management(
workspace, ## input_database
include_system,
tables,
"ANALYZE_BASE",
"ANALYZE_DELTA",
"ANALYZE_ARCHIVE"
)
except Exception as err:
## Print exception error only if it's not from Esri
if not arcpy.GetMessages(2):
print err
finally:
## Print the full details of the last Esri message
if arcpy.GetMessages():
print arcpy.GetMessages()
arcpy.ClearWorkspaceCache_management()
except Exception as err:
if err.message in arcpy.GetMessages(2):
print arcpy.GetMessages()
else:
print unicode(err).encode("utf-8")
finally:
# Cleanup
arcpy.ClearWorkspaceCache_management()
@contextmanager
def makeTempDir():
temp_dir = tempfile.mkdtemp()
try:
yield temp_dir
finally:
shutil.rmtree(temp_dir)
if __name__ == '__main__':
main() It seems to be doing its job, but I don't see any entries in the SDE.SDE_LAYER_STATS table; should I? Eventually this will get rolled into our existing SDE maintenance script that disconnects users then reconciles and compresses.
... View more
07-24-2015
04:38 PM
|
2
|
17
|
8507
|
|
POST
|
Our SDE (10.0 on Oracle 11g) has a tabular view created from a feature class and a table. The view is valid in Toad but it does not show up in ArcCatalog for either the schema owner or the SDE user; arcpy.Exists() returns False. There is, however, an entry in the SDE.Table_Registry for the view. How can I remove this view from the table registry?
... View more
07-23-2015
11:02 AM
|
0
|
8
|
12082
|
|
BLOG
|
I simplified your code with the parser option parameters and such just for this example, but this is what I came up with for creating temporary connection files that will get cleaned up when finished. I've tested this a bit and it seems to work. On Win7, the temp folder gets created in C:\Users\Username\AppData\Local\Temp import arcpy from contextlib import contextmanager import os import shutil import tempfile def main(): try: with makeTempDir() as temp_dir: tempConn = arcpy.CreateDatabaseConnection_management( temp_dir, ## out_folder_path "tempConn.sde", ## out_name "ORACLE", ## database_platform "GISTEST.WORLD", ## instance "DATABASE_AUTH", ## account_authentication "myuser", ## username "myuserpass", ## password ) print arcpy.GetMessages() tempConn = str(tempConn) ## Format result object as string for path to connection file # Print workspace properties desc = arcpy.Describe(tempConn) cp = desc.connectionProperties print("User: ", cp.user) print("Workspace Type:", desc.workspaceType) print("WorkspaceFactoryProgID:", desc.workspaceFactoryProgID) except Exception as err: print err finally: # Cleanup arcpy.ClearWorkspaceCache_management() @contextmanager def makeTempDir(): """Creates a temporary folder and returns the full path name. Use in with statement to delete the folder and all contents on exit. Requires contextlib contextmanager, shutil, and tempfile modules. """ temp_dir = tempfile.mkdtemp() try: yield temp_dir finally: shutil.rmtree(temp_dir) if __name__ == '__main__': main()
... View more
07-22-2015
05:49 PM
|
0
|
0
|
2798
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | Friday | |
| 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 |