POST
|
That's great, happy to provide some direction, even if not the solution. I stumbled with this for a little while. I was able to set a default value for a hosted feature service in Pro just now. I wonder if that is a recently added capability? Attribute default values are a property of a specific feature template. You could create multiple templates with different default values for different situations. You can also select the default tool for editing, among other things I'm sure.
... View more
06-07-2023
03:51 PM
|
1
|
0
|
386
|
POST
|
You can do it with a table. https://community.esri.com/t5/arcgis-field-maps-questions/default-values-not-shown-and-not-configurable/m-p/1256698/highlight/true#M5312
... View more
06-07-2023
12:20 PM
|
2
|
0
|
692
|
POST
|
This is what worked for me: https://community.esri.com/t5/arcgis-field-maps-questions/default-values-not-shown-and-not-configurable/m-p/1256698/highlight/true#M5312
... View more
06-07-2023
12:19 PM
|
0
|
2
|
692
|
POST
|
Apparently I'm too deep down the rabbit hole to notice simple things like the version introduced. Clearly this won't work on 10.9.1. The more you know!
... View more
05-03-2023
12:36 PM
|
0
|
0
|
359
|
POST
|
I've been at this in every way imaginable (seemingly) and have determined two things. Thing 1: The ArcGIS API for Python does not work well. Thing 2: The ArcGIS REST API is poorly documented. Long story short, all I need to do is automate the task of reassigning content. Simple in concept, not in practice. You can't reassign certain items (Service Definitions) until their dependent items are reassigned, and in other cases, items shared to groups with update capabilities, can't be reassigned until unshared. Ok, I can work around that. Here's the process: Create dictionary of Item Properties > Unshare Item > Reassign Ownership > Re-share Item The Python API seems to hang indefinitely when it finds something it doesn't like, where at least with the REST API it will either succeed or fail with an error code that I can handle, so I've rewritten all my code using the REST API directly in Python rather than the Python API itself. Was this preferred? No. But does it work? Also no. Moving on, I'm finally at the point where I want to reassign ownership, but the documentation points me to an invalid URL, see: Reassign Items—ArcGIS REST APIs | ArcGIS Developers. What am I missing here? I finally have it solved using the following URL (that actually resolves): sharing_root_url/content/users/<username>/<folder_id>/items/<item_id>/reassign But...just..why?!? Seems like this should not have taken this long. Portal was supposed to make life easier? LOL. I'm not even asking a question here, just some light venting. Thanks for listening.
... View more
05-03-2023
11:02 AM
|
0
|
1
|
381
|
POST
|
You could try to truncate first, then append. Working in an enterprise database there are often more constraints in terms of permissions, locks, versions, etc.
... View more
03-08-2023
10:56 AM
|
1
|
2
|
395
|
POST
|
You should just be able to replace the out_fc_path variable with the path to your data...that could be an sde feature class. You'd point to your connection file, something like "P:/Folder/Folder/ConnectionFile.sde/GIS.DBO.FeatureClassName"
... View more
03-07-2023
04:51 PM
|
1
|
9
|
946
|
POST
|
@DonMorrison1 lol!!! 100 lines of code...or one? Thanks for posting. The simplicity of this versus iterating over the service and compiling the JSON responses is striking. I have the above code for an old customer that needed GeoJSON and it's faster to poll the service, but in the end who's counting!? In this case, if you just want the output, brevity wins! Well played sir!
... View more
03-07-2023
04:29 PM
|
1
|
0
|
432
|
POST
|
I do this kind of thing all the time! Love data mining. You have to group your requests in batches of whatever the max number of records that will be returned is, in this case 1000. Here's a code snippet I modified from something I use regularly. You can set it up to run on task to be fully automated. You'll have to put in your desired output paths and it should run. import arcpy
import requests
import json
import os
import sys
import traceback
from datetime import date
arcpy.env.overwriteOutput = True
class DataScraper():
def __init__(self):
# URL to map service you want to extract data from
self.service_url = 'https://apps.deq.virginia.gov/arcgis/rest/services/public/EDMA/MapServer/104'
def getServiceProperties(self, url):
URL = url
PARAMS = {'f' : 'json'}
r = requests.get(url = URL, params = PARAMS)
service_props = r.json()
return service_props
def getLayerIds(self, url, query=None):
URL = url + '/query'
PARAMS = {'f':'json', 'returnIdsOnly': True, 'where' : '1=1'}
if query:
PARAMS['where'] = "ST = '{}'".format(query)
r = requests.get(url = URL, params = PARAMS)
data = r.json()
return data['objectIds']
def getLayerDataByIds(self, url, ids):
# ids parameter should be a list of object ids
URL = url + '/query'
field = 'OBJECTID'
value = ', '.join([str(i) for i in ids])
PARAMS = {'f': 'json', 'where': '{} IN ({})'.format(field, value), 'returnIdsOnly': False, 'returnCountOnly': False, 'returnGeometry': True,
'outFields': '*'}
r = requests.post(url=URL, data=PARAMS)
layer_data = r.json()
return layer_data
# UTILITIES
def chunks(self, lst, n):
# Yield successive n-sized chunks from list
for i in range(0, len(lst), n):
yield lst[i:i + n]
if __name__ == '__main__':
# Can use date for naming iterative runs...
todays_date = date.today().strftime("%Y_%m_%d")
# Instantiate DataScraper class
ds = DataScraper()
# Specify where you want to save output JSON and feature class on your machine
out_json_path = rf"e:/data{todays_date}.json"
out_fc_path = rf"e:/data{todays_date}.shp"
# Function call to DataScraper class to get number of records, chunk up OIDs
# and send requests to serivce. Results are compiled into single JSON and then
# converted to shapefile/feature class at the end.
def scrapeData(out_json_path, out_fc_path):
try:
service_props = ds.getServiceProperties(ds.service_url)
max_record_count = service_props['maxRecordCount']
layer_ids = ds.getLayerIds(ds.service_url)
id_groups = list(ds.chunks(layer_ids, max_record_count))
for i, id_group in enumerate(id_groups):
print(' group {} of {}'.format(i+1, len(id_groups)))
layer_data = ds.getLayerDataByIds(ds.service_url, id_group)
if i==0: # If first iteration of id_groups
layer_data_final = layer_data
else:
layer_data_final['features'].extend(layer_data['features'])
print('Writing JSON file...')
with open(out_json_path, 'w') as out_json_file:
json.dump(layer_data_final, out_json_file)
print('Converting JSON to features...')
arcpy.conversion.JSONToFeatures(out_json_path, out_fc_path)
except Exception:
# Handle errors accordingly...this is generic
tb = sys.exc_info()[2]
tb_info = traceback.format_tb(tb)[0]
pymsg = f'PYTHON ERRORS:\n\tTraceback info:\t{tb_info}\n\tError Info:\t{str(sys.exc_info()[1])}\n'
msgs = f'ArcPy ERRORS:\t{arcpy.GetMessages(2)}\n'
print(pymsg)
print(msgs)
# Run the function to get your data
scrapeData(out_json_path, out_fc_path)
... View more
03-07-2023
12:52 PM
|
4
|
1
|
967
|
IDEA
|
Seems like Arcade would be an Experience Builder prerequisite and available everywhere. It didn't even occur to me that my Arcade popup expressions wouldn't be available in an EB app.
... View more
02-15-2023
01:36 PM
|
0
|
0
|
1764
|
IDEA
|
It would be awesome to have an OOTB widget that just simply exposed the SQL Expression Builder instead of requiring a predefined filter or query. I'm publishing a web experience highlighting an inspections table with 40+ fields and I would like my end-users to be able to choose their own query rather than preconfiguring them all. Is this not a thing already? Seems like it would be very easy to implement.
... View more
02-14-2023
02:22 PM
|
2
|
2
|
429
|
IDEA
|
I know it's a setting in the GP options, but would be nice to have as a counterpart to 'addOutputsToMap' to be able to force the option to remove layers that reference data overwritten by geoprocessing tools one way or another when using the Python window or a Notebook.
... View more
02-14-2023
10:50 AM
|
0
|
0
|
526
|
POST
|
Having a conversation with myself...but there is a setting in the Pro GP options that accomplishes this...thank goodness. Remove layers that reference data overwritten by geoprocessing tools
... View more
02-14-2023
10:41 AM
|
0
|
0
|
955
|
POST
|
Not sure when this was added but there is a setting in the Pro GP options now to self-select whether you want to retain layers that are being overwritten, or have them automatically removed. I was just struggling with this yesterday and this morning until I found it. Remove layers that reference data overwritten by geoprocessing tools
... View more
02-14-2023
10:41 AM
|
0
|
0
|
201
|
POST
|
Hi Dan, Thanks for responding. The issue I'm having is with the layers getting removed when their data sources are overwritten, not with the layers getting added in afterwards. I think ESRI is trying to keep house, so that when data is deleted it's removed from any maps, but in this context that's cartographic suicide. I'm overwriting the layer's data source, something I've been doing as a typical workflow for many years from the Python window, but now I'm seeing that when I overwrite a dataset, the layer is removed from the map, which causes a loss of all layer-related settings including symbology, labeling, participation in a legend or map series. I can't remember when I first noticed it but it makes the Python window and Jupyter Notebook rather useless to me for many workflows. I'm surprised more users aren't barking about this issue. I can just do my work in PyCharm or wherever else, but for hybrid workflows where you want to visually inspect results midstream, I love using the Python window or more recently a Notebook. Sad trombone. I attached a gif of the same workflow in ArcMap, data gets overwritten, layers become unavailable but never removed, then once the data is back the layers are refreshed.
... View more
02-14-2023
09:37 AM
|
0
|
0
|
964
|
Title | Kudos | Posted |
---|---|---|
1 | 06-07-2023 03:51 PM | |
2 | 06-07-2023 12:20 PM | |
1 | 03-08-2023 10:56 AM | |
1 | 11-07-2022 01:49 PM | |
1 | 03-07-2023 04:51 PM |
Online Status |
Offline
|
Date Last Visited |
07-27-2023
09:06 PM
|