POST
|
Essentially I want an end user (who is using a Web App Builder application, or any of the suite of other online apps, like collector, survey123 etc.) to be able to submit a pre determined shapefile or feature into ArcGIS online. This shape would then be added to an existing feature layer that is stored on AGO. The shape could then be used for analysis within a web app builder application. Unfortunately the "Add Data" widget only adds data to the application, and doesn't allow many of the widgets to access the data to perform analysis, so it doesn't exactly help. Essentially I need the same functionality of the "Add Data" widget, but the data will actually be added to a feature layer permanently, which can then be used to select features with the batch editor.
... View more
12-06-2022
09:06 AM
|
0
|
0
|
557
|
POST
|
Hi Brian, the break is simply there to stop the loop at one iteration (one territory). Its just for testing (I stated in the blurb above). I can see how its confusing though. Ill edit my submission for clarity. Ill give the "Del" a shot.
... View more
11-18-2022
02:08 PM
|
0
|
0
|
1370
|
POST
|
Nice catch. I've changed that. Unfortunately still getting the same results.
... View more
11-17-2022
04:51 PM
|
0
|
0
|
1453
|
POST
|
Hello, I currently have an arc online tool that allows users to enter data for polygons based on their overlap with a larger territory layer. Unfortunately due to the nature of web app builder, the user is also able to enter values into a corresponding territory field (in the polygon layer), even if there is no overlap. Because of this issue, I am writing a tool that checks for these errors. Unfortunately I keep running into an issue. The two datasets look like this: Polygon layer: OID Territory1 Territory2 Territory3 Territory4 Territory5 etc..... 1 2 Response 3 4 Response Response Territory layer: OID FIELD_NAME 1 Territory2 2 Territory3 3 Territory4 4 Territory5 etc... etc... Essentially I want to select an individual territory (from the FIELD_NAME field), intersect it with the polygon layer, reverse the selection (so all polygons that are not within the territory are selected) and then test to see if that specific territory field within the polygon layer has any values in it. If it does, then there is an error and I want that to be displayed in an error field with the number of errors. Currently, my code seems to just be adding 1, regardless of any data that is incorrect/correct in the dataset. Keep in mind I have a break statement in my code, so after one iteration it stops (for testing). Any Ideas? Here is my code (ive changed the dataset names etc): def check_errors():
env.workspace = gdb_name
print ('--------------------------------------')
print("check_errors()")
arcpy.management.AddField('polygon_areas', "OVERLAP_ERROR", "LONG")
#create layers
polygon_layer = arcpy.MakeFeatureLayer_management('polygon_areas', 'polygon_layer')
territory_layer = arcpy.MakeFeatureLayer_management('territory', 'territory_layer')
print("layers created!")
overlap_error_count = 0
overlap_error_field = ["OVERLAP_ERROR"]
#clear error field:
update_cur = arcpy.da.UpdateCursor(polygon_layer, overlap_error_field)
for row in update_cur:
row[0] = 0
update_cur.updateRow(row)
print (' Cleared error field')
#-------------------------------------------------------------------------------------------------------------------------------
territory_fields = [
'Territory1','Territory1','Territory1','Territory1','Territory1','Territory1','Territory1','Territory1','Territory1', 'Territory1'
]
#cycle through each field that corresponds to territory name, check for errors
for name in territory_fields:
print("Currently Processing: " + name)
print(datetime.datetime.now())
#select a territory, intersect with the polygons, and select all polygons that fall outside of the territory
#do any rows have values within the territories field? Should be empty
arcpy.SelectLayerByAttribute_management('territory_layer', 'NEW_SELECTION', "FIELD_NAME = '" + name + "'")
arcpy.SelectLayerByLocation_management('polygon_layer', 'INTERSECT', 'territory_layer', "", "", "INVERT")
#look at the territory field, add a 1 to the error field if there exists data within the territory field
update_cur = arcpy.da.UpdateCursor("polygon_layer", [name] + overlap_error_field)
for row in update_cur:
if row[0] != "" or None or " ":
row[1] += 1
update_cur.updateRow(row)
print ('overlap errors calculated')
arcpy.CopyFeatures_management('polygon_layer', 'Polygon_features') Thanks in advance! Im pulling my hair out with this one.
... View more
11-17-2022
04:28 PM
|
0
|
6
|
1468
|
IDEA
|
Seconded. When over-writing a web layer, if any new fields are added in Arc Pro, the new fields show up at the end of the field list in the web map. And now there doesn't seem to be any way to reorder the fields in map viewer? Very frustrating.
... View more
11-03-2022
02:06 PM
|
0
|
0
|
1109
|
POST
|
Hello, I'm currently using the batch editor widget to update the fields in a set of feature views (3 separate layers). Each view points to the same feature layer. The issue arises when I try to use the batch editor to update the fields if the 3 feature views. Each field has a coded value domain (6 selections) with Null values allowed set to yes. I want a way for editors to be able to set the field to "no value" if they feel they need to edit a response / delete an entry. Unfortunately this option is not available for all fields, only the first in the list. Currently this field has no values entered into it. The No Value option shows. This will show even if there are values in the field. The rest of the fields, whether populated or not, do not display the "No Value" option - only the top field in the list. Any Idea why the No Value would only appear on the first field? I would rather not have to put a "Blank" or "Null" value in the actual domain list as this would complicate things, but this seems to be the only option if this is a bug. (also sorry for all the redacted text, I hope its still clear enough) Thank you!
... View more
08-31-2022
11:10 AM
|
0
|
1
|
770
|
POST
|
Hello, Im currently using the batch editor to take a feature layer (lets call it feature1) to intersect with another feature layer(feature2). The intersecting polygons are then edited (value changed) using the editor. My issue is that feature1, and the selected records used for the intersect are quite large (1000s of hectares) and select thousands of individual features from feature2. this passes the threshold of the widget as you can see from the disclaimer below. Is there a way to bypass this threshold? Perhaps in the JSON? I have yet to do much JSON editing so far so Im unaware of whats possible. Thanks in advance.
... View more
08-04-2022
01:45 PM
|
0
|
1
|
899
|
POST
|
Hello, Fairly new to python. By no means a beginner, but I still have trouble with logic. I'm currently trying to create a script which takes an ID field - if the IDs match up, then take the value from a name field, and concatenate together into a list, and fill out a concatenated list field (see table) I know i will have to use a update_cursor and a counter etc. the logic for whatever reason is escaping me on how to assemble the python. ID Name Name_cancat 33 hello Hello, hi, bye 33 hi Hello, hi, bye 33 bye Hello, hi, bye 44 red Red, tan, blue 44 tan Red, tan, blue 44 blue Red, tan, blue 88 dog Dog, cat 88 cat Dog, cat I know it will be something like this (obviously missing a ton of code/logic) with arcpy.da.UpdateCursor("FC", ['ID', 'name', 'name_concat']) as cursor: myList = [] for row in cursor: myList.append(row[1]) row[2] = myList cursor.updateRow(row) any help pointing me to a resource would be greatly appreciated!
... View more
07-20-2022
02:56 PM
|
0
|
4
|
1354
|
POST
|
Hello, I have a bit of an odd question. I currently have a point dataset that has been randomly generated over a land base. I want to create a set of polygons at said points, corresponding to an area field, where each polygon will be 1, 2, 3 or 4 hectares in size (this is done in a random fashion). I am able to achieve this by either using the buffer tool or by using the table to ellipse tool (where I need the major and minor axis), and simply adding a field within my point features which determines which size the polygon will be, and then creating an if statement that builds the size of the buffer/table to ellipse based on this... My question is, I am looking to find a way to generate polygons at these points that are not perfectly circular or an ellipse. I have a set of 4 pre-drawn polygon shapes (oblong/uneven shapes that are not exactly buffers/ellipse) which I would like to map at the same location of these points. Again, these polygons would be randomly set to each point, with a random designation of 1,2,3, or 4 hectares. I have 100s-1000s of points, so I would like to automate this, but I have not found anything that would be appropriate for this problem (other than a simple buffer or table to ellipse). I figure it would be some sort of copy operation, where a polygon is copied from a template, and then built at the point, but I'm not sure how to accomplish this. Again, a fairly odd problem, but I just want to cover my bases by asking the net. Thanks in advance!
... View more
10-21-2020
10:11 PM
|
0
|
2
|
734
|
POST
|
Hi Mehdi, I'm still not seeing changes in the data on ArcOnline unfortunately. from arcgis.gis import GIS
gis = GIS(url='xxxxxxxxxxxxx', username='xxxxxxxxxxx', password='xxxxxxxxx')
import datetime
from arcgis.features import FeatureSet, Feature
itemId = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
fs=gis.content.get(itemId)
#search for the feature layer/service
featureLayer_item = gis.content.search('type:"Feature Service" AND title:"xxxxxxxxxxxxxxxxxxxx"')
#access the item's feature layers
feature_layers = featureLayer_item[0].layers
flayer = feature_layers[0]
#query all the features and get the spatial dataframe
fset = feature_layers[0].query()
flayer_rows = fset.sdf
for index, row in flayer_rows.iterrows():
today = datetime.datetime.today()
if row['FromDate'] <= today <= row['ToDate']:
print("Updating feature layer ....")
print(row['FromDate'])
print(today)
print(row['ToDate'])
fset.features[index].attributes['Room_Status'] = 'Occupied'
#fset.features[0].attributes['Total'] = '1'
flayer.edit_features(updates = fset.features)
print("Feature layer is set to Occupied!")
else:
print("Updating feature layer ....")
fset.features[index].attributes['Room_Status'] = 'Vacant'
#fset.features[0].attributes['Total'] = '0'
flayer.edit_features(updates = fset.features)
print("Feature layer is set to Vacant!")
print("Complete")
It reads the dates correctly, and states the correct print out for each row: But then when looking at the data, The "Data Last updated" in the top right corner is correct (every time the script is run this is updated). Despite this, the Room_Status field is still the same as before the script is run (ie does not reflect the fromDate - ToDate field). Its like its able to read the data, but is not actually able to edit.
... View more
09-23-2020
11:09 AM
|
0
|
0
|
12794
|
POST
|
Thank you! This seems to run without issue...it moves through the rows (I had to change the 'vacant' to 'occupied' and vise versa for the logic to work), yet I do not see any change in my data once complete. The "last updated" text reflects this (it changes every time the script is run), just no change in the data. Any idea why this would be? - I have all the editing privileges set to edit/update/delete etc.
... View more
09-21-2020
08:16 AM
|
0
|
0
|
12794
|
POST
|
Hello! Im new to PythonAPI, still very much a novice. I'm trying to update some fields in an AGO feature layer from a script. Hopefully I will be able to set up a reoccurring task which will update the layer consistently. Every time the task will run I want my script to look at a field, and change another field based on what is there. The change will occur based on a FromDate and a ToDate field. These fields will be the cause of the edit, which will change a field from Vacant to Occupied, depending if the current time (now()) falls within the FromDate / ToDate times. In other words, When the current time is After the FromDate and before the ToDate, the field will be occupied. This is what I have so far: from arcgis.gis import GIS
from arcgis.features import FeatureSet, Feature
gis = GIS(url='https://pythonapi.playground.esri.com/portal', username='XXXXXX', password='XXXXXX')
itemId = 'xxxxxxxxxxxxxxxxxx'
fs=gis.content.get(itemId)
fl=fs.layers[0]
#this is where I get confused
features = not sure what to put here
for feature in features:
if FromDate <= Now() and ToDate >= Now():
newValue = 'occupied'
feature.set_value('roomstatus',NewValue)
else:
newValue2 = 'vacant'
feature.set_value('roomstatus',NewValue)
# update the features in AGOL
results = fl.edit_features(updates=features)
Again, super new to this so any advice would be appreciated! Thanks.
... View more
09-16-2020
08:11 PM
|
1
|
7
|
13076
|
IDEA
|
Yep! This is exactly what I need for a current project. This is a vital addition.
... View more
09-11-2020
11:25 AM
|
1
|
0
|
6488
|
Title | Kudos | Posted |
---|---|---|
1 | 09-16-2020 08:11 PM | |
1 | 09-11-2020 11:25 AM |
Online Status |
Offline
|
Date Last Visited |
02-22-2024
09:37 PM
|