POST
|
We are changing our production server to have a prefix of 'HV'. I have a folder of MXDs I would like to update to the new server, but I am missing something from my code below. I got my start from https://gist.github.com/davehorsey/d8892b150e61d2e03617. import arcpy, os
path = r"C:\layouts"
for fileName in os.listdir (path):
basename, extension = os.path.splitext(fileName)
# select MXD files that do NOT begin with "Copy_of_" - this
# prevents the script from updating files that have already been updated
if (extension == ".mxd") and (fileName[:8] != "Copy_of_"):
fullPath = os.path.join(path, fileName)
mxd = arcpy.mapping.MapDocument(fullPath)
print fullPath
# update data sources
mxd.findAndReplaceWorkspacePaths("Database Connections\\Server Database NT Auth.sde", "Database Connections\\HV_Server Database NT Auth.sde")
print "\tUpdated: SDE data sources"
# check for broken links
brknList = arcpy.mapping.ListBrokenDataSources(mxd)
for brknItem in brknList:
print "\tCheck: " + brknItem.name + " data source broken"
if not brknList:
print "\tCheck: no broken data sources"
# save a copy of the MXD
saveACopy_filename = "Copy_of_" + fileName
saveACopy_fullpath = os.path.join(path, saveACopy_filename)
mxd.saveACopy(saveACopy_fullpath)
print "\tSaved: " + saveACopy_filename
del mxd
# delete the original MXD
arcpy.Delete_management(fullPath)
print "\tDeleted: " + fullPath
... View more
06-20-2019
11:40 AM
|
0
|
5
|
1237
|
POST
|
When using the Apply Symbology From Layer file in Pro via Model Builder, it will revert the labels back prior to any changes I have made. I have updated the layer file (.lyrx) that it references too, but does not seem to stick as it does in ArcMap with a Layer (.lyr) file.
... View more
05-22-2019
08:49 AM
|
0
|
0
|
422
|
POST
|
We updated one of our SDE editor's computers from 10.3.1 to 10.6.1 (ArcGIS Server SDE at 10.3.1). I am able to edit on their 10.6.1 computer, but when they go to edit the same data they get the red warning 'No Editable Layers' with a warning for each layer 'Check to see that you have the appropriate permissions'. We have tested numerous machines both on Windows 8 and 10. We had that user edit the same data on ArcMap 10.3.1 and they were able to edit.
... View more
05-17-2019
03:39 PM
|
0
|
1
|
670
|
POST
|
My goal is to list all indexes that are being used on each feature class in an SDE database with ~50 feature classes that reside, with the end product being a list of the feature class and what the name of the index is. import arcpy
arcpy.env.workspace = r"Database Connections\Server Database Login.sde"
# Get list of indexes and print properties
FCs = arcpy.ListFeatureClasses()
for FC in FCs:
indexes = arcpy.ListIndexes(FC)
for index in indexes:
print FC
print("Name : {0}".format(index.name))
print("IsAscending : {0}".format(index.isAscending))
print("IsUnique : {0}".format(index.isUnique))
... View more
05-02-2019
12:19 PM
|
1
|
0
|
536
|
POST
|
A follow up to my above comment, while 5TH and MAIN does not work, NE 5TH AND MAIN does work just by adding NE at the beginning.
... View more
05-02-2019
07:59 AM
|
0
|
2
|
1057
|
POST
|
Hi Shana and Devon, Has there been any update on this issue? I am having the same issue as we are upgrading from 10.3.1 to 10.6.1. On both levels, E MAIN ST and NE 5TH AVE works, however on 10.3.1 MAIN and 5TH works but does not work on 10.6.1.
... View more
05-02-2019
07:18 AM
|
0
|
3
|
1057
|
POST
|
I usually do that but it requires a spatial join, then a table join, then a calculate field. In the case of my schema here, I don't have a unique ID field to join back to on a table join.
... View more
03-14-2019
02:17 PM
|
1
|
0
|
1488
|
POST
|
Thanks, Mitch, That worked. I was able to make a separate python file for each point feature class and just schedule it sequentially in task scheduler, takes about 10 minutes to run instead of 2 hours. I also took your advice about doing the geoprocessing on my local drive. I ended up deleting the features where the PlanRefID was NULL after exporting locally then append them back into SDE at the end of the script. Thanks for your help.
... View more
03-13-2019
04:04 PM
|
0
|
0
|
1488
|
POST
|
I am working on a python script that updates a field titled 'PlanRefID' field in several point feature classes. These are populated based on a 'PlanRefID' field in a polygon feature class. The cursor will loop through and populate the 'PlanRefID' field in the point feature classes (approximately 10) correctly. The issue I am having is that I only want it to update where the PlanRefID IS NULL in my point feature classes. However, it will loop through all records in the polygon feature class, which is taking about 1.5 - 2 hours to run. As the feature classes add more records, the processing time will only increase. I only interested in updating the point features where the PlanRefID IS NULL and referencing the polygons they intersect. arcpy.MakeFeatureLayer_management("Database Connections\\Server Database OWNER.sde\\Database.OWNER.FeatureDataset\\Database.OWNER.Polygon", "Database_OWNER_Polygon")
arcpy.MakeFeatureLayer_management("Database Connections\\Server Database OWNER.sde\\Database.OWNER.FeatureDataset\\Database.OWNER.Point", "Database_Owner_Point", "PlanRefID IS NULL")
arcpy.SelectLayerByAttribute_management("Database_Owner_Point", "NEW_SELECTION", "PlanRefID IS NULL")
rows = arcpy.SearchCursor("Database_OWNER_Polygon")
for row in rows:
arcpy.SelectLayerByAttribute_management("Database_OWNER_Polygon", "NEW_SELECTION", "\"OBJECTID\" = " + str(row.getValue("OBJECTID")))
arcpy.SelectLayerByLocation_management("Database_Owner_Point", "INTERSECT", "Database_OWNER_Polygon", "", "NEW_SELECTION")
arcpy.CalculateField_management("Database_Owner_Point", "PlanRefID", "'{0}'".format(str(row.getValue("PlanRefID"))), "PYTHON_9.3", "") print "Finished processing " + str(row.getValue("PlanRefID"))
... View more
03-13-2019
10:34 AM
|
0
|
4
|
1788
|
POST
|
We are in the process of importing our water mains into an asset management system. The system rejects any line segments with an arc/curve (example below). I think these were imported ~15 - 20 years ago from CAD. Trying to research a way to query out these features that will need to be updated to not contain arc segments. I looked through some Data Reviewer options but did not yield any results yet. We are on Desktop 10.3.1.
... View more
02-14-2019
07:33 AM
|
0
|
1
|
1038
|
POST
|
I had this issue and went the following route: If the field that is the ID is a number field, create a view for creating the next ID in sequence in SQL Server such as: SELECT MAX(FieldName) + 1 AS NEXT_ID
FROM owner.TABLENAME Then, in Model Builder, I created a model to assign the ID. Get Field Value: Using your view that you created: Field is NEXT_ID, Data Type is Long Make a Feature Layer of the feature class you are trying to update, then Select By Attribute as "FieldName IS NULL", then calculate "FieldName" with the "Value" from the next available ID Calculate Field (Python 9.3): Expression:
autoIncrement()
Code Block:
rec=0
def autoIncrement():
global rec
pStart = %Value%
pInterval = 1
if (rec == 0):
rec = pStart
else:
rec += pInterval
return rec From here, you can import the Model Builder model into a Python script as: arcpy.ImportToolbox("C:\Path\To\Your\Toolbox\AutoID.tbx","test")
arcpy.ModelName_test() Make sure you add _test() to the end of your model name and "test" at the end of your toolbox.
... View more
02-04-2019
04:21 PM
|
0
|
2
|
9175
|
POST
|
Thank you, that one worked after removing the double 'arcpy'.
... View more
02-04-2019
07:07 AM
|
0
|
0
|
232
|
POST
|
I updated line 6 and 7 with your code but seems to still report an error: Traceback (most recent call last): File "C:\path\to\python\file.py", line 8, in <module> arcpy.arcpy.CreateDatabaseView_management(fc, os.path.join("Database Connections\\Server DB sde.sde",'v_{}'.format(fc), 'select * from {}'.format(fc))) File "C:\Program Files (x86)\ArcGIS\Desktop10.3\ArcPy\arcpy\management.py", line 4069, in CreateDatabaseView raise e ExecuteError: Failed to execute. Parameters are not valid. ERROR 000837: The workspace is not the correct workspace type. ERROR 000735: View Definition: Value is required Failed to execute (CreateDatabaseView). import arcpy
import os
arcpy.env.workspace = "Database Connections\\Server DB sde.sde"
featureclasses = arcpy.ListFeatureClasses()
for fc in featureclasses:
arcpy.arcpy.CreateDatabaseView_management(fc, os.path.join("Database Connections\\Server DB sde.sde",'v_{}'.format(fc), 'select * from {}'.format(fc)))
... View more
01-31-2019
04:02 PM
|
0
|
1
|
2213
|
POST
|
I have created an SDE database in which I have copied feature classes from my production database from State Plane into WGS 84 for web mapping applications. The final step is to create views, and I am trying to automate the process as I have hundreds of feature classes. Below, I am trying to make a list of all the feature classes and use the name of the feature class. The middle parameter starts with a prefix of v_ then grabs the feature class name (ie: v_watermeters). The third variable is the SQL statement used to create the view definition, where it grabs all the fields (SELECT * FROM ) then I want to use the feature class name (ie: SELECT * FROM watermeters). I am having trouble with the third variable and concatenating the string values to make valid code. We are currently on ArcGIS 10.3.1 and SQL Server 2012. import arcpy
import os
arcpy.env.workspace = "Database Connections\\Server Database sde.sde"
featureclasses = arcpy.ListFeatureClasses()
for fc in featureclasses:
arcpy.arcpy.CreateDatabaseView_management(
fc, os.path.join("Database Connections\\Server Database sde.sde","v_"+str(featureclasses), "select * from "+featureclasses)
... View more
01-31-2019
03:03 PM
|
0
|
10
|
2734
|
POST
|
I had a similar issue, and I could not assign privileges with a blank feature dataset. Once I added a dummy feature class within the feature dataset, I was able to assign privileges then I removed the dummy feature class and added the real ones.
... View more
01-16-2019
10:26 AM
|
3
|
0
|
1023
|
Title | Kudos | Posted |
---|---|---|
1 | a month ago | |
1 | 08-29-2024 03:18 PM | |
1 | 09-05-2024 09:08 AM | |
1 | 09-10-2024 09:40 AM | |
1 | 08-16-2024 12:55 PM |
Online Status |
Offline
|
Date Last Visited |
yesterday
|