POST
|
Looks like this is still an issue in ArcGIS Pro 3.3./Python API 2.3.0. If arcpy is available, @Vincentvd's solution works, but we had a need to find a workaround when arcpy wasn't available. I've had success using the authenticated session object for REST API and Sharing API calls to secured services instead of passing the token explicitly, like so (only tested on AGOL): import json
from arcgis.gis import GIS
gis = GIS("pro")
# Use the session from the GIS object
session = gis._con._session
# Example secured URL, doesn't have to be admin, just an example
update_definition_url = "https://services8.arcgis.com/XXXXXXXXXXXXXXXX/arcgis/rest/admin/services/XXXXXXXXXXX/FeatureServer/updateDefinition"
# Define some parameters for the update; again, just an example
update_def_params = {
'updateDefinition': json.dumps({
"capabilities": "Query,Editing,Create,Update,Delete,Sync"
}),
'async': 'false',
'f': 'json'
}
response = session.post(update_definition_url, data=update_def_params, timeout=10)
result = response.json()
print(result) This apparently provides a subclass of a Requests session, so you can use it in place of requests; e.g., session.get, session.post, etc. Your mileage may vary, but this solved the problem for me in a workflow where arcpy wasn't an option.
... View more
06-03-2024
04:01 PM
|
1
|
1
|
238
|
POST
|
Try this: import copy
def update_cyano_status(cyanoponds_features, overlap_rows, cyanoponds_lyr):
for CCC_GIS_ID in overlap_rows['CCC_GIS_ID']:
cyanopond_feature = [f for f in cyanoponds_features if f.attributes['CCC_GIS_ID'] == CCC_GIS_ID][0]
row = overlap_rows[overlap_rows['CCC_GIS_ID'] == CCC_GIS_ID].iloc[0]
cyanopond_feature_copy = copy.deepcopy(cyanopond_feature)
cyanopond_feature_copy.attributes['Cyano_Status'] = row['cyano_risk_tier']
resp = cyanoponds_lyr.edit_features(updates=[cyanopond_feature_copy])
print(f"Attempted to update Cyano_Status for {CCC_GIS_ID} to {row['cyano_risk_tier']}. Response: {resp}")
... View more
05-14-2024
03:22 PM
|
0
|
2
|
215
|
POST
|
Hi Samantha, can you remove the try-except so it just errors out with a traceback, so we can see what line it's tripping up on? Regarding the other post, I noticed that error. I'm reaching to out Esri to ask for permission to edit it (seems like you can't edit old posts).
... View more
05-14-2024
12:08 PM
|
0
|
4
|
225
|
POST
|
For Issue #2: try this to get a list of CCC_GIS_ID values where there has not been a sample in 30 days: def query_for_no_inspection_in_thirty_days(layer):
threshold_date = datetime.now() - timedelta(days=30)
query_result = layer.query(where=f"fluorometry_date < '{threshold_date}'", out_fields='CCC_GIS_ID')
ccc_gis_ids = [record.attributes['CCC_GIS_ID'] for record in query_result.features]
return ccc_gis_ids
no_fluorometry_in_30 = query_for_no_inspection_in_thirty_days(fluorsamples_lyr)
print(no_fluorometry_in_30) Then you can loop over those CCC_GIS_ID values and update the ponds: for CCC_GIS_ID in no_fluorometry_in_30:
cyanopond_feature = [f for f in cyanoponds_features if f.attributes['CCC_GIS_ID'] == CCC_GIS_ID]
cyanopond_feature.attributes['Cyano_Status'] = 'No updated information'
resp = cyanoponds_lyr.edit_features(updates=[cyanopond_feature]) Then do the same for the microscopy. Let me know how that works.
... View more
05-14-2024
10:49 AM
|
0
|
0
|
231
|
POST
|
Hi Samantha, regarding Issues #1 and #3: It's hard to tell for sure without access to your data, but it looks to me like you're writing a value from the fluorsample layer to the cyanoponds layer to populate Cyano_Status, instead of pulling the value from the dataframe you've built. Same for prior_activity. This might put you on the right track (let me know if I misunderstood something): def update_cyano_status(cyanoponds_features, overlap_rows, cyanoponds_lyr):
for CCC_GIS_ID in overlap_rows['CCC_GIS_ID']:
cyanopond_feature = [f for f in cyanoponds_features if f.attributes['CCC_GIS_ID'] == CCC_GIS_ID][0]
row = overlap_rows[overlap_rows['CCC_GIS_ID'] == CCC_GIS_ID].iloc[0] # get the matching row from the dataframe
cyanopond_feature.attributes['Cyano_Status'] = row['cyano_risk_tier'] # add the matching status value from the dataframe to the update dictionary
resp = cyanoponds_lyr.edit_features(updates=[cyanopond_feature]) # call the update
print(f"Attempted to update Cyano_Status for {CCC_GIS_ID} to {row['cyano_risk_tier']}. Response: {resp}")
... View more
05-14-2024
10:20 AM
|
0
|
6
|
310
|
POST
|
Old thread but thought I'd post this here in case Google brings anyone here. There is an update_definition method in the arcgis.features.managers module of the Python API, but it's been inconsistent for me. So I just make the call through the REST API. The code below enables layer optimization for the specified feature service item and layer index: from arcgis.gis import GIS
import requests
import json
gis = (portal_url, username, password)
item_id = '' # item id of feature service wih layer to optimize
item = gis.content.get(item_id)
layer_index = 0 # layer index in feature service for layer to optimize
update_def_url = f"{item.layers[layer_index].url}/updateDefinition".replace(r'rest/services',r'rest/admin/services')
token = gis._con.token
data = {'token':token,
'f': 'json',
'async': 'true',
'updateDefinition': r'{"multiScaleGeometryInfo":{"levels":[]}}'
}
result = requests.post(update_def_url, data=data, timeout=10)
status_url = f"{result.json().get('statusURL')}?token={token}&f=json"
status = None
while not status == 'Completed' and not status == 'Failed':
status = requests.get(status_url, timeout=10).json().get('status')
print(f"Optimization status: {status}")
time.sleep(10)
else:
if status == 'Completed':
logging.info(f"Layer drawing optimized successfully for {item.title} ({item.id})")
if status == 'Failed':
status = requests.get(status_url, timeout=10).json()
logging.error(f"Layer optimization failed for {item.title} ({item.id}). Status: {status.json()}")
... View more
05-07-2024
08:35 AM
|
0
|
0
|
168
|
POST
|
Thanks Brett, I added a vote for your idea. It's interesting that the status of your bug report is "In Review". Perhaps that's a hopeful sign.
... View more
04-30-2024
08:47 AM
|
0
|
1
|
272
|
POST
|
Yep, sounds like a job for Python. Feel free to tag me or PM me if you get stuck. My post from 2020 is a bit outdated now that you can schedule tasks in Notebooks (no need to have a computer always on, or use a third-party cloud environment).
... View more
04-27-2024
09:37 AM
|
0
|
0
|
258
|
POST
|
Just noticed that you have matching IDs (I missed that on the original post because I saw you were doing an intersect). In that case, a joined view should work. Did you set the join operation as one-to-one, only keep the first matching record, then sort by EditDate descending?
... View more
04-26-2024
03:56 PM
|
0
|
2
|
280
|
POST
|
I see - it sounds like you're trying to populate values in bulk for the whole table. If so, then you are correct, Forms is not meant for this. What you should expect from Forms is that when you go to edit a feature in the map (e.g., by clicking on it then clicking Edit in the popup), the value for the field where your expression is configured will be pre-populated with the value returned by the expression. The Arcade visualization profile doesn't support FeatureSets, so I don't know of a way to dynamically set the symbology in the way you're describing. Attribute Rules are not supported on hosted feature layers, so that's out as well. AFAIK, you'll need to calculate the values you want to use for symbology, either manually or with Python.
... View more
04-26-2024
02:10 PM
|
0
|
4
|
298
|
POST
|
With the pending deprecation of Field Maps on Windows, we're looking for a solution for distributing offline maps to rural public safety staff. Windows is an absolute requirement (they will be viewing maps on mobile data terminals in patrol cars), and they need to be able to see their position on the map (they have a GPS dongle plugged into the MDTs). Explorer meets all of these requirements, and as far as I can tell, is the only Windows app that does.* It still looks great and does everything we need it to do. According to ArcGIS Explorer (Windows) Life Cycle | Esri Support, Explorer is still in General Availability on Windows, and according to Deprecation: ArcGIS Explorer Deprecation (esri.com), there are no plans to deprecate Explorer on Windows. I'm hoping to gather some information/opinions on whether this is a viable solution, and how long we might expect Explorer to remain supported, since the life cycle page shows no retirement date. *We could kind of jam this into Survey123, but it's not designed for this and therefore has some limitations for our purposes.
... View more
04-26-2024
11:33 AM
|
2
|
4
|
377
|
POST
|
Have you tried logging those variables to the console, e.g., Console(RelatedReads) etc.? That might help you understand the values being generated by the expression to make sure your logic is getting the inputs you expect.
... View more
04-25-2024
07:13 PM
|
0
|
7
|
367
|
POST
|
I did some more testing, and our 4x map looks great on Explorer on Windows 11 without any modification. Arcade expressions work (including FeatureSets). Multiline labels and layer grouping from hosted feature layers. Created an MMPK and it works almost as well, but without curved labels. @RyanUthoff: ArcGIS Explorer (Windows) Life Cycle | Esri Support shows Explorer still in General Availability, which means patches/bugfixes should happen, maybe. It would be great if someone from Esri could confirm. It looks to still be fully supported, although I know the official recommendation is to move to Field Maps on iOS/Android. FWIW, our use case is a sheriff's office needing offline maps on their Windows-based mobile data terminals (ruggedized laptops mounted in patrol cars). Moving to Android or iOS just isn't possible.
... View more
04-25-2024
05:25 PM
|
1
|
0
|
378
|
POST
|
I've tested Explorer on Windows 11. It seems to work fine and is available from the Microsoft Store. I'm afraid to deploy to any production workflows since all the support links for Explorer in the Microsoft Store redirect you to Field Maps docs. It's unclear whether Explorer is still supported by Esri, or if so, what the Explorer support lifecycle might look like. But we are in a bit of a bind without a Windows 11 option that can show device location with offline capability.
... View more
04-25-2024
11:10 AM
|
0
|
1
|
390
|
POST
|
Thanks again Doug, very good point. I'm planning to use the pulldata("@property", 'mode') calculation on a hidden/null question to assign the survey mode to a variable, then use that variable in the relevant column for the second geopoint and the lat/long fields populated from it (e.g., ${survey_mode}!='edit')). This way those fields will only be calculated on initial submission.
... View more
04-12-2024
06:20 PM
|
1
|
0
|
311
|
Title | Kudos | Posted |
---|---|---|
1 | 09-06-2020 10:46 PM | |
1 | 09-05-2020 03:41 PM | |
1 | 06-03-2024 04:01 PM | |
1 | 04-25-2024 05:25 PM | |
2 | 04-26-2024 11:33 AM |
Online Status |
Offline
|
Date Last Visited |
Thursday
|