Questions tagged [arcgis-python-api]
ArcGIS API for Python is a Python library for working with maps and geospatial data, powered by web GIS (ArcGIS Online, ArcGIS Enterprise portal).
185 questions
3
votes
1
answer
79
views
Truncate layer in ArcGIS Online using arcgis.gis
I'm trying to delete all features in a layer hosted in ArcGIS Online.
from arcgis.gis import GIS
from arcgis.features import FeatureLayer
#Login AGOL
gis = GIS("https://www.arcgis.com", &...
1
vote
0
answers
32
views
Clip Raster in ArcGIS Python API
It seems I cannot clip my raster using the ArcGIS Python API. I am trying to read the Elevation Imagery Layer from the ArcGIS Living Atlas and clip it by a Watershed area.
I first imported the USGS ...
0
votes
0
answers
31
views
Adding an existing web map into a new Story Map via Python
My ultimate goal is pretty simple: I need to create a Story Map, add a web map to it, then save and publish it all from a python notebook. The documentation is unclear to me about how to accomplish ...
0
votes
1
answer
64
views
Arcgis Python Api to create field map smartforms
I have been asked to create field map smartforms from the hosted feature layer & webmap.
Any example would be helpful!
My code seems to be not working, it does not create Form element.
from arcgis....
0
votes
1
answer
65
views
Filtering for deprecated items using Item Fields with ArcGIS Python API
ArcGIS Pro 3.1, Python 3.9
I'm using the ArcGIS Python API to connect to Portal (11.1) and AGOL to filter for deprecated items. According this reference doc, Item Fields can be passed to the query ...
1
vote
0
answers
41
views
Reload item with ArcGIS Python API [closed]
This tutorial shows how to easily download an item from an ESRI portal using the Python API. Can you open the item just downloaded in a different, offline, Python environment that doesn't have access ...
0
votes
0
answers
45
views
Displaying labels on points in Jupyter notebook using ArcGIS API for Python widget map
I'm trying to get labels working in my Jupyter notebook map, and I've tried everything I can think of.
Here's my code:
from arcgis.geometry import Point
from arcgis.features import Feature, FeatureSet,...
0
votes
2
answers
112
views
ArcGIS API unable to unshare item
ArcGIS Pro 3.1.4
Python 3.9
API version is 2.1.0.2
When I log into ArcGIS Online with an account that has a custom role with a few administrative privileges, I can share / unshare items owned by ...
1
vote
1
answer
58
views
GIS Object shows wrong Portal version
I'm connecting to Portal via the GIS object.
from arcgis.gis import GIS
portal = GIS(<my portal>)
print(portal.version) # gives [10,3]
But my portal is at version 11.1. That's what the Portal ...
0
votes
1
answer
370
views
How to refresh or overwrite a feature service using the ArcGIS REST API
I am trying to use the REST API from ArcGIS Online to refresh or overwrite a feature service.
I am using Python to upload an item using the addItem operation:
upload_url = (
f"{portal}/...
0
votes
0
answers
38
views
ArcGIS Online Python API Empty DataFrame return for Usage property on hosted raster tile service
I have a simple piece of code which I'm hoping I might be able to get a solution to. It specifically pulls usage for an item for the last 7 days or whatever desired date range. It appears to work fine ...
1
vote
1
answer
66
views
How to add a spatially enabled df to a Leafmap map
Python: 3.9
ArcGIS API for Python: 2.3.0.1
I am accessing a Feature Layer from the Living Atlas using the ArcGIS API for Python. I convert it to a sdf with the column 'SHAPE' as the geometry. How do I ...
0
votes
2
answers
151
views
ArcGIS API for Python - determine if feature service was published from ArcGIS Pro?
We publish most of our ArcGIS Online (AGOL) content from ArcGIS Pro, with the original data stored in local file Geodatabases. However, we have some layers that exist only in AGOL (eg, Survey123 ...
-1
votes
1
answer
188
views
Problem with installation ArcGIS Python library
I want to launch the Python tool, which is available here:
https://github.com/Esri/field-maps-scripts
but unfortunately there is no arcgis library
I tried several ways of installing this script:
...
1
vote
0
answers
70
views
Update Survey123 media via Python (not via republishing)
Using the example in the Developers.ArcGIS.com documentation I am trying to update a Survey123 form's media file pythonically. My modified version of the example code is downloading an empty Zip file.
...
1
vote
1
answer
176
views
Overwriting feature layer using lyrx file
I am trying to come up with a method that utilizes lyrx files to routinely overwrite a feature layer on ArcGIS Portal. I've tried a few methods that utilize Python scripts, ModelBuilder and Task ...
0
votes
0
answers
462
views
Error when connect to ArcGIS Server with Python API
I am working with ArcGIS Python API and trying to connect to a local server with the code:
gis = GIS(url="https://localhost:6443/arcgis", username="**", password="**", ...
0
votes
1
answer
53
views
How to detect cloud in time series Sentinel using ArcGIS Pro and Python
This is my code:
import arcpy
from datetime import datetime
from arcgis.gis import GIS
from arcgis.raster import ImageryLayer
# Connect to GIS (with authentication)
gis = GIS("https://www.arcgis....
0
votes
1
answer
565
views
How to return subtype and domain description instead of the code, when using arcgis.gis Python
I am working on some Python that takes an attribute table and makes a pandas df from it. I am doing this by creating an empty list, and looping through each record of the attribute table and making a ...
0
votes
1
answer
115
views
Convert .tif to imagery layer
I'm trying to run this notebook in ArcGIS Pro: https://developers.arcgis.com/python/samples/count-cars-in-aerial-imagery-using-deep-learning/#:~:text=imagery%20%3D%20gis.content.search(%22aerial*%22)
...
0
votes
1
answer
393
views
Overwriting hosted table in ArcGIS Online with CSV file from Pandas dataframe in Python
I have a script that I'm using to sort through a very large feature layer with thousands of records and create a summary table of them by type. It also calculates the count of records of the last 5 ...
1
vote
1
answer
817
views
Unknown error when trying to append to feature layer with ArcGIS API for Python
I am trying to perform an 'upsert' (UPDATE + INSER) operation on a feature layer via ArcGIS API for Python. My input data is a GeoJSON file that gets uploaded as per the available guides:
data_item = ...
0
votes
1
answer
185
views
Hosted layer in ArcGIS not getting updated
I'm encountering a peculiar issue while trying to add records to a Hosted Layer in ArcGIS using Python.
I am using ArcGIS Pro 3.1.3 with ArcGIS Enterprise 11.1. I am running this code from the Jupyter ...
0
votes
1
answer
195
views
df.spatial.to_featureclass produces an empty shapefile [closed]
I am using ArcGIS Pro 2.9.8 and Python 3.7 from the ArcGIS\PRO\bin\Python\envs\arcgis-pro-py3\python.exe.
I have a pandas dataframe from CSV I am trying to get to a shapefile or featureclass for a set ...
0
votes
1
answer
70
views
ArcGIS API for Python WebMap object move_to_basemap() method will not move the layer to the basemap
ArcGIS API for Python version 2.2.0.1
I have used the move_from_basemap() to move basemap to a layer.
from arcgis.gis import GIS
from arcgis.mapping import WebMap
## Access AGOL
agol = GIS("home&...
0
votes
1
answer
40
views
Accessing the UserInvitationManager class, ArcGIS Python API
How do I use the UserInvitationManager class with the ArcGIS Python API?
The documentation is scant and there are no examples.
I have a workflow that will involve inviting a separate account of mine ...
0
votes
1
answer
60
views
Setting/Un-Setting Service Lock Database Schema Property Using ArcGIS API for Python
Is there a way to set/unset a service Lock Database Schema using ArcGIS ArcGIS API for Python?
0
votes
1
answer
91
views
Create a new GPFeatureLayer from data frame
I am a complete newbie to ArcGIS/ArcPy. I am creating a new Python Toolbox, that reads in a GPFeatureLayer, and also should return one. I read in the values of a GPFeatureLayer row by row. Then I ...
0
votes
1
answer
71
views
Handling/troubleshooting errors with helper scripts in arcgis module
I am fairly new to python and need recommendations on how to handle internal/helper function failures.
I have a script that that imports a list of jurisdictions, then iterates through that list and ...
2
votes
1
answer
357
views
How to access layer using feature service URL/path
I am trying to access a feature layer within my Portal using the layers path. I have been accessing the data within Visual Studio Code using the feature layers ID like this:
feature_service_layer = ...
1
vote
1
answer
471
views
Accessing ArcGIS Portal user account using ArcGIS API for Python
Using ArcGIS API for Python on Portal, I need to see
from arcgis.gis import GIS
gis = GIS(url="https://xxx.xxx.com/portal", username="xxx", password="xxx")
print(gis....
-1
votes
1
answer
309
views
GeoAccessor (SEDF) spatial join is not working in ArcGIS Python API?
I want make a spatial join with my two spatially enabled dataframes. But while doing a join between the two dataframes. I got below errors.
joined_sedf = sedf_cables.spatial.join(sedf_sub_assignment[['...
0
votes
1
answer
251
views
ArcGIS Python API (gis.user.search)
Every time I run this code with a wild card (max_users = '*') or >140 I get this error
JSONDecodeError: Expecting value: line 1 column 1 (char 0). But are <140 value it works fine not just all ...
0
votes
1
answer
94
views
Issue with attribute types when publishing GeoJSON to ArcGIS Online
I'm trying to publish a GeoJSON file containing lines and points to ArcGIS Online. The publication process is successful, resulting in a Feature Layer with two layers - point and line. Everything ...
0
votes
1
answer
810
views
How to get description instead of coded value for a field with domain in hosted feature layer
I have a hosted feature layer with a field with a domain (coded values).
How do I get the description instead of the coded value?
The layer is in the TOC of an aprx, and I can retrieve the domain name ...
1
vote
0
answers
274
views
Extract list of content in a specific Portal webmap using ArcGIS API for Python
I would like to extract the lists of content (Feature & Map Image Service) including the type of base map. Also, wanted to know if all the layers are loading correctly using ArcGIS API for Python.
...
1
vote
1
answer
127
views
Cannot enable 'Any organization's members' setting when creating Group or updating properties using ArcGIS Python API [closed]
I am creating a group using the ArcGIS for Python API, there is limited information in the API Reference here.
And I found some more information in the Rest Reference relating to the membershipAccess ...
1
vote
1
answer
71
views
What do parameters provider_group_name and provider achieve in GroupManager create function when using ArcGIS Python API?
The create() function in the GroupManager module has two parameters; provide_group_name and provider.
See API Reference
What is the purpose of these parameters?
I cannot find any documentation ...
1
vote
1
answer
413
views
How to clone a copy using ArcGIS API for Python
What I am trying to do: Take a layer from ArcGIS Enterprise, clone it as a temporary file, overwrite a file in SQL DB, delete temporary file.
What I have tried so far:
def overwrite_existing_layer(...
2
votes
1
answer
370
views
"AttributeError: 'FeatureLayer' object has no attribute 'overwrite'" error when overwriting feature service with CSV using ArcPy
I am trying to download a CSV from our project database and then append this to a feature service in AGOL.
import os
import requests
import csv
import arcpy
from requests.auth import HTTPBasicAuth
...
1
vote
1
answer
399
views
ArcGIS Python API wont run in Docker
I built a Docker container to run one of our ArcGIS Python API scripts. It ran for a couple of months successfully. Recently I added some minor enhancements and rebuilt the Docker image. Thereafter, ...
1
vote
0
answers
174
views
Bypassing KeyError: 'type' when running a ArcGIS Online Python Notebook meant to overwrite organizational CSV
I have a scheduled organizational script that is only meant to be run during the summer and is left dormant for the winter as the data it scrapes is not maintained at that time. The reason I am ...
0
votes
1
answer
1k
views
Can you grab a JSON file off of an AGOL feature layer using Python API
I need to run a daily script that checks if data hosted on AGOL matches source data in an enterprise geodatabase. I'd like to convert the enterprise geodatabase table and a JSON file containing the ...
0
votes
1
answer
491
views
Trying to use UpdateCursor on Branch versioned layer - RuntimeError: cannot open workspace
I have a branch versioned service layer on ArcGIS Portal. I want editors to use ArcGIS Pro to open a map in a ArcGIS Pro project and use their respective versions of this layer to create new features ...
1
vote
0
answers
454
views
How to publish or replace the data to the feature layer hosted?
A little background: My teammate has created a hosted feature layer. I access the data of hosted feature layer using ArcGIS API for Python and pull the data.
The hosted feature layer he created doesn'...
0
votes
1
answer
541
views
Export out list of users and user types in Portal
I'm trying to export a list of Portal users and their user types. This is the code I'm trying to use but getting an error regarding the user.LicenseTypeId entry:
import csv
from arcgis.gis import GIS
...
1
vote
1
answer
784
views
Update Modified date or Summary field of AGOL hosted feature layer using ArcGIS API for Python
I am using a Python script (see below) in ArcGIS Pro to update two existing hosted feature layers on ArcGIS Online. The script deletes all records in the existing hosted feature layers and appends the ...
1
vote
0
answers
287
views
ArcGIS Python API append new record
I am trying to insert a python dict record to the hosted online service.
I am getting the following error:
Traceback (most recent call last):
File "", line 1, in
File "C:\Program Files\...
0
votes
1
answer
989
views
How can I automate a consolidated back up of all AGOL feature layers with python? [closed]
What I've Tried: I have used the script in this article before. However it does require more input than I would like, and the feature layers are downloaded as individual FGDB instead of into a single, ...
0
votes
1
answer
1k
views
List all maps in my Portal and list their corresponding layers
I am trying to list all of the maps inside of my Portal with the corresponding features that are inside. So far this is my code:
# Import necessary modules
import arcgis
import openpyxl
# Create an ...