18

From Overview of the ArcGIS API for Python: The ArcGIS API for Python is implemented using the online and on-premises web GIS platform provided by ArcGIS Online and ArcGIS Enterprise respectively. The API has Python modules, classes, functions, and types for managing and working with elements of the ArcGIS platform information model. From ...


5

arcpy is installed with ArcGIS software and requires a license to use. It is meant to assist in automating complex GIS tasks and extending GIS functionality not available out of the box. It is still more granular than using ArcObjects however. The ArcGIS API for python is free to download but is meant to be used with "web GIS". "ArcGIS API for Python is a ...


4

After a few weeks getting up to speed on the ArcGIS Python API, I have come up with work flow that works quite well. My original understanding of scripting using JSON dictionaries was a bit off as well as the structure of FeatureLayerCollection, FeatureLayer, FeaturesSet, and Feature objects from the new API. My process thus far involves manually ...


4

Yes the ArcGIS API for Python can use the arcpy package if it is available in the current environment. arcpy is not required, but enables some additional functionality if available. For example: the arcgis.features.from_featureclass function accepts optional parameters if arcpy is installed; the arcgis.features.from_table function requires arcpy; and ...


4

For using ArcGIS API for Python, credentials have to be provided gis = GIS("http://www.arcgis.com", "username", "password"). from arcgis.gis import GIS gis = GIS("http://www.arcgis.com", "***", "***") help(gis) Information from help(gis) class GIS(builtins.object) | GIS(url=None, username=None, password=None, key_file=None, cert_file=None, verify_cert=...


4

It looks like 1200 and 450 are the dimension of the image in pixels, so the image is 1200 pixels wide by 450 pixels tall. The extent (first line of the cell) is in Web Mercator coordinates, so the pixx and pixy calculations are calculating the dimensions of a single pixel in terms of meters. For example the difference between xmax and xmin is 192,621 meters, ...


3

I had this problem due to changing the source name in the map doc after publishing the service. Thus, the source name in the service was different from the source name in the map doc. I had to look at the feature's Rest page to determine the original source name used when the feature service was published and changed the map doc to match.


3

Update based on OP's comment: To get the version of the ArcGIS API for Python package, the following snippet should work without first establishing a connection: import arcgis arcgis.__version__ on my machine outputs '1.5.2' looks like I need to upgrade If you wish to find the version without even importing arcgis at all, Raskar Kapak's answer would ...


3

I made a simple web map to test this out. For some reason none of my layers had the 'popupInfo' property mentioned in that geonet post ... but setting the 'disablePopup' property to false on all layers worked for me. import arcgis import json gis = arcgis.gis.GIS("https://arcgis.com", "username", "password") item = gis....


3

While there is no method in the ArcGIS Python API to convert from a SpatialDataFrame to a Geopandas GeoDataFrame, we can create a GeoDataFrame using another method. I will assume you are accessing your ArcGIS Online feature layer using the .query() method, which returns a FeatureSet. You can convert a FeatureSet into a geojson string, read the geojson as a ...


2

With the ArcGIS Python API from the help The output of this is a dictionary of all items (source_items_by_id). Do with them as you wish: from arcgis.gis import GIS source = GIS("https://host.esri.com/portal", "adminuser", "adminpassword") # Query Portal for all users, ignore admin and system accounts source_users = source.users.search('!esri_ & !...


2

Yes, 1000.0000 is how you would specify a 1:1000 scale when creating a cached tile service. I use 1:1155581.108577 as my greatest scale and the parameter I pass is 1155581.108577. Also, a tiled service is a REST service endpoint for a tiled layer. So they are not the same thing but when you make a request to a tiled service, you receive a tiled layer (or ...


2

You can only run a Python script against one version of the Python debugger at a time (2.7, 3.4, etc). If you have ArcMap, which runs against Python 2.x and the Python API (I'd assume you've installed Python 3.x and required dependencies), then you can't write a single script that calls import arcpy import argis In theory you might be able to write a ...


2

what if you add this: me = source.users.me me.folders for folder in me.folders: print(folder['title']) me.items(folder['title']) itemsInFolders = me.items(folder=f['title']) print(len(itemsInFolders)) for i in itemsInFolders: print(" " +str(i))


2

Using ArcGIS Pro 2.5 and making sure my feature service was editable with update privileges I was able to get the following line of code to work: arcpy.management.AddGeometryAttributes("https://services.arcgis.com/<myCode>/arcgis/rest/services/<MyLayer>/FeatureServer/0", "POINT_X_Y_Z_M", None, None, None)


2

I am not aware of a functionality in the ArcGIS API for Python to accomplish this. However, you can do a workaround and get the values by querying the domains of the feature service using the ArcGIS REST API. Using Python you would simply make the following request: import requests url = 'https:// <featureservice-url>/queryDomains' params = {'f': '...


2

When using PyScripter with arcgis pro you should call the IDE with a batch script, to activate the anaconda environment. There are batch files shipped with arcgis pro which i use to call PyScripter: @echo off set pyhome=%PROGRAMFILES%\ArcGIS\Pro\bin\Python\envs\arcgispro-py3 set pyscrpt=%~pd0\PyScripter\PyScripter.exe if not exist "%pyhome%" ( echo Can'...


2

Try using the UserManager with the Python API. The UserManager has an option for max_records which can be set to the number of users in your group from arcgis.gis import GIS import arcgis gis = GIS("https://www.arcgis.com", "USERNAME", "PASSWORD") # set first arguement to your Portal or AGOL users = arcgis.gis.UserManager(gis) ...


2

The only way to add a layer using Python/arcpy to ArcMap is using the arcpy.mapping.AddLayer function. This function works with mapping layers. No matter what you do in the ArcGIS for Python API, you'll never get back an arcpy mapping layer object. Meaning: you cannot simply do a search using the Python API, and pass that reference through to arcpy.mapping....


2

Your code is close, but there are a few things you're doing wrong with the properties you're passing into each call. Try the below code (specifically updating what you're passing for the properties and not passing in the itemId to the publish... the item itself knows which item it is, thus you don't need to give it this). import arcgis from arcgis.gis ...


2

The answer from @Taras is correct in how you can authenticate and startup the GIS object within the ArcGIS Python API -- there is, however, many ways to get started. See the Working with different authentication schemes help topic. In theory, you do not need to authenticate, you can start it up as an anonymous user to ArcGIS Online: gis = GIS() However, ...


2

The error is saying the UpdateCursor does not like the input, it is NOT a "table or featureclass". If you do a type on your layers, you'll see its an object specific to the ArcGIS Python API. And you're trying to use an arcpy cursor that wants either a table or feature class. l = f.layers[0] type(l) >> arcgis.features.layer.FeatureLayer However, the ...


2

You're running into the same problem/answer here: Adding data using Python from ArcGIS Online/ArcGIS REST Services directory to a ArcMap MXD --just reversing the layers and the map technology. You're trying to use an arcpy thing and put that into a ArcGIS Python API map. Basically, the layer you're trying to add to your map is not something the Python API ...


2

You can upload hosted tiled layers to AGOL which consist of images in a tile package. The process for doing this is different than uploading content such as the formats you mentioned. This documentation shows several methods; there are equivalent methods to perform this tile package upload to AGOL using the python API. I recommend that you get familiar with ...


2

As your code is now, you're doing a row-by-row update. This means the code needs to send 52,000 requests and get 52,000 responses -- at a minimum. As Vince points out in the comment, this is a quick operation when you're in the same network to an Enterprise Geodatabase. But over the web, through a service and ultimately into the data adds overhead. Per Vince,...


1

I have a vague memory of reading somewhere that the distance to only does euclidean distances, but I can't find a reference to it. Also you might actually try using PointGeometry, which accepts the spatial reference when you create the object. https://pro.arcgis.com/en/pro-app/arcpy/classes/point.htm https://pro.arcgis.com/en/pro-app/arcpy/classes/...


1

Very short code without handling any projection reference, it could start like that: from shapely.geometry import Point def distance(shape1, shape2): p1 = Point(shape1) p2 = Point(shape2) dist = p1.distance(p2) return dist * 111.132 shp1 = {'x': -118.78663214499994, 'y': 46.70276817100006, 'spatialReference': {'wkt': 'GEOGCS["NAD83(...


1

Based on the documentation found here https://developers.arcgis.com/python/guide/reverse-geocoding/, Location parameter The point from which to search for the closest address. The point can be represented as a simple list of coordinates ([x, y] or [longitude, latitude]) or as a JSON point object. reverse the order of the location. Either: ...


1

Based on the sample Notebook: Identify Items That Use Insecure URLs, the answer is yes, you can use the Python API to look through apps to determine their URLs. You'll write your code like: Make connection to the GIS (ArcGIS Online or your local portal) Do a search of the Org to identify all apps (webmaps, web appbuilder, whatever) Look through each item ...


1

So I figured it out. The issue I was having is that I wasn't referencing down all the way to the REST API URL. Once you give it the feature service URL page to your feature service then it works fine. Code provided below: from arcgis.gis import GIS import arcpy gis = GIS("http://arcgis.com", "XXXXXXXXX", "XXXXXXXXXXX") print("Credentials Verified") ####...


Only top voted, non community-wiki answers of a minimum length are eligible