POST
|
Hello, I have a script tool that takes a feature layer and update the table with 'arcpy.da.UpdateCursor(path, fields_rec) as cursor:' It runs on shp files from my geodatabase but i want to make it run also on a web feature layer that i upload from the organization portal, is it possible ?. I am new to the AGOL field and possibilities. Here is the code for refernce: import arcpy
import os
import time
arcpy.env.overwriteOutput = True
arcpy.env.workspace = r"C:\GIS\###\x_prebuild.gdb"
# Choose receivers layer and input lists for surveyour and restored status
rec_table = arcpy.GetParameterAsText(0)
surv_list_str = arcpy.GetParameterAsText(1)
Feature_rec = os.path.basename(rec_table)
surv_list = surv_list_str.split(",")
fields_rec = ["LineNumber", "Station", "Status", "Surv_Date","Restored_Date"]
# Update Status for Rec layer - SURVEYED
i=0
for x in range(int(len(surv_list)/3)):
with arcpy.da.UpdateCursor(path, fields_rec) as cursor:
for row in cursor:
if row[0] == surv_list and row[1] >= int(surv_list[i+1]) and row[1] <= int(surv_list[i+2]):
row[2] = 1
row[3] = time.strftime("%d/%m/%Y")
cursor.updateRow(row)
i += 3
... View more
10-07-2019
12:22 AM
|
0
|
0
|
296
|
POST
|
Thanks for replying. I did all the thing but didn't understand the "use of surv_list as a "value list" under the "filter" option". my attempt is to enter a random list to the tool in the form of:(name,from_point,to_point), or list of lists: ((name, from_point, to_point),(name2, from_point2, to_point2)) and than use these 3 variable of each list in the code block to return a value if i have a match. i might have other problems with my code but for start, i cant get the list i enter in the tool to be identified in the code block. any suggestions ? Thanks in advanced
... View more
08-12-2019
01:39 AM
|
0
|
1
|
820
|
POST
|
I'm trying to build a tool based on script in arcgis pro (the tool makes changes to a field with calculate field based on a list of variables). how do i use a list inserted with arcpy.GetParameterAsText() within a codeblock function in calculate field ? my problem is that it does not recognize my list: "NameError: name 'surv_list' is not defined" This is my script: import arcpy arcpy.env.overwriteOutput = True arcpy.env.workspace = r"C:\GIS\project_prebuild.gdb" # Exmaple fot text input to run tool in python: ##surv_list = (('FT18-17',235,300),('FT18-17',410,432),('FT18-15',101,130),('FT18-13',101,140)) surv_list = arcpy.GetParameterAsText(0) record_list = arcpy.GetParameterAsText(1) codeblock = ("""def update_status(line,point,surv_list,record_list): if len(surv_list[0])==3: for x in surv_list: if line == x[0] and point >= x[1] and point <= x[2]: return 1 elif line == surv_list[0] and point >= surv_list[1] and point <= surv_list[2]: return 1 if len(record_list[0])==3: for y in record_list: if line == y[0] and point >= y[1] and point <= y[2]: return 2 elif line == record_list[0] and point >= record_list[1] and point <= record_list[2]: return 2""") arcpy.CalculateField_management("REC_Preplot_25m","Status","update_status(!LineNumber!,!Station!,surv_list,record_list)","PYTHON3",codeblock)
... View more
08-10-2019
11:25 PM
|
0
|
3
|
1060
|
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:25 AM
|