|
POST
|
I was able to get it to work by removing the feature_dataset [0] and making the workspace a "database connection" not a direct connection. import arcpy
from arcpy import env
arcpy.env.workspace = "Database Connections\GISSERVER1 (VERSION:dbo.DEFAULT)"
lyr = arcpy.ListFeatureClasses ("Hydro_FINAL_ALL_*")#Database Servers\GIS.gds\GISSERVER1 (VERSION:dbo.DEFAULT)\Hyrdo_FINAL_ALL_121817
for fc in lyr:
arcpy.MakeFeatureLayer_management(fc, "In_memory\lyr1")
arcpy.TableSelect_analysis("In_memory\lyr1","C:/Temp/Export_Output.xls", "")
#arcpy.FeatureClassToFeatureClass_conversion("In_memory\lyr1","C:\Temp","Export.shp")
print 'done'
... View more
12-28-2017
10:01 AM
|
0
|
0
|
591
|
|
POST
|
Fixing the typo didn't not fix it the "list index out of range" error.
... View more
12-28-2017
08:20 AM
|
0
|
1
|
5508
|
|
POST
|
Yes Hydro, sorry. The feature class gets delete and replace with a new one with the date it was created, sorry i should have mentioned that.
... View more
12-21-2017
03:35 PM
|
0
|
3
|
5508
|
|
POST
|
I am getting "list index out of range" at lyr = arcpy.ListFeatureClasses(" Hyrdo_FINAL_ALL_* ") [0]? thanks for the TableToExcel.
... View more
12-21-2017
02:21 PM
|
0
|
2
|
5508
|
|
POST
|
I have a feature class table that i need to export to excel, the feature class will be created weekly. The problem i am having is that on creation the feature class gets the date added to the end of the feature class name and i am trying to access with a wildcard because the date will change based on when the feature class gets created. How can i get the feature class with a wildcard? import arcpy
workspace = "Database Servers\GIS.gds\GISSERVER1 (VERSION:dbo.DEFAULT)"
arcpy.env.workspace = workspace
'''
lyrs = ['Hyrdo_FINAL_ALL_*']
for fc in arcpy.ListFeatureClasses():
for lyr in lyrs:
if fc.startswith(lyr):
print 'lyr'
'''
lyr = "Hyrdo_FINAL_ALL_*" #Database Servers\GIS.gds\GISSERVER1 (VERSION:dbo.DEFAULT)\Hyrdo_FINAL_ALL_121817
arcpy.MakeFeatureLayer_management(lyr, "In_memory\lyr1")
arcpy.TableSelect_analysis("In_memory\lyr1","C:/Temp/Export_Output.xls", "")
print 'done'
... View more
12-21-2017
10:41 AM
|
0
|
10
|
8229
|
|
POST
|
ok, so after i run the script in arcmap the features updated based on the script, no error there. They way i found out that it was locking that ArcSDE Personal Sever was that i was trying to open another feature class from that ArcSDE Personal Server in a new mxd. If i try to look at a feature class on that ArcSDE Personal Sever with ArcCatalog i get the error " Failed to connect to database. Maximum number of connections to instanced exceeded." My knowledge is that you are allowed 3 connections to a ArcSDE Personal Server and i just have the one mxd that i run the script on and a second new one to add a feature class to see if the ArcSDE Personal Server is locked. I know that it is the update cursor because if i commented it out on the script runs fine and i can open the ArcSDE Personal Server and add features from that server to a new mxd.
... View more
11-20-2017
07:41 AM
|
0
|
0
|
410
|
|
POST
|
you are right, i dedented them and re-rand the script but still locks up the Personal SDE server.
... View more
11-20-2017
07:29 AM
|
0
|
0
|
2456
|
|
POST
|
Dan, yes i did try. line 65-67 import arcpy, os
arcpy.env.overwriteOutput = True
arcpy.env.workspace = r'Database Connections\Connection to test.sde' #Database Connections
fc1 = 'DBO.TaxParcels1' # Taxparcels
fc2 = 'DBOAddresPointsTest_1'
def main():
try:
lyr2 = arcpy.MakeFeatureLayer_management(fc2, "In_memory\lyr2")
arcpy.AddField_management(fc2, "Verifi2", "Text", "","",50)
#build a dictionary of OBJECTID : Address pairs, change OID@ to your uniqueID
addDict = {row[0]:row[1] for row in arcpy.da.SearchCursor(fc1, ['ACCOUNT','SiteAddress'])}
# Start an edit session. Must provide the worksapce.
edit = arcpy.da.Editor(arcpy.env.workspace)
# Edit session is started without an undo/redo stack for versioned data
# (for second argument, use False for unversioned data)
edit.startEditing(True)
# Start an edit operation
edit.startOperation()
#Spatial joins the points to taxparcels if "Match" is in Verifi2 field, updates points attributes.
arcpy.env.workspace = r'Database Connections\Connection to test.sde'
ptSelection = "DBO.AddresPointsTest_1"
pointLayer = arcpy.env.workspace + os.sep + "DBO.AddresPointsTest_1" # DBO.AddresPointsTest
parcel = 'DBO.TaxParcels1' #Taxparcels
sjpoints = "In_memory\sjpoints"
poly = "ACCOUNT_1"
Pnt = "Account"
ptCount = int(arcpy.GetCount_management(pointLayer).getOutput(0))
dsc = arcpy.Describe(ptSelection)
selection_set = dsc.FIDSet
if len(selection_set) == 0:
print "There are no features selected"
elif ptCount >= 1:
#Run the Spatial Join tool, using the defaults for the join operation and join type
arcpy.SpatialJoin_analysis(lyr2, parcel, sjpoints)
# define the field list from the spatial join
sourceFieldsList = ['ACCOUNT_1', poly,'Field_1','Field_2', 'Field_3','Field_4','Field_5'] #,'StreetType_1'
# define the field list to the original points
updateFieldsList = ['Account', Pnt,'Field1', 'Field2', 'Field3', 'Field4','Field4', 'Field5'] #, 'StreetType'
# populate the dictionary from the polygon
valueDict = {r[0]:(r[1:]) for r in arcpy.da.SearchCursor(sjpoints, sourceFieldsList)}
whereclause = "Verifi2 = 'Match'"
with arcpy.da.UpdateCursor(ptSelection, updateFieldsList ,whereclause) as updateRows:
for updateRow in updateRows:
keyValue = updateRow[0].title()
if keyValue in valueDict:
for n in range (1,len(sourceFieldsList)):
updateRow[n] = valueDict[keyValue][n-1]
updateRows.updateRow(updateRow)
updateRows.reset()
del valueDict
del updateRows
# Stop the edit operation.
edit.stopOperation()
# Stop the edit session and save the changes
edit.stopEditing(True)
#Clear geodatabase locks.
# Set environment settings
arcpy.env.workspace = "Database Connections\Connection to Test.sde" # Creates a connection to enterprise geodatabase
fcList = arcpy.ListFeatureClasses() # Show that we are connected
print(str(fcList) + "\n")
arcpy.env.workspace = "" # Release hold on enterprise geodatabase workspace created in previous step.
# Execute the Clear Workspace Cache tool
arcpy.ClearWorkspaceCache_management("Database Connections\Connection to Test.sde")
print(arcpy.GetMessages() + "\n")
except:
arcpy.AddError("Python Messages: " + arcpy.GetMessages())
if __name__ == '__main__':
main()
... View more
11-17-2017
03:49 PM
|
0
|
2
|
2456
|
|
POST
|
I am on ArcGIS10.4.1, sorry i should have mentioned that. I removing the entire 'with' block and run the code and ArcSDE Personal server is not locked. It's the 'with' block that locks it up but i am not sure why it's not release it because the cursor is inside a statement. I am at a loss here.
... View more
11-17-2017
02:49 PM
|
0
|
4
|
2456
|
|
POST
|
I have a ArcSDE Personal geodatabase that i need to edit. I am connecting to the feature class through a save connection other wise i can't edit the feature class. The problem i am having is once i run the code and it runs fine it seem to lock the entire ArcSDE Personal server not just the geodatabase the specific feature class is in. I thought the 'with' ith arcpy.da.SearchCursor as cur: would release it but it does not. I also tried running the with statement inside of a function to remove the locks on the server when done. I also tried arcpy.ClearWorkspaceCache_management but nothing is working. So i need some help, i am not sure is there is something wrong with my python script. I need to run this script inside Arcmap's python window. import arcpy, os
arcpy.env.overwriteOutput = True
arcpy.env.workspace = r'Database Connections\Connection to test.sde' #Database Connections
fc1 = 'DBO.TaxParcels1' # Taxparcels
fc2 = 'DBOAddresPointsTest_1'
def main():
try:
lyr2 = arcpy.MakeFeatureLayer_management(fc2, "In_memory\lyr2")
arcpy.AddField_management(fc2, "Verifi2", "Text", "","",50)
#build a dictionary of OBJECTID : Address pairs, change OID@ to your uniqueID
addDict = {row[0]:row[1] for row in arcpy.da.SearchCursor(fc1, ['ACCOUNT','SiteAddress'])}
# Start an edit session. Must provide the worksapce.
edit = arcpy.da.Editor(arcpy.env.workspace)
# Edit session is started without an undo/redo stack for versioned data
# (for second argument, use False for unversioned data)
edit.startEditing(True)
# Start an edit operation
edit.startOperation()
#Spatial joins the points to taxparcels if "Match" is in Verifi2 field, updates points attributes.
arcpy.env.workspace = r'Database Connections\Connection to test.sde'
ptSelection = "DBO.AddresPointsTest_1"
pointLayer = arcpy.env.workspace + os.sep + "DBO.AddresPointsTest_1" # DBO.AddresPointsTest
parcel = 'DBO.TaxParcels1' #Taxparcels
sjpoints = "In_memory\sjpoints"
poly = "ACCOUNT_1"
Pnt = "Account"
ptCount = int(arcpy.GetCount_management(pointLayer).getOutput(0))
dsc = arcpy.Describe(ptSelection)
selection_set = dsc.FIDSet
if len(selection_set) == 0:
print "There are no features selected"
elif ptCount >= 1:
#Run the Spatial Join tool, using the defaults for the join operation and join type
arcpy.SpatialJoin_analysis(lyr2, parcel, sjpoints)
# define the field list from the spatial join
sourceFieldsList = ['ACCOUNT_1', poly,'Field_1','Field_2', 'Field_3','Field_4','Field_5'] #,'StreetType_1'
# define the field list to the original points
updateFieldsList = ['Account', Pnt,'Field1', 'Field2', 'Field3', 'Field4','Field4', 'Field5'] #, 'StreetType'
# populate the dictionary from the polygon
valueDict = {r[0]:(r[1:]) for r in arcpy.da.SearchCursor(sjpoints, sourceFieldsList)}
whereclause = "Verifi2 = 'Match'"
with arcpy.da.UpdateCursor(ptSelection, updateFieldsList ,whereclause) as updateRows:
for updateRow in updateRows:
keyValue = updateRow[0].title()
if keyValue in valueDict:
for n in range (1,len(sourceFieldsList)):
updateRow[n] = valueDict[keyValue][n-1]
updateRows.updateRow(updateRow)
del valueDict
del updateRows
del updateRow
# Stop the edit operation.
edit.stopOperation()
# Stop the edit session and save the changes
edit.stopEditing(True)
#Clear geodatabase locks.
# Set environment settings
arcpy.env.workspace = "Database Connections\Connection to Test.sde" # Creates a connection to enterprise geodatabase
fcList = arcpy.ListFeatureClasses() # Show that we are connected
print(str(fcList) + "\n")
arcpy.env.workspace = "" # Release hold on enterprise geodatabase workspace created in previous step.
# Execute the Clear Workspace Cache tool
arcpy.ClearWorkspaceCache_management("Database Connections\Connection to Test.sde")
print(arcpy.GetMessages() + "\n")
except:
arcpy.AddError("Python Messages: " + arcpy.GetMessages())
if __name__ == '__main__':
main()
... View more
11-17-2017
01:24 PM
|
0
|
10
|
3108
|
|
POST
|
I figured it out, for some reason there was an extra field on the feature layer that i overwrote with. Once i removed that field and overwrote again i am able to see the points now. Kelly thank you for the links to the Blogs.
... View more
11-15-2017
02:06 PM
|
1
|
0
|
3150
|
|
POST
|
I read the blogs and i have set the visible scale and filters but doesn't seem to make a difference. I checked the web requests and i am seeing the following for that layer. Preview {error: {code: 400, message: "Cannot perform query. Invalid query parameters.",…}} Response {"error":{"code":400,"message":"Cannot perform query. Invalid query parameters.","details":["Unable to perform query. Please check your parameters."]}}
... View more
11-15-2017
01:44 PM
|
0
|
0
|
3150
|
|
POST
|
I have a web map that i use for a Web Appbuilder application and today i need to update a feature layer that is stored on ArcGIS online that is used on this web map. So through ArcGIS Online I did an overwrite, i made sure it had the same fields and name but then i noticed that in my Application the points were not showing anymore. So i open up the web map on arcgis online and zoom in to an area and i get the error "The layer, Address_Points, was not drawn completely because it has too many features to draw. Try zooming in to a smaller area." So i am not sure what happened because the only difference was that there were about 300 more new points. Any thoughts on whats going on? I would really appreciate any help. Thanks.
... View more
11-15-2017
11:37 AM
|
0
|
6
|
4265
|
|
POST
|
Thanks Darren, something like like 31? #Spatial joins the points to taxparcels if "Match" is in Verifi2 field, updates points attributes.
arcpy.env.overwriteOutput = True
arcpy.env.workspace = r'C:\Temp\Default.gdb'
ptSelection = "PointsTest" #points
pointLayer = arcpy.env.workspace + os.sep + "PointsTest"
parcel = 'TaxParcels' #Taxparcels
sjpoints = "In_memory\sjpoints"
poly = "Filed_1"
Pnt = "Filed"
ptCount = int(arcpy.GetCount_management(pointLayer).getOutput(0))
dsc = arcpy.Describe(ptSelection)
selection_set = dsc.FIDSet
if len(selection_set) == 0:
print "There are no features selected"
elif ptCount >= 1:
#Run the Spatial Join tool, using the defaults for the join operation and join type
arcpy.SpatialJoin_analysis(lyr2, parcel, sjpoints)
# define the field list from the spatial join
sourceFieldsList = ['Filed_1', poly,'Field1_1','Field2_1', 'Field3_1']
# define the field list to the original points
updateFieldsList = ['Field', Pnt,'Field1', 'Field2', 'Field3']
# populate the dictionary from the polygon
valueDict = {r[0]:(r[1:]) for r in arcpy.da.SearchCursor(sjpoints, sourceFieldsList)}
whereclause = "Verifi2 = 'Match'"
with arcpy.da.UpdateCursor(ptSelection, updateFieldsList ,whereclause) as updateRows:
for updateRow in updateRows:
keyValue = updateRow[0].title()
if keyValue in valueDict:
for n in range (1,len(sourceFieldsList)):
updateRow[n] = valueDict[keyValue][n-1]
updateRows.updateRow(updateRow)
del valueDict
... View more
11-02-2017
02:41 PM
|
0
|
0
|
1559
|
|
POST
|
Interesting stuff guys, thank you for the great information and links!
... View more
11-02-2017
02:29 PM
|
0
|
0
|
2263
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 10-27-2022 11:37 AM | |
| 1 | 10-31-2023 10:16 AM | |
| 1 | 02-16-2023 01:50 PM | |
| 1 | 08-11-2021 11:13 AM | |
| 1 | 01-06-2021 10:45 AM |
| Online Status |
Offline
|
| Date Last Visited |
09-10-2024
10:42 AM
|