IDEA
|
Add the address search widget to the web UI would allow users to search for a specific location to view tracks. A client is using Tracker for snow plow routes and needs to be able to quickly search for and address to verify when and if the street was plowed or treated.
... View more
02-04-2020
01:42 PM
|
0
|
1
|
101
|
POST
|
This is a shame, especially since they deprecated the spatial dataframe and replaced it with the spatially enabled dataframe. Not only is it less idiomatic, but it produces this error (while the original SDF does not).
... View more
12-09-2019
12:37 PM
|
0
|
0
|
84
|
POST
|
I made more progress. I want to change this script so it actually uses the add_to_definition method from the API (since it would probably make my script less verbose), but for now, this works. Below is a modified of my final script (because it's doing something slightly different than what you want), but this snippet might be helpful too. I haven't tested this exact script, but it should work. Just input the service URL of your table (it has to uploaded to AGOL first, doesn't matter where it is) and the item ID of where you want to add the table. Again, haven't tested this for a feature layer instead of a table. EDIT: test this on some dummy data first. I've had addToDefinition go wrong before and pretty much delete all my data (but it was okay b/c it was dummy data). The finalized script shouldn't do that, but still test it. from arcgis . gis import GIS from arcgis . features import FeatureLayerCollection , FeatureLayer import json , requests url = 'https://www.arcgis.com' user = 'username' pw = 'pw' gis = GIS ( url , user , pw ) def build_json ( table , name ) : # turn PropertyMap type to list of dictionaries (PropertyMap is not JSON # serializable) fields = [ ] for i in table : d = { } for k , v in i . items ( ) : d [ k ] = v fields . append ( d ) # assumes field OBJECTID is your objectIdField temp_json = json . dumps ( { 'layers' : [ { 'name' : name , 'type' : 'Table' , 'objectIdField' : 'OBJECTID' , 'fields' : fields } ] } ) return temp_json def add_to_definition ( origin , add_json , table_name ) : token = gis . _con . token flayer = FeatureLayerCollection . fromitem ( origin ) url = f '{flayer.service.url}/AddToDefinition?token={token}' # build URL to POST to payload_add = { 'addToDefinition' : add_json , 'async' : 'true' , 'f' : 'json' , 'token' : token } session = requests . Session ( ) result = session . post ( url , data = payload_add ) print ( result ) def main ( ) : ago_table = FeatureLayer ( 'URL to your feature layer' ) origin = gis . content . get ( 'ID of the feature class you want to add data to' ) table_name = ago_table . properties . name fields = ago_table . properties . fields add_json = build_json ( fields , table_name ) add_to_definition ( origin , add_json , table_name ) if __name__ == '__main__' : main ( )
... View more
10-02-2019
07:01 AM
|
0
|
0
|
115
|
POST
|
I recently got something to work, and it may be of use to you. It uses the requests Python library instead of the ArcGIS Python API (I couldn't get that to work either). I just POST to the addToDefinition tool and it adds a table. Looking through this thread helped me quite a bit. Still working on adding a relationship. Of course, change type to "Feature Layer" if that's what you want, I've only gotten a table working. from arcgis . gis import GIS from arcgis . features import FeatureLayerCollection import json import requests gis = GIS ( 'https://www.arcgis.com' , 'user' , 'pw' ) feature_item = gis . content . get ( 'ITEMID' ) flayer = FeatureLayerCollection . fromitem ( feature_item ) token = gis . _con . token url = f '{flayer.service.url}/AddToDefinition?token={token}' print ( url ) add_json = ''' { "layers" : [ { "name" : "Maintenance_py", "type" : "Table", "objectIdField" : "FID", "fields" : [ { "name" : "reference", "type" : "esriFieldTypeGUID", "alias" : "reference", "sqlType" : "sqlTypeOther", "nullable" : false, "editable" : true, "length" : 38, "visible" : true, "domain" : null, "defaultValue" : null }, { "name" : "MaintDate", "type" : "esriFieldTypeDate", "alias" : "Maintenance Date", "sqlType" : "sqlTypeOther", "length" : 8, "nullable" : true, "editable" : true, "domain" : null, "defaultValue" : null }, { "name" : "MaintType", "type" : "esriFieldTypeString", "actualType" : "nvarchar", "alias" : "Maintenance Type", "sqlType" : "sqlTypeNVarchar", "length" : 256, "nullable" : true, "editable" : true, "visible" : true, "domain" : null, "defaultValue" : null }, { "name" : "Notes", "type" : "esriFieldTypeString", "actualType" : "nvarchar", "alias" : "Notes", "sqlType" : "sqlTypeNVarchar", "length" : 256, "nullable" : true, "editable" : true, "visible" : true, "domain" : null, "defaultValue" : null }, { "name" : "CreationDate", "type" : "esriFieldTypeDate", "alias" : "CreationDate", "sqlType" : "sqlTypeOther", "length" : 8, "nullable" : true, "editable" : false, "domain" : null, "defaultValue" : null }, { "name" : "Creator", "type" : "esriFieldTypeString", "alias" : "Creator", "sqlType" : "sqlTypeOther", "length" : 50, "nullable" : true, "editable" : false, "domain" : null, "defaultValue" : null }, { "name" : "EditDate", "type" : "esriFieldTypeDate", "alias" : "EditDate", "sqlType" : "sqlTypeOther", "length" : 8, "nullable" : true, "editable" : false, "domain" : null, "defaultValue" : null }, { "name" : "Editor", "type" : "esriFieldTypeString", "alias" : "Editor", "sqlType" : "sqlTypeOther", "length" : 50, "nullable" : true, "editable" : false, "domain" : null, "defaultValue" : null }, { "name" : "FID", "type" : "esriFieldTypeOID", "actualType" : "int", "alias" : "FID", "sqlType" : "sqlTypeInteger", "length" : 4, "nullable" : false, "editable" : false, "domain" : null, "defaultValue" : null } ] } ] }''' payload = { 'addToDefinition' : add_json , 'async' : 'false' , 'f' : 'json' , 'token' : token } session = requests . Session ( ) result = session . post ( url , data = payload ) print ( result )
... View more
09-25-2019
12:08 PM
|
3
|
2
|
115
|
POST
|
This sadly didn't work. I cleared the cache, logged in and out, and tried the same in incognito mode. Maybe I'm calling the fgdb . delete ( ) function too soon. Perhaps if I created a list of FGDBs deleted, and then called a function to delete all those FGDBs that would work. Just spit-balling.
... View more
05-22-2019
07:36 AM
|
0
|
0
|
37
|
POST
|
I use a Python script to export an item to a FGDB, download said FGDB and then delete it. The script successfully deletes the FGDB, but when I go to the AGOL account, it is still there, and I am unable to remove it. When I try to delete the item I get: And when I try to view the item in AGOL, I get: Below is my script (some of which I got from another user on this forum, but I can't find the thread): from arcgis . gis import GIS from datetime import datetime from pathlib import Path from zipfile import ZipFile import time , os , zipfile print ( 'Initializing...\n' ) gis = GIS ( site , user , pw ) print ( 'Logged on...\n' ) fs = gis . content . get ( 'XXXXXXXXXXXXXXXXXXXXXXX' ) print ( f 'Exporting Feature Service to FGDB - {fs.name}' ) fs . export ( fs . name + '_temp' , 'File Geodatabase' , parameters = None , wait = 'True' ) # search for fgdb and get item id while True : try : print ( 'Locating FGDB' ) search_fgb = gis . content . search ( query = fs . name + '_temp' ) print ( search_fgb ) fgb_item_id = search_fgb [ 0 ] . id fgdb = gis . content . get ( fgb_item_id ) break except IndexError as e : print ( e ) print ( 'FGDB does not exist yet' ) data_path = Path ( './monthlyDownload' ) if not data_path . exists ( ) : data_path . mkdir ( ) print ( 'Downloading FGDB' ) fgdb . download ( save_path = data_path ) '''while statement runs until a valid zipped file is created''' ## randomly the output is a 1 KB file that is not a valid zipped file. ## The while statement forces a valid zipped file to be created. print ( 'Finalizing zip file' ) zipfullpath = os . path . join ( data_path , fs . name + "_temp.zip" ) #full path to the zipped file once it is downloaded to your computer while zipfile . is_zipfile ( zipfullpath ) == False : fgdb . download ( save_path = data_path ) # delete temp FGDB in AGOL print ( 'Deleting temporary FGDB' ) while True : try : fgdb . delete ( ) except RuntimeError : break
... View more
05-21-2019
01:05 PM
|
0
|
2
|
188
|
POST
|
I am trying to configure email notifications for the Citizen Problem Reporter (local government ArcGIS Solution) per these instructions. I configured the Send Emails tool and tried running servicefunctions.py but get the following error from the log: ERROR: Failed to process service https://services1.arcgis.com/stuff/arcgis/rest/services/stuff/FeatureServer/0 (504, b'5.7.4 Unrecognized authentication type [stuff.stuff.prod.outlook.com]') I am not sure what is going on. I see this error pops up in other softwares when setting up SMTP. Some of the advice I've seen is to specify a port number, but I don't see where I can specify a port number. Does this have anything to do with the new TLS change? Let me know if further clarification is needed.
... View more
04-29-2019
10:53 AM
|
0
|
2
|
399
|
POST
|
I am trying to setup an inspection workflow using Collector and related tables (or Survey123). Not sure which to use yet. FYI, we are using ArcGIS Online for this. Here are my requirements: Use existing feature service to create inspections against (1 feature, many inspections) Start with Collector, click on a feature, either view past inspections or start a new one. User can also start with Survey123 and see a list of features to inspect. Display 3 previous readings of pump runtimes in the parent feature pop-up that were recorded from previous inspections. Not sure how to pass data from inspections back to main feature (parent) into specific fields Calculate the difference between the present and previous reading in either the main feature pop-up or the inspection form. I have seen ways to pass data from a feature service to Survey123 through the custom URL, but I also need to pass data back to the main feature service from either the related table or Survey123. Thank you in Advance!
... View more
11-28-2018
10:57 AM
|
0
|
1
|
355
|
POST
|
When trying to sync data from the field, we are getting the following error message I've tried to do some research on what could be causing the issue, but it seems like a pretty generic error message that could be any number of things. Hoping to narrow it down and figure out what the problem is. Thanks in advance for the help.
... View more
06-27-2017
02:50 PM
|
0
|
1
|
862
|
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:23 AM
|