POST
|
Sorry for the late reply. We had tried something similar with the .startediting method parameters set both to True. I tried your suggestion and it didn't work either. We ended up using a windows task as an alternative to want we needed. I would still like to find out why it didn't work, though. Thanks, Michael
... View more
09-15-2015
10:27 AM
|
1
|
0
|
421
|
POST
|
What about replacing the exists function in line 20 with an "if statement". The listfeatures function returns a list and then you could do something like "if len(list) == 1:" or similar
... View more
09-09-2015
03:28 PM
|
1
|
1
|
929
|
POST
|
Has anyone have this problem? I created a python script, and it runs fine in a python interface or as a python tool in Arcmap, but when I convert it to a geoprocessing service it won't run. Furthermore, the error it gives it's unclear: RuntimeError: Objects in this class cannot be updated outside an edit session This error doesn't make sense because 1. the process is done in an editing session, and 2. it works as a standalone script or as a python tool. Below is the code in case you want to take a look, but again it runs fine so the problem seems to be in the geoprocessing service step. import arcpy
arcpy.env.overwriteOutput = True
# If needed create a connection file to the sde geodatabase
if not arcpy.Exists('connect.sde'):
arcpy.CreateDatabaseConnection_management('************')
arcpy.env.workspace = r'connect.sde'
# Input files
districts = '*****'
sites = '*****'
arcpy.MakeFeatureLayer_management(sites, 'sites')
# Start an editing session
with arcpy.da.Editor(arcpy.env.workspace) as edit:
fields = ['Name', 'totalsites', 'completedsites', 'SHAPE@']
with arcpy.da.UpdateCursor(districts, fields) as cursor:
for row in cursor:
name = row[0]
shape = row[3]
arcpy.SelectLayerByLocation_management('sites', 'WITHIN', shape)
arcpy.CopyFeatures_management('sites', 'in_memory/selected')
# count total and completed
total = 0
completed = 0
siteFields = ['SITE_STATUS']
with arcpy.da.SearchCursor('in_memory/selected', siteFields) as cursor2:
for row2 in cursor2:
status = row2[0]
total += 1
if status == '****':
completed += 1
row[1] = total
row[2] = completed
cursor.updateRow(row)
print 'Finished' Thanks a in advance, Michael
... View more
09-09-2015
03:07 PM
|
1
|
3
|
3355
|
POST
|
I just came across this same need. It is very frustrating that ArcGIS online does recognize phone number hotlinks, and Colletor, which is a MOBILE app, does not.
... View more
08-18-2015
04:09 PM
|
1
|
3
|
438
|
POST
|
I was just wondering this the other day. I moved to Python 64 background processing a while ago, but there are certain tools I want to use that still need Python 32. I would like to keep Python 64 background processing but be able to go back to Python 32 every once in a while without having to uninstall 64. Thanks, Michael
... View more
07-15-2015
12:02 PM
|
2
|
9
|
4764
|
POST
|
Uhh, that sucks. I thought there would be a work around or something.
... View more
06-15-2015
01:59 PM
|
0
|
0
|
425
|
POST
|
I can't read excel files with data access search cursor since I upgrade to Python 64 background processing. I have the office system drivers so that's not the problem. Also, I was able to read excels files fine before I upgraded. I even tried the same script in a computer running on Python 32 and then in mine with Python 64,.It worked in Python 32, but failed in Python 64 so I'm pretty sure the problem is with Python 64. Have anyone run into this or knows how to fix it? Here a simple example of what I can't do anymore: import arcpy
spreadsheet = r'spreadsheet.xlsx\Sheet1$'
with arcpy.da.SearchCursor(spreadsheet, 'name') as cursor:
for row in cursor:
print row[0] Thanks, Michael
... View more
06-15-2015
10:22 AM
|
0
|
2
|
2240
|
POST
|
My coworker spent a couple of days on this and couldn't find the error either. At the end we just rewrote the whole thing differently. The actual error was never found but at this does what we needed. One thing we added that may have solved the problem was the simplify polygon function on the wetlands data. We believe that the wetlands data had some sliver in between counties or something like that, but there's still the exception that things ran fine when done manually so we will never know for sure. Thank you all for your help anyway. Michael
... View more
05-14-2015
01:30 PM
|
1
|
1
|
428
|
POST
|
Running as standalone from Spyder, also tried Pyscripter, ArcGIS 10.3. We did tried the .da cursors to see if that was it, but no. See solution explained below.
... View more
05-14-2015
01:01 PM
|
0
|
0
|
428
|
POST
|
That's a good suggestion, however it doesn't solve the problem. The .replace() was in the script before I updated it, I added the str() in case unicode strings were the ones causing the problem. but no.
... View more
05-05-2015
03:35 PM
|
0
|
0
|
1025
|
POST
|
That's how it was before. I would loop through the counties and save them in a list and then loop through the list separately, I changed it hoping that making it more simple would help me find the error. A coworker is now working on it to see if he can find the problem. P.S. it's not the geometry either.
... View more
05-05-2015
03:32 PM
|
0
|
3
|
1025
|
POST
|
The first couple counties clip fine. Also, I ran the clip manually for the Sanpete county in arcmap and the clip works. I assumed that the geometry was okay because of that, but I'll run the repair geometry on Monday just in case.
... View more
05-02-2015
04:21 PM
|
0
|
2
|
1025
|
POST
|
I updated a script to clip wetlands data per county. Some counties work, but for others the Clip analysis fails. Here is the code: import arcpy
import time
# Start time
start = time.time()
print('Prepping wetlands county clipped data')
# Enivornment variables
arcpy.env.overwriteOutput = True
arcpy.env.workspace = 'in_memory'
arcpy.env.outputCoordinateSystem = arcpy.SpatialReference('NAD 1983 UTM Zone 12N')
# Input paths
countyPath = r'Counties'
wetlandsPath = r'UT_Wetlands'
# Output path
outFolder = r'output.gdb'
# Create feature dataset
wetlandsFolder = '{}/Wetlands'.format(outFolder)
if not arcpy.Exists(wetlandsFolder):
arcpy.CreateFeatureDataset_management(outFolder, 'Wetlands')
arcpy.MakeFeatureLayer_management(countyPath, 'countyLayer')
maxCount = len(idList)
count = 1
countyRows = arcpy.SearchCursor(countyPath)
for countyRow in countyRows:
county = str(countyRow.NAME).replace(' ', '_')
outFile = '{}/Wetlands/{}_Wetlands'.format(outFolder, county)
query = '"NAME" = \'' + str(countyRow.NAME) + '\''
arcpy.SelectLayerByAttribute_management('countyLayer', 'NEW_SELECTION', query)
print 'Clipping ' + str(count) + ' out of ' + str(maxCount)
arcpy.Clip_analysis(wetlandsPath, 'countyLayer', outFile)
arcpy.SelectLayerByAttribute_management('countyLayer', 'CLEAR_SELECTION')
count += 1
print 'Working on wetlands for ' + county.replace('_', ' ') + ' county...'
# Here I create variables
# Here I add new fields
# Here I populate the new fields with the created variables
del countyRow, countyRows
# Finish
end = time.time()
print '\nFinished, run time', time.strftime('%M:%S', time.localtime(end - start)) The script will work until it gets to SANPETE county, which gives this error: arcgisscripting.ExecuteError: ERROR 999999: Error executing function. The table was not found. The table was not found. [SANPETE_Wetlands] The table was not found. The table was not found. [SANPETE_Wetlands] Invalid Topology [Incomplete void poly.] Failed to execute (Clip). I've tracked the error to the clip function. At first I thought there was an error in the syntax, then I thought arcpy was getting confused as to where to look for the created clipped feature because I was saving it in memory, then I thought maybe the wetlands data was just too big, or there is something wrong with the attribute data for the SANPETE county, but it's non of those. I tried skipping SANPETE but then it runs for a while and fails in BEAVER county. I'm running out of ideas as to what it may be. I tried the clip manually in arcMap and it works. Any suggestions as to what else to try or do you see anything I'm missing in the script? Thanks, Michael
... View more
05-01-2015
04:00 PM
|
1
|
13
|
5836
|
POST
|
It is now working, I didn't do anything today though. I did clear my cache and restarted my computer last week and that didn't work then. Anyway, thanks for your responses. Michael
... View more
03-16-2015
11:17 AM
|
0
|
0
|
1072
|
Title | Kudos | Posted |
---|---|---|
1 | 09-09-2015 03:28 PM | |
1 | 09-09-2015 03:07 PM | |
1 | 09-15-2015 10:27 AM | |
1 | 05-01-2015 04:00 PM | |
1 | 05-14-2015 01:30 PM |
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:23 AM
|