POST
|
Reuben, Sounds like a necessary workaround but frustrating. I would be curious what your code looks like if you don't mind posting a sample. I am fervently hacking away at Python ArcGIS API to some success with basic functions. However I am 90% certain I encountered a bug that seems consistent with other wierd behavior I've noticed. This from the GIS module, specifically content.search. I hate how running the same search returns items in random orders each time. Now my task was to first upload shapfiles, then publish. In that process I uploaded shapfiles and published chunks at a time based off of tags. Anyways, I am going to put that post up in the form of a question prob over the weekend and I'll throw a link up here to see what you think. I need to read more background but is the Python API Open Source? Thanks for the response and the breakdown of the interesting workflow, Zach
... View more
09-23-2020
09:21 PM
|
0
|
0
|
2146
|
POST
|
Turns out to be more of an xml parsing problem than Arc. Swapped out the backslashes \ with forward slashes /. I used two // for good measure and my Item Description troubles were over. Good job Zach! Geonet Community abandoned me, but all is forgiven I still like you guys
... View more
09-23-2020
08:53 PM
|
1
|
0
|
498
|
POST
|
Reuben. Sorry for the delay. I'm definitely interested to hear how you solved this. Odd that you can manually download the feature services but Python is not working - assuming that it's an AGOL issue and not Python (?). If you want to post your script I'll take a peek. If you solved it to I would be interested in the solution. Thanks! Zach
... View more
09-20-2020
12:16 PM
|
0
|
2
|
2146
|
POST
|
This is the text in the Summary(Purpose) section of my Item Description as seen in ArcMap (right click Item Description): DATA_LOCATION: C:\Users\zach\Box\GIS\Project_Based\\GIS_Data\AGOL_DataUploads\2020_09_17\2020_09_17 DATE_RECEIVED: 09/11/2020 Once posted to ArcGIS Online as a shapefile and/or the published Feature Layer it becomes: DATA_LOCATION: 2020_09_17 DATE_RECEIVED: 09/11/2020 F R U S T R A T I N G !. This is important metadata and is being stripped. I don't understand. Originally I was editing the xml file in Python using xml.etree.ElementTree module. It worked well to batch update metadata to basically create or append new metadata in the xml that populates the Item Description. I tried in ArcMap manually to see if my xml updates in Python passed text with parsing issues BUT it occurs with Item Descriptions created in ArcMap and in Python. Clearly seems to be a text parsing issue but seems pretty negligent by ESRI to be stripping metadata. And yes, I've uploaded to AGOL then downloaded the same data and it comes back stripped as well. Please Help!
... View more
09-19-2020
04:58 PM
|
0
|
1
|
551
|
POST
|
Of course and...whoops! I got a little carried away and projected my own issues into your question. Basically I answered a completely different question. But those two lines from the Arcgis Python API can be used to log you in programmatically. Sounds like an interesting endeavor scheduling your code to run independently. I know the Airflow software (Scheduler — Airflow Documentation ) is popular for scheduling - it's Python and Open Source. No idea its compatibility with Arc stuff. But honestly the ArcGIS API is not that hard - don't be intimidated!
... View more
08-26-2020
12:03 PM
|
0
|
1
|
2609
|
POST
|
Hi Amber, I've recently been on the same path and have developed / scrounged / assembled some functionality for adding data to an ArcGIS Online Group I own. I will provide some Python scripts, BUT you need Python 3 to use the the Python ArcGIS API. So the code to get you going is minimal, but getting a Python 3 environment may be where the heavy mental lifting and possible exacerbation comes in. However, I am no computer genius, I simply installed Arc Pro which will install Python 3. I run my scripts through the command line in Conda environments. If you are not familiar with the Command Line, I can respond with some instructions on getting started there. Here is some code you can save in a script and run(<script_name>.py i.e. add_to_agol.py) or run from Arc Pro Python console (that exists right?). Line 5 is where you access your AGOL account, line 37 adds your zipped shapefiles. from ArcGIS.gis import GIS
import os
# username and password are your ArcGIS Online login credentials
your_gis_name = GIS(username = 'your_username', password = 'your_password')
print('Connected to {} as {}'.format(your_gis_name.properties.portalHostname,
your_gis_name.users.me.username))
# the outDir variable is a path to a folder. The folder will contain one or
# more folders with zipped shapefiles (i.e. <filename>.shp, <filename>.prj, etc.)
outDir = 'path/to/parent/folder/with/zipped/dirs '
# this will create a list of paths to each zipped feature folder
# if zipped subdirs appear in folder as: agriculture.zip, forests.zip, commercial.zip
# scandir orders file paths ALPHABETICALLY! So...
# zipped_dirs = [path/to/agriculture.zip, path/to/commercial.zip and path/to/forests.zip]
zipped_dirs = [subD.path for subD in os.scandir(outDir)]
# Make tags, title, snippet
# since zipped_dirs will order alphabetically the title, tags and snippets
# need to be ordered to match zipped dirs as if they were arranged alphabetically
title = ['agricultural lands', 'commercial_property', 'forests']
# tags can be a list of lists if multiple tags per item or a simple list
# with strings if just one tag per item
tags = [['land_project', 'agricultural'],['land_project', 'commercial'],
'land_project', 'forests']
# snippets
snippet = ['some agricultural lands in Kentucky', 'proposed development sites',
'where forests are classified']
# add items to your ArcGIS Online Content
for idx, shp in enumerate(zipped_dirs):
properties_dict = {'title':title[idx],
'tags':tags[idx],
'snippet':snippet[idx]}
fc_item = your_gis_name.content.add(properties_dict, data = shp)
Here is a link for setting up Python 3 through the Command Line Python and ArcGIS Pro 2.2 That blog also mentions that many people just use Arc Pro, similar to the Python Console in ArcMap I imagine. Dan Patterson has dozens of useful blogs on setting up Python, Pro, Conda, etc. Dan Patterson . Here is one that has multiple links to traverse /blogs/dan_patterson/2018/07/01/arcgis-pro-your-conda-environments . * Note he recently set up a new username if you need future content * And here is the ArcGIS Python API tutorials from which I gleaned those two lines of code using the GIS module Using the GIS | ArcGIS for Developers Good luck! Let me know what you find out and where you get hung up... Zach
... View more
08-25-2020
01:17 PM
|
1
|
3
|
2609
|
POST
|
Seems there should be a way to send messages to an entire Group that I own right? Members have organizational accounts but are from different organizations. I posed this question on Friday as a programming question - Format smtp notifications to Group members, arcgis-online - But at this point I would be fine with going through the ArcGIS Online directly. I don't see buttons or tabs or any way to send a Group message. How do I send messages to my Group members? Just FYI I am abandoning the Python API route because I didn't get any responses and for one-off messages I am fine to use functionality online. The problem with that route was that my Python text with linebreaks: 'Dear Guys\n\nHere is my message body.\n\nThanks\n\nZach' - is not formatting Python text. Just comes out as one big string in e-mail body when passed to notify function. group_name.notify([group_members_to_sent], 'subject', 'msg_body', 'e-mail') Thanks, Zach
... View more
08-24-2020
08:37 AM
|
2
|
1
|
459
|
POST
|
Hello again. I want to send a simple e-mail to members from an ArcGIS Online Group. A general version of the script is provided at the bottom. PLEASE help me if you know how to format the email_body for the (it appears) smtp message. My main concern is FORMATTING the email_body because the message protocol clearly does not recognize Python string delimeters - the newlines and tabs are not being produced, just one long sentence basically. I have found really helpful resources for more heavy-duty automated messaging (for instance: Send Email When a Feature is Added to an ArcGIS Online Hosted Feature Service ) BUT it does not appear I can access e-mails of Group members, so I am confined to the Arcgis Python API using the Group.notify method. from arcgis.gis import GIS
from arcgis.gis import Group
# get gis object
my_gis = GIS(username = <my_username>, password = <my_password>)
# Group User Info: dict with keys - owner, admins, users
my_group = Group(my_gis, <group_id_number>)
members_dict = my_group.get_members()
# give me list of user names from group
group_users = members_dict['users']
subject = 'Changes and updates to group'
signature = 'Zach <Lastname\>nGIS Specialist\n(123) 456-7890\tmyemail.com'
email_body = '''Hi everybody,\n\nWe have changed some content and protocol
updated and added metadata to the existing datasets -
feature layers and shapefiles - and did other stuff.
\n\nFeel free to contact me if you have questions.
\n\n'''.format(signature)
my_group.notify(group_users, subject, email_body, 'email')
... View more
08-21-2020
02:18 PM
|
0
|
2
|
702
|
POST
|
Ok. Might take me awhile to wrap my head around and use them properly. I know it's simple but there is definitely a union between the two that takes finesse to differentiate. Thanks Robert!
... View more
08-06-2020
11:31 AM
|
0
|
0
|
665
|
POST
|
UPDATE: It was indeed a Permissions issue, but a little more nuanced. The gdb the guy was sharing needed to set Permissions to Organization AND share to my group: KRRP_Geospatial. I think just the Organization was not sufficient for my purposes and Edit Group Sharing was necessary. Here are the screenshottted instructions:
... View more
08-05-2020
02:59 PM
|
1
|
0
|
2146
|
POST
|
Thanks Lukas (late response by me!!). I briefly tried your first link awhile back but since then I was able to get going on ArcGIS Pro and easily access the Python ArcGIS API. The SECOND link you posted includes similar code to mine below in a response by Dong-gyun Kim. I partially cannibalized parts from this Tutorial on the ArcGIS Python API page - Accessing and managing groups | ArcGIS for Developers. Here is what I settled on...pseudocode = 1) Prepare lists for Titles, Tags and Snippets. 2) Login to AGOL 3) Upload shapefiles (zipped): # 1) Tags, Titles and Snippets
# Create a list for each of the three where len(list) = n shapefiles
# 1a) TITLE
zipped_dirs = ['full/path/to/file1.zip', 'full/path/to/file2.zip', 'full/path/to/file2.zip']
# Option A - use file names for Title: 'file1.zip' into 'file1' OR do this:
title = [dir[:-4] for dir in os.listdir(zipped_dirs)]
# Option B - list file names manually/custom
# title = ['wetland birds', 'wetland sasquatch', 'wetland skunk cabbage']
# 1b) TAGS
# tags get a little wierd because I make a list of lists. I wanted multiple tags
# for each shapefile. There are programmatic ways to make lists of lists if
# you have a bunch of shapefiles and manual creation is time consuming...
tags = [['wetland', 'birds'], ['wetland', 'sasquatch'], ['wetland', 'skunk cabbage']]
# 1c) SNIPPETS
# snippets could have separate items within the list for each shapefile as well.
# For my purposes I was find with the same for each.
snippet = ['wetland observation data current as of 7/13/2020'] * len(title)
# 2) GIS stuff: login with credentials
zach_gis = GIS(username = 'myusername.com', password = 'mypassword')
print('Connected to {} as {}'.format(zach_gis.properties.portalHostname, zach_gis.users.me.username))
# Group object for a group. The string of letters, numbers is from url
some_group = Group(zach_gis, 'a6384c1111111a43bfd91f5d9723912b')
# 3) AGOL Add data to Content and Groups
for idx, shp in enumerate(zipped_dirs):
properties_dict = {'title':title[idx],
'tags':tags[idx],
'snippet':snippet[idx]}
fc_item = zach_gis.content.add(properties_dict, data = shp)
fc_item.share(groups = 'a6384c1111111a43bfd91f5d9723912b')
... View more
08-05-2020
02:46 PM
|
2
|
0
|
1753
|
POST
|
I have some initial thoughts on why one over the other, but these two organizational tools seem pretty redundant right? Tags can just be abstracted up to Categories. I imagine the main functional difference is that tags are used online more for filtering data. Can someone explain to me WHY Categories are a thing and share their use cases that make them necessary. I am managing data and maps for a large project, primarily with non-GIS folks (biologists, engineers) so they just want ways to filter the data, view it and order maps with particular feature layers. For instance for Wetland Survey Spring 2020 I may tag it: 'Wetland' and 'Current'. Then replace 'Current' with 'Archive' once 2021 hits. Thanks for the insight! Zach
... View more
08-05-2020
02:05 PM
|
0
|
2
|
722
|
POST
|
I should have held off another 10 months - marked the 10 year anniversary of this post. It worked!!! Just changed the print statements into fav_fruit = 'cantalope'
print('my favorite fruit is {}'.format(fav_fruit)) And good to go --> Python 3.6
... View more
07-21-2020
04:14 PM
|
0
|
0
|
2523
|
POST
|
Thanks Lucas (not the first time you've solved my queries!). Marking this as the tentative solution. Pretty sure that's my problem. I'll update if I learn otherwise.
... View more
07-20-2020
04:05 PM
|
1
|
0
|
2146
|
POST
|
Hi, I am the owner of an ArcGIS Online organizational account. Somebody shared a Feature Collection in a group within my organization that I intend to download. The person is essentially transferring the data to me, at which point i can add it to my Content and share with the group. There is no option to download data directly on ArcGIS Online. I think this is a simple ownership level issue. On the Feature Layer page the options are: View in SceneViewer or MapViewer or ArcGIS Desktop. When I upload data to the group there is a download or save data option. In this case in the Overview tab --> Sharing Level is set to 'Owner' of whom I am not. It is owned by the guy who shared it. How do I download this data? FYI I endeavored on this journey using ArcGIS package to get my scripting reportoire operational. Here is code ``` my_org_gis = GIS(username = 'my_username', password = 'sssshh, secret')
# 5 is the feature id in my content
feature_collection = my_org_gis.content.get(5)
fp_download = 'path/to/download'
gdb_name = 'eagle.gdb'
result = feature_collection.export(gdb_name, 'File Geodatabase')
``` And the meat of the error message: ---> RuntimeError: You do not have permissions to access this resource or perform this operation. (Error Code: 403)
... View more
07-20-2020
11:52 AM
|
0
|
7
|
2275
|
Title | Kudos | Posted |
---|---|---|
2 | 08-24-2020 08:37 AM | |
2 | 07-13-2020 07:48 AM | |
1 | 08-05-2020 02:59 PM | |
2 | 08-05-2020 02:46 PM | |
1 | 08-25-2020 01:17 PM |
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:23 AM
|