POST
|
@Aravinthkumar , No, it returns all types of geometry as long as they are Feature Layers specified in the item_type and you have the right access to them. layer.properties.name.upper() will make all the layer name an upper case, so there is no need to worry about that. There should be something wrong either with your feature layers (e.g., types or names, ...) or your level of access (role) if you are searching other members' items.
... View more
01-31-2022
05:04 PM
|
0
|
1
|
3148
|
POST
|
@Aravinthkumar , If you mean the layers of a feature layer collection, then the following script should get you the layer name and layer id. Note that the first line is set to all layers but I have put a limit to go through 10 items. However you can change filter and/or increase the max_items value: layer_items = gis.content.search("*", item_type='Feature Layer', max_items=10)
for item in layer_items:
for layer in item.layers:
for lyr in layer.properties:
if "river" in layer.properties.name.lower():
print(f"Layer name: {layer.properties.name}, \tLayer ID: {layer.properties.id}")
break Cheers Mehdi
... View more
01-30-2022
10:36 PM
|
1
|
3
|
3162
|
POST
|
@Aravinthkumar , What layer items do you get when you run the first line followed by layer_items? layer_items = gis.content.search("river", item_type='Feature Service', max_items=100)
layer_items
... View more
01-26-2022
06:03 PM
|
1
|
5
|
3174
|
POST
|
@Aravinthkumar , The following code snippet lists up to 100 feature layers which contain "River" in their title along with feature layer owner, and their IDs: layer_items = gis.content.search("river", item_type='Feature Service', max_items=100)
for layer in layer_items:
if "river" in layer.title.lower():
print(f"Layer name: {layer.title}, \tOwner: {layer.owner}, \tLayer ID: {layer.id}") I hope that's helpful. Mehdi
... View more
01-24-2022
05:26 PM
|
0
|
7
|
3199
|
POST
|
Not a problem @JaimieNevins2. If my reply has answered your question, could you please Accept as Solution? Thanks.
... View more
01-23-2022
04:35 PM
|
1
|
0
|
854
|
POST
|
Hi @JaimieNevins2 , Here's a sample script which lists all the layer views of a hosted feature layer: from arcgis import GIS
from arcgis.features import FeatureLayerCollection
gis = GIS("portal_url", "username", "password")
source_item = gis.content.search("feature_layer")[0]
flc = FeatureLayerCollection.fromitem(source_item)
for view in flc.layers[0].manager.properties.adminLayerInfo.layerViews:
print(view.serviceName) Hope that helps. Mehdi
... View more
01-20-2022
06:24 PM
|
2
|
2
|
870
|
POST
|
Hi @mehdihamdoune , It should work if you first add the dlpk file to Portal/AGOL from Content > Add Item then get it in your script via item id as follows: detect_objects_model_package = gis.content.get(item_id)
detect_objects_model = Model(detect_objects_model_package)
detect_objects_model.install(gis=gis) I hope that helps.
... View more
11-21-2021
07:36 PM
|
2
|
2
|
3982
|
POST
|
Hi @tigerwoulds , Try the script below which gives you both urls: gis_servers_properties = gis.admin.servers.properties
for server in gis_servers_properties.servers:
print(f"Server URL: {server.url}, Server Admin URL: {server.adminurl}")
... View more
11-11-2021
06:43 PM
|
3
|
2
|
1256
|
BLOG
|
Introduction
Smartsheet is a dynamic workspace that empowers teams to manage projects, automate workflows, and rapidly build new solutions. Smartsheet uses spreadsheets, referred to as sheets, as the basis of everything it does, but the difference between Smartsheet and spreadsheet programs like Microsoft Excel or Google Sheets is that Smartsheet has all sorts of collaboration functionality incorporated into it.
The screenshot below is a sample Smartsheet data.
In this blog, we will update a point feature layer in ArcGIS Online (AGOL) with a Smartsheet dataset using ArcGIS API for Python. In the process, first we will convert this Smartsheet into a Pandas Data Frame, remove rows with no coordinates and then update the feature layer. It is notable that the data contains longitude and latitude in X and Y columns.
The following screenshot is the feature layer that has already been published as a hosted feature layer from the Smartsheet into AGOL before and after updates. As such both the hosted feature layer and the Smartsheet have the same schema and fields. This Smartsheet gets updated on a weekly basis. Therefore the hosted feature layer needs to be updated as well to reflect the updates on the web map. Using ArcGIS API for Python, this process can be automated.
Requirements
There are three items that are required before data conversion:
Install Smartsheet library by running this command “pip install smartsheet-python-sdk” in Python Command Prompt (here python is in D drive: “D:\ArcGIS\Server\framework\runtime\ArcGIS\bin\Python\envs\arcgispro-py3\Scripts>”)
Smartsheet Access Token - here’s a link which shows how to create one
Sheet ID – to obtain the sheet ID, in Smartsheet go to File > Properties > Sheet ID
Methodology
1. Smartsheet Conversion into a Data Frame
First import the modules.
Input the access token generated from the Smartsheet in the script below. After the Smartsheet authentication, a function is used to implement the Smartsheet to data frame conversion.
Input the sheet ID copied from the properties into the following script, then we call the function to create the data frame.
The rows with no latitudes or longitudes are removed.
Note that X and Y columns are the longitude and latitude coordinates respectively.
2. Export Data Frame into a CSV
Once the data frame is created, it is output as a temporary csv file in a folder. Here, a TEMP folder in C drive is used.
3. Upload CSV to AGOL
Connect to AGOL, then remove any existing csv item with the same title from AGOL.
When properties are set with title, description, and tags, upload the csv file to the Smartsheet's folder in AGOL. We can skip the description and tags here and can just use the title since this item is temporary and gets deleted when a new csv is added.
4. Truncate and Append
After that we get the hosted feature layer by id and we truncate it. This hosted feature layer becomes empty but still retains all the properties and settings.
Finally, we use the Append method to update this feature layer with the newly added csv file.
The good thing about using Append method is that the feature layer’s id does not change. This means that if the feature layer is already used in a web map or a web application, it will not break.
Now the hosted feature layer updated with the Smartsheet is displayed in the web map.
There are some points to note:
The hosted feature layer has initially been created from the same Smartsheet. Hence the schema, field names and types of both data are the same.
Append is currently only available in AGOL and cannot be used in Portal for ArcGIS.
I did not talk about the data used here as it can be any data as long as it contains coordinates since the emphasis is predominantly on the methodology.
This script can be used in e.g., Windows Task Scheduler to run on a regular basis for automation of the whole process.
Summary
Smartsheet integration with AGOL has been made easier and more efficient using ArcGIS API for Python with just a few lines of code. Therefore, when there are some updates in Smartsheet, these updates will automatically occur in the hosted feature layer whenever the script is run. This ensures the web maps and web applications such as Operations Dashboard display the latest features.
... View more
11-04-2021
07:32 PM
|
13
|
5
|
5212
|
POST
|
@JoePrimicias , The following python code extracts group members based on number of groups you want. (Here it's set to 10 groups). Just input the portal url, your credentials and the path to the output csv file. from arcgis.gis import GIS
import pandas as pd
gis = GIS(portalURL, username, password)
group_members_list = []
groups = gis.groups.search('*', max_groups=10)
for group in groups:
groupMembers = group.get_members()['users']
dictionary = {'Group Name':group.title,'Group Members':groupMembers}
group_members_list.append(dictionary)
df = pd.DataFrame(group_members_list)
df.to_csv(r'path to ...group_members.csv',index=False)
... View more
11-03-2021
06:18 PM
|
4
|
4
|
4436
|
POST
|
@ASLPipeline , There is also a simpler way of implementing this process. You don't need to use neither Geopandas nor GeoAccessor: from arcgis.gis import GIS
from arcgis.features import FeatureLayer
gis=GIS("https://arcgis.com",username, password)
Target_Layer = gis.content.get('{}'.format(layerid))
flyr = FeatureLayer("https://services1.arcgis.com/Hp6G80Pky0om7QvQ/arcgis/rest/services/DoD_Sites_Boundaries_Public/FeatureServer/0", gis=gis)
features = flyr.query(where="SITE_NAME='Eglin Air Force Base'")
for feature in features:
add_result = Target_Layer.layers[0].edit_features(adds=[feature]) Cheers Mehdi
... View more
11-02-2021
07:43 PM
|
1
|
1
|
5670
|
Title | Kudos | Posted |
---|---|---|
1 | 11-10-2020 04:59 PM | |
1 | 02-08-2021 09:29 PM | |
1 | 02-17-2021 04:47 PM | |
1 | 03-15-2024 02:35 AM | |
1 | 09-15-2021 06:18 PM |