|
POST
|
I would be keen to see your code if you could share please! It's mainly down to my entry/mid level python skills and not know what options there are or how to wield them. Self learning as you go and sticking with what is familiar.
... View more
06-25-2025
05:19 PM
|
0
|
2
|
637
|
|
POST
|
The scheduled task is on our GIS Server (not Esri Enterprise - Microsoft). I'm logged in with a service account and the task is registered to use the same service account. Besides the login process you can see at the start of the code in my original post, I also ensure that ArcGIS Pro has been signed into ArcGIS Online using my admin account which owns all the content and has all privileges. I wish there was a way of not relying on the ArcGIS Pro login as that always seemed like the mostly likely point to fail, but even with all that done, it still decides it not going to work in it's original format.
... View more
06-24-2025
05:07 PM
|
0
|
2
|
1126
|
|
POST
|
Great tips there - documentation so frequently doesn't get done well, or at all! I'm just as guilty as the next person there, though trying hard to change that. I don't want to be the one that lets it all fall apart in my absence!
... View more
06-22-2025
09:33 PM
|
1
|
1
|
1253
|
|
POST
|
Thanks for the added context. I have been playing with your code to try and implement it. Found a couple of easy errors and fixes early on, but working on through my logic and error shooting is starting to do my head in. Starting to think it's time to hire in some professional python help to give all my coding the once over and fix it where necessary and improve it where possible to make it more robust (like in your logic) and potentially check other things like security. I appreciate the time you've spent putting this together. Still valuable for myself as I try to improve my understand of python!
... View more
06-22-2025
08:57 PM
|
1
|
3
|
1259
|
|
POST
|
Sorry - I was in a bit of a rush so glossed over it a bit. It was still working when run via the Interpreter. But when called by Task Scheduler it has started to fail. It returns the below exception: Exception: cannot open 'https://services-ap1.arcgis.com/##########/arcgis/rest/services/PTNs_FPC416Polygons/FeatureServer/0' The URL is referencing the first feature service in the csv file. I just find this really bewildering. I write (however rough it might be compared the wizardry below from @HaydenWelch ) and test it. I set it up in Task Scheduler and monitor and it works just fine for weeks. Then all of a sudden I start getting these errors, but when I run it manually through the interpreter, it's perfectly happy. I spent some time on Friday reconfiguring parts of the code to use Feature Layers instead of ExportFeatures from arcpy. That seemed to work mostly, but now I get a different error on just 1 layer in the list 🤦Will give Haydens code below a good crack and see if I can make that work. All a good learning opportunity if nothing else!
... View more
06-22-2025
05:51 PM
|
1
|
9
|
1281
|
|
POST
|
I have the below script which does the following: Logs into ArcGIS Online Reads a feature service URL from a csv Uses that feature service URL to save a local copy of the data as a feature class Recalculates the relevant Area field in the dataset Disables the editor tracking on the feature service Uses UpdateCursor to match any updated records to the original in the feature service and updates the area value in the feature service Renables editor tracking Repeat for the next feature service in the csv. This script works when run in the interpretter, and has been running on our server when trigged by Task Scheduler overnight for some weeks. All of a sudden, now it doesn't. I'm getting told that the feature service URL is not a valid parameter for ExportFeatures, and also not compatible with Update Cursor (according to Copilot). I managed to find a way around the ExportFeatures issue by using Feature Layer to create a local copy. What I can't figure out is why this was working with no issues, now isn't despite no software updates being done on the server, or data configuration changes occurring. Has ArcGIS Online restricted the use of the feature service URL as a data source in arcpy? import arcpy
import time
import os
import csv
import tempfile
from arcgis.gis import GIS
from arcgis.features import FeatureLayerCollection
# Start Timer
startTime = time.time()
try:
import certifi
import urllib3
import ssl
import warnings
from urllib3.exceptions import InsecureRequestWarning
# Overwrite Output
arcpy.env.overwriteOutput = True
# Create a default SSL context with certificate verification
ssl_context = ssl.create_default_context(cafile=certifi.where())
http = urllib3.PoolManager(ssl_context=ssl_context)
# Make a request to verify the setup
response = http.request('GET', 'https://org-wa.maps.arcgis.com')
print("http response: " + str(response.status))
# Suppress only the single InsecureRequestWarning from urllib3 if necessary
warnings.simplefilter('ignore', InsecureRequestWarning)
# Create GIS object
print("Connecting to AGOL")
client_id = '#####'
client_secret = '#####'
gis = GIS("https://org-wa.maps.arcgis.com", client_id=client_id, client_secret=client_secret)
print("Logged in as: " + gis.properties.user.username)
# Create a temporary directory
temp_dir = tempfile.mkdtemp()
# Define the path for the temporary File Geodatabase
temp_gdb = os.path.join(temp_dir, "tempAreaHa.gdb")
# Create the File Geodatabase
arcpy.CreateFileGDB_management(temp_dir, "tempAreaHa.gdb")
# Set the workspace to the temporary File Geodatabase
arcpy.env.workspace = temp_gdb
def remove_last_part(url):
# Split the URL by '/' and join all parts except the last one
return '/'.join(url.split('/')[:-1])
def extract_fc_name(url):
# Extract the feature class name from the URL and clean it
path_parts = url.split('/')
fc_name = path_parts[-3]
return fc_name
# Read the CSV file containing feature service URLs
with open(r'\\gis-prod\orggis\Update\Feature Service Update Scripts\FeatureServiceAreaUpdates.csv', mode='r') as file:
csv_reader = csv.reader(file)
next(csv_reader) # Skip header row if present
for row in csv_reader:
featureservice = row[0]
fc_name = extract_fc_name(featureservice)
with arcpy.EnvManager(preserveGlobalIds=True):
temp_Areas = arcpy.conversion.ExportFeatures(
in_features=featureservice,
out_features=arcpy.env.workspace + "\\" + fc_name,
where_clause="",
use_field_alias_as_name="NOT_USE_ALIAS",
field_mapping=f'AreaHa "Area (ha)" true true false 0 Double 0 0,First,#,{fc_name},AreaHa,-1,-1;GlobalID "GlobalID" false false true 38 GlobalID 0 0,First,#,{fc_name},GlobalID,-1,-1',
sort_field=None
)
print(f"Features exported for {fc_name}")
# Determine which area field exists
fields = [f.name for f in arcpy.ListFields(temp_Areas)]
area_field = None
for candidate in ["AreaHa", "Area", "Hectares"]:
if candidate in fields:
area_field = candidate
break
if area_field:
print(f"Calculating area for field: {area_field}")
arcpy.management.CalculateGeometryAttributes(
in_features=temp_Areas,
geometry_property=f"{area_field} AREA",
length_unit="",
area_unit="HECTARES",
coordinate_system='PROJCS["GDA2020_Australian_Albers",GEOGCS["GDA2020",DATUM["GDA2020",SPHEROID["GRS_1980",6378137.0,298.257222101]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Albers"],PARAMETER["False_Easting",0.0],PARAMETER["False_Northing",0.0],PARAMETER["Central_Meridian",132.0],PARAMETER["Standard_Parallel_1",-18.0],PARAMETER["Standard_Parallel_2",-36.0],PARAMETER["Latitude_Of_Origin",0.0],UNIT["Meter",1.0]]',
coordinate_format="SAME_AS_INPUT"
)
print(f"Areas calculated for {fc_name}")
else:
raise ValueError(f"No matching area field found in {fc_name}. Expected one of: 'AreaHa', 'Area', or 'Hectares'.")
# Remove the last part of the URL
modified_url = remove_last_part(featureservice)
# Access the feature layer collection
flc = FeatureLayerCollection(modified_url, gis)
# Disable editor tracking
disable_params = {
"editorTrackingInfo": {
"enableEditorTracking": False
}
}
flc.manager.update_definition(disable_params)
print(f"Editor tracking disabled for {fc_name}")
# Create a dictionary from the exported table
sourceFieldsList = ['GlobalID', area_field]
valueDict = {r[0]: r[1] for r in arcpy.da.SearchCursor(temp_Areas, sourceFieldsList)}
# Update the feature service using the dictionary
updateFieldsList = ['GlobalID', area_field]
print(f"\nUpdating {area_field} field in {fc_name}...\n")
with arcpy.da.UpdateCursor(featureservice, updateFieldsList) as updateRows:
for updateRow in updateRows:
keyValue = updateRow[0].upper()
if keyValue in valueDict:
if valueDict[keyValue] != updateRow[1]:
for n in range(1, len(sourceFieldsList)):
print(f"Updating {area_field} for {updateRow[0]} from {updateRow[1]} to {valueDict[keyValue]}")
updateRow[n] = valueDict[keyValue]
updateRows.updateRow(updateRow)
del valueDict
print(f"\n{area_field} field updated successfully for {fc_name}")
# Re-enable editor tracking
enable_params = {
"editorTrackingInfo": {
"enableEditorTracking": True,
"enableOwnershipAccessControl": True,
"allowOthersToUpdate": True,
"allowOthersToDelete": True
}
}
flc.manager.update_definition(enable_params)
print(f"Editor tracking re-enabled for {fc_name}\n")
endTime = time.time()
print(f"\nScript completed in {endTime - startTime} seconds.")
except Exception as e:
if "The Product License has not been initialized" in str(e):
e = "\n\n" + r"ArcGIS Pro license not available."
if "cannot open 'https" in str(e):
e = "\n\n" + r"Login to ArcGIS Online failed - check ArcGIS Pro on the FPC-GIS-01 server is logged in using an Admin account."
if "Exception: Failed to execute. Parameters are not valid." in str(e):
e = "\n\n" + r"Either login to ArcGIS Online failed - check ArcGIS Pro on the FPC-GIS-01 server is logged in using an Admin account, or Parameters need fixing if changes have been made in ArcGIS Online to the input layers."
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
import smtplib, os
fromaddr = "GISNotifications@org.wa.gov.au"
toaddr = "gis@org.wa.gov.au"
msg = MIMEMultipart()
msg['From'] = fromaddr
msg['To'] = toaddr
msg['Subject'] = "Updating AreaHa field process failed (" + os.path.basename(__file__) + ")"
# Enter email body text below
body = "There has been an error in the script that checks and updates the AreaHa field in listed feature services. \n\nPlease check the script to troubleshoot any problems. \n\nException: " + str(e) # DON'T include URL's or links to the web in the body of the email or it might get blocked by the scam filters
msg.attach(MIMEText(body, 'plain'))
server = smtplib.SMTP('org-wa-gov-au.mail.protection.outlook.com')
#No login required so this section is commented out
#server.login("youremailusername", "password")
server.sendmail(fromaddr, toaddr, str(msg))
print ("\nScript failed - email notification sent to gis@org.wa.gov.au")
print ("\nException: " + str(e))
... View more
06-20-2025
01:34 AM
|
0
|
16
|
2040
|
|
IDEA
|
IDEA: In line with the option in Enterprise to include data classification schemas in the organisation settings, add the option to classify the sensitivity of data in ArcGIS Online. Use Case: When a feature service is loaded into an ArcGIS Pro map, the layer with the highest level of data classification will inform the overall sensitivity rating applied to a layout that would then be honoured as part of the export process (e.g. export to PDF) as per this related idea: Include Document Classification Functions in ArcGIS Pro's Export Layout to PDF
... View more
06-19-2025
06:45 PM
|
3
|
0
|
384
|
|
IDEA
|
Great addition! I haven't used Enterprise before so there's a whole new level of settings there that I don't get access to in ArcGIS Online. I think I'll have to add a separate idea to add that functionality to Online as well!
... View more
06-19-2025
06:21 PM
|
0
|
0
|
368
|
|
IDEA
|
Problem: In Microsoft Word, Excel and Powerpoint, plus Adobe PDF's, our organisation has enabled Add-ins that assign a document classification to every document/email. By default, each document receives the classification "Official" and we can then adjust it down or up to suit the required level of sensitivity. It's been asked that we start applying these categories to our exported PDF maps from ArcGIS Pro. From my research, it seems at present this can only be done doc by doc manually after exporting has happened in Adobe. This may be fine for the occasion map export, but we leverage Map Series to export dozens or hundreds of maps at a time and manually assigning a sensitivity category to each document is not an efficient use of time. IDEA: Include "Document Classification" that leverages the "Microsoft Purview Information Protection" to the Export Map/Layout pane under the Security settings. In Microsoft Word: In Adobe:
... View more
06-18-2025
08:36 PM
|
2
|
2
|
425
|
|
POST
|
Hi Dan - great question! I did a quick bit of testing and found an interesting result. I created a new point layer (very rough and ready) through ArcGIS Online, with a drop down category field. When loading it into a map, it simply had a "New Feature" option. I then added symbology to the layer using the "Category" field and refreshed the map. There were now feature templates included based on the symbology. I then deleted the feature templates in Field Maps Designer and refreshed the map again. In the webmap on my PC, I could no longer create a feature, but on my phone in Field Maps, it simply went straight to creating the feature with no prefilled info. It looks like you don't have symbology by category (or you do, but they're all the same - you could change that to a single symbol if that's the case). When I did this on mine (reverted to single symbol), refreshed Field Maps Designer and then hit the "Update" but on the Templates pane, a single feature type is loaded with no pre-filled info. I think this is what you want to do. If you do then want custom symbology based on attributes, I would apply that after this step so that it honours the single Feature Template. I hope that all makes sense - short answer is, Yes, you can remove the feature templates and go straight to a blank form. You just need to force it to go back to a single Feature Template with no pre-set fields.
... View more
06-16-2025
05:52 PM
|
0
|
0
|
614
|
|
POST
|
Are you referring to the grey bar that says "Filter" in your screenshot? That isn't a direct data filter. It's like a search bar where you can start typing to reduce the list of options to pick from when selecting which feature template you want to start with (each Feature Template can have prefilled answers with at least one being already set which is the list of feature types you see in the list). You can update the Feature Templates in Field Maps Designer as well. Go to Forms > select layer > select Templates at the top of the centre pane.
... View more
06-15-2025
10:20 PM
|
0
|
2
|
744
|
|
POST
|
Hi @KellyGerrow. Just wondering if the above outcomes are still the recommended best practice approach for including contractors in your ArcGIS Org. Can't find anything else that clearly discusses this in the last 10 years and was wondering if it's possible to setup groups that can't see content shared to the organisation yet, or if we should also pursue a 2nd org for managing contractors.
... View more
06-05-2025
12:17 AM
|
1
|
0
|
396
|
|
IDEA
|
Thanks for the link. I did search but didn't find that one.
... View more
04-08-2025
08:53 PM
|
0
|
0
|
445
|
|
IDEA
|
I just followed up on this after being approached by Esri to see if it was still a problem. We're now on 3.3.2 and it all seemed to work as advertised. Test results below. I tested by publishing a new feature service with 25,180 rows (polygons), then ran the whole lot through the Delete Rows tool ("Enable Undo" turned off). It took 1 min 51 secs to run (pretty good). I then ran the Append tool to upload the original 25,180 features again and that only took 55 secs to run.
... View more
04-08-2025
08:50 PM
|
0
|
0
|
272
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | Sunday | |
| 1 | 2 weeks ago | |
| 1 | 08-24-2025 06:11 PM | |
| 1 | a month ago | |
| 1 | 10-08-2024 09:01 PM |
| Online Status |
Offline
|
| Date Last Visited |
Monday
|