POST
|
Hey all, I am trying to create a notebook that will look at how layers are shared in a few webmaps and (later down the line) send me a message when things are throwing errors or not shared properly. However, I am running into the 403 error saying "You do not have permissions to access this resource or perform this operation" even though I both own the layer and am an admin for my AGOL organization. Any ideas on what could be causing this? Just making a try/except to skip it isn't an option for that I need the script to do in the end. from arcgis.gis import GIS
import datetime as dt
import time
from arcgis.gis import GIS
from arcgis.mapping import WebMap
gis = GIS('home')
intelmanagerMap = gis.content.get("904575e13cf04ebfb9bdfc4ee0f48cbb")
wm=WebMap(intelmanagerMap)
for lyr in wm.layers:
try:
lyr_item = gis.content.get(lyr.itemId)
print(f"{lyr_item.title} shared with {lyr_item.shared_with}\n")
except Exception as e:
print(f"Something is wrong with {lyr.title}. Exception thrown: {e}\n") output: SARCOP Tasks v1 - debd1c shared with {'everyone': True, 'org': True, 'groups': []}
ee24a9 Sandbox v9 SIFS Intel Manager 1.0 View shared with {'everyone': True, 'org': True, 'groups': [<Group title:"SARCOP Sandbox v9 - 38f775" owner:afackler_napsg>]}
ee24a9 Sandbox v9 SIFS Intel Manager 1.0 View shared with {'everyone': True, 'org': True, 'groups': [<Group title:"SARCOP Sandbox v9 - 38f775" owner:afackler_napsg>]}
Something is wrong with Waypoint Triage Status View. Exception thrown: You do not have permissions to access this resource or perform this operation.
(Error Code: 403)
Something is wrong with Waypoint Search Type. Exception thrown: You do not have permissions to access this resource or perform this operation.
(Error Code: 403)
UAS Recon Photos Sandbox shared with {'everyone': True, 'org': True, 'groups': []}
... View more
03-27-2024
01:03 PM
|
0
|
1
|
248
|
POST
|
Thanks Jack! I ended up having to modify it a bit to look at layers in the map instead of the map itself, but overall, this solved what I needed! I ended up needing to append the group ID's into their own list and checking from there since the snippet above would look at each group as a new iteration (at least from what I could tell) and succeed and fail depending on each group. Since all the layers are shared to many groups, it would eventually get to the right group... after "failing" 3 times prior. Maybe this is a roundabout way of doing it, but it works for what I need it to webmap_item = gis.content.get("466b1d08ab8d4dcb9905e7c3a32eba27") wm=WebMap(webmap_item) groupID = "8e95e3c576304ab49f5fc8396f41484b" for lyr in wm.layers: sharedInto = [] if "itemId" in lyr: lyr_item = gis.content.get(lyr.itemId) for group in lyr_item.shared_with['groups']: sharedInto.append(group.id) if groupID in sharedInto: print(f"{lyr_item.title} is Shared to group\n") else: print(f"{lyr_item.title} is NOT SHARED\n")
... View more
03-27-2024
08:38 AM
|
0
|
0
|
162
|
POST
|
Hey everyone, I am working on a larger notebook but have ran into a stumbling block. Basically, the end result of the notebook is to check the sharing level of all layers in a webmap and see what layers are shared publicly OR shared to a specific group; in this case, the group is called "NSARGC 3 SARCOP Partnered Collaboration Internal Group - 41484b". I figured out the public sharing part but haven't been able to figure out the group sharing in line 8. For ease of reading, I simplified the script to print "Shared Correctly" or "Not Shared Correctly" since I can get the script to run from there. Does anyone have any ideas on how to look at a specific group? Thanks! wm=WebMap(webmap_item) for lyr in wm.layers: if "itemId" in lyr: lyr_item = gis.content.get(lyr.itemId) print(f"Layer {lyr.title} sharing: {lyr_item.shared_with}") if lyr_item.shared_with['everyone'] is True: print("Shared Publicly") if lyr_item.shared_with["NSARGC 3 SARCOP Partnered Collaboration Internal Group - 41484b"] is True: print("Shared to group") else: print("Not Shared Correctly")
... View more
03-25-2024
12:21 PM
|
0
|
2
|
212
|
POST
|
Hello all, I ran into this bug earlier today on one of my web apps. Does anyone know if this is another unannounced update issue or if there is anything I can try to fix it? Thanks!
... View more
01-25-2024
05:48 PM
|
0
|
0
|
37
|
POST
|
Hi Jessica, This is set up using Experience Builder. It's a been a minute since I looked at this, but I think I remember what I did. Basically I pulled in a web map (doesn't have to have the survey's layer), then pulled in the survey using the Survey widget in ExB. Within the survey settings that come up, I hit the switch to "Send data to this survey", chose the source layer (in this case it's basially a county layer). From there you can chose what fields get pulled over from the Field/question section by hitting "Add Connection". To get the geometry, use the *Shape field and place it into the question in your survey asking for the geometry. Here's a bit of documentation on this as well https://doc.arcgis.com/en/experience-builder/10.8/configure-widgets/survey-widget.htm and https://www.esri.com/arcgis-blog/products/experience-builder/real-time/using-experience-builder-and-survey123-to-pass-attributes-and-geometry-from-one-layer-to-another/. Hope this helps! Still haven't found an answer for my problem but I moved onto other projects and probably won't be coming back to doing this.
... View more
09-25-2023
01:11 PM
|
0
|
0
|
193
|
POST
|
Thanks for your response Ismael! I was able to make the view of the address locator, but no matter the combination of settings I set up I'm still getting place names. Any guidance?
... View more
09-20-2023
09:40 AM
|
0
|
0
|
340
|
POST
|
I have a survey where teams can update their location. Part of it uses a map so they can easily pin their location using location services on their phone and a few fields after that automatically fill out to give the address and such. However, I noticed that if you place a point on or near a business, you'll almost always get the business name and not the address. Example below. This is all set up in the web editor of Survey123 and I'd like it to stay there so anyone on my team can edit the survey if needed. Seems to be set up correctly, pulling the match address in the calculation, but it always tries to pull the place name instead of the actual address. Any way around this or do I just have to wait for Esri to push out an update?
... View more
09-07-2023
08:48 AM
|
0
|
2
|
477
|
POST
|
Still no bueno, images coming back corrupted or not functional like my reply a few hours back. And XY data still isn't coming over when I look at the properties
... View more
07-06-2023
09:56 AM
|
0
|
0
|
583
|
POST
|
Alright had to retrofit a bit by adding "exif_data=exif_data", otherwise it would fail. However, the XY data still isn't being preserved. See script below (also modified to work outside of a function, so there may be a few small differences from the original above) for file_name in file_list:
# Get the full path of the source file
source_file = os.path.join(source_folder_path, file_name)
# Check if the file is an image
if not os.path.isfile(source_file) or not file_name.lower().endswith(('.jpg', '.jpeg', '.png')):
continue
# Open the image using PIL
image = Image.open(source_file)
# image = source_file.exif_transpose(image)
# Resize the image
width, height = image.size
new_width = int(width * 0.5)
new_height = int(height * 0.5)
resized_image = image.resize((new_width, new_height))
# Preserve the geotag information
exif_data = image.info.get("exif")
resized_image.info["exif"] = exif_data
# Save the resized image to the destination folder
destination_file = os.path.join(destination_folder_path, file_name)
resized_image.save(destination_file,exif_data=exif_data)
... View more
07-06-2023
08:46 AM
|
0
|
2
|
602
|
POST
|
Would you be able to explain a bit more about which lines from your script to put where? I think I put it in wrong since my images came back corrupted (I think?)
... View more
07-06-2023
08:14 AM
|
0
|
4
|
608
|
POST
|
I am working on a python script that will later be used as a tool in ArcGIS Pro that will take the photos from a drone, resize them by 50%, then run a geotag-to-point process. Right now, the script is set to copy all the photos into a new folder called "images_resized" as a way to indicate that these are the photos to be used and uploaded while the raw unchanged photos stay in the root folder. The issue I am running into is that when I run the resize part of the script, I end up losing the key location data I need for the script to run properly. import os
import arcpy
from sys import argv
from datetime import date
from pathlib import Path
from PIL import Image
import shutil
source_folder_path = r"C:\Users\admin\Desktop\UASPhotos"
# Specify the destination folder path
destination_folder_path = r"{}\images_resized".format(source_folder_path)
# Create the destination folder if it doesn't exist
if not os.path.exists(destination_folder_path):
os.makedirs(destination_folder_path)
# Get a list of all files in the source folder
file_list = os.listdir(source_folder_path)
# Loop through each file in the source folder
for file_name in file_list:
# Create the source and destination paths
source_path = os.path.join(source_folder_path, file_name)
destination_path = os.path.join(destination_folder_path, file_name)
# Check if the file is an image (you can add more file extensions if needed)
if file_name.lower().endswith((".jpg", ".jpeg", ".png", ".bmp", ".gif")):
# Copy the file to the destination folder
shutil.copyfile(source_path, destination_path)
# Open the image file from the destination folder
with Image.open(destination_path) as image:
# Calculate the new width and height
new_width = int(image.width * 0.5)
new_height = int(image.height * 0.5)
# Resize the image
resized_image = image.resize((new_width, new_height)) I know it's during the resize because I tried just the copy and the photos still had the info, but as soon as I run the resizer the data is gone. Any ideas on how to preserve the essential metadata or any workaround? Edit: I also found and tried out some EXIF scripts basically running the code below but still the same result(replace after line 16 in the script above with this) for file_name in files:
# Get the full path of the source file
source_file = os.path.join(source_folder, file_name)
# Check if the file is an image
if not os.path.isfile(source_file) or not file_name.lower().endswith(('.jpg', '.jpeg', '.png')):
continue
# Open the image using PIL
image = Image.open(source_file)
# Resize the image
width, height = image.size
new_width = int(width * resize_percentage)
new_height = int(height * resize_percentage)
resized_image = image.resize((new_width, new_height), Image.ANTIALIAS)
# Preserve the geotag information
exif_data = image.info.get("exif")
resized_image.info["exif"] = exif_data
# Save the resized image to the destination folder
destination_file = os.path.join(destination_folder, file_name)
resized_image.save(destination_file)
# Close the image
image.close()
resized_image.close()
... View more
07-06-2023
07:36 AM
|
0
|
6
|
626
|
POST
|
Hello all, so here's what I am looking at doing: So I have a handful of photos that I run a geotag photo to point and I want to put the team name into the point attributes of those photos. Part of our workflow is when the team goes out they populate a "UAS Operating Zone" polygon using field maps (an AGOL feature layer) and what I want to do is take the team name field from the operating zone and put it into all the points' team name field mostly so we aren't duplicating efforts. The idea is if I get this working I can duplicate for the rest of the fields in the points layer. To manually do this workflow is a simple spatial join and field calculate, but it is proving to be more complicated when I do it in Python. The end goal is to make this into a script in a toolbox so anyone can use it. Below is my code so far and I'm getting the error "Invalid field UASTemp_AddSpatialJoin_11.team_name Failed to execute (CalculateField). I'm also not really sure if the spatial join is working, I am just assuming so since the error I am getting is coming from the field calculation. I took out the field mapping part parameter on the script below on the join just to make things easier to read on here but can add it back in if needed. Let me know what I'm missing and if there are any workaround. I am running ArcGIS Pro 3.1.2. import os import arcpy from sys import argv from datetime import date from pathlib import Path project = arcpy.mp.ArcGISProject("Current") m = project.activeMap # All the parameters pulled in from user inputs InputFolder = arcpy.GetParameterAsText(0) today = date.today().strftime('%Y%m%d') #Finds where the script is located and backs up to the root folder, that way the script can find the UAS geodatabase full_path = os.path.dirname(__file__) env = Path(full_path).parents[0] # Name the feature class OutputFeatureClass = r"{}\incident_data\imagery\2023_UAS_photos.gdb\UASTemp".format(env) # Geotagged Photos to Points arcpy.management.GeoTaggedPhotosToPoints(InputFolder , OutputFeatureClass , None, "ONLY_GEOTAGGED", "ADD_ATTACHMENTS") m.addDataFromPath(OutputFeatureClass) # Add and Calc TEAM NAME arcpy.management.AddField( in_table=OutputFeatureClass, field_name="team_Name", field_type="TEXT", field_precision=None, field_scale=None, field_length=255, field_alias="Team", field_is_nullable="NULLABLE", field_is_required="NON_REQUIRED", field_domain="") # Join arcpy.management.AddSpatialJoin( target_features=OutputFeatureClass, join_features="https://services.arcgis.com/XG15cJAlne2vxtgt/arcgis/rest/services/UASAO_v2/FeatureServer/0", join_operation="JOIN_ONE_TO_ONE", join_type="KEEP_ALL", field_mapping= match_option="WITHIN", search_radius=None, distance_field_name="" ) arcpy.management.CalculateField( in_table=OutputFeatureClass, field="{}.team_Name".format(OutputFeatureClass), expression="!UASTemp_AddSpatialJoin_11.team_name!", expression_type="PYTHON3", code_block="", field_type="TEXT", enforce_domains="NO_ENFORCE_DOMAINS" )
... View more
06-08-2023
01:58 PM
|
0
|
2
|
480
|
POST
|
I ran into an issue with the base map widget. My web map has a custom base map for our operations, but sometimes I need to swap to Imagery or something else. However, when I swap the base map to something other than the default, then want to swap back to the tactical base map, nothing happens. Does anyone have a workaround for this? Below are some screenshots and the app can be found here https://experience.arcgis.com/experience/9051a07ffd1947bbb395e9f9b4088f85/page/Intel-Manager-1_0/
... View more
05-03-2023
08:49 AM
|
0
|
0
|
176
|
POST
|
The issue here was that Pro needed an update. After updating to 3.1.1 it's working fine. Thanks all for your support
... View more
05-03-2023
08:40 AM
|
0
|
0
|
535
|
POST
|
Running the tool like the example, I get "ArcGIS for Desktop Advanced license not available" which I know is wrong because I triple-checked that I have the advanced license (screenshot below). When I run arcpy.CheckProduct("arcinfo") as is in the python window, I get the message 'AlreadyInitialized'. Another development, when I run the tool from the Python window after copying the python command from the geoprocessing pane it runs fine.
... View more
04-18-2023
02:17 PM
|
0
|
0
|
551
|
Title | Kudos | Posted |
---|---|---|
1 | 01-06-2023 02:17 PM | |
1 | 11-23-2022 08:36 AM | |
1 | 03-22-2022 10:10 AM | |
1 | 12-05-2022 10:41 AM | |
2 | 11-15-2022 07:48 AM |
Online Status |
Offline
|
Date Last Visited |
a week ago
|