Questions Answered: Explore the Power of the ArcGIS API for Python

3018
3
11-06-2017 05:58 PM
AmyNiessen
Esri Regular Contributor
5 3 3,018

On Wednesday, October 18th Ben Ramseth and Atma Mani teamed up to present the webinar, "Explore the Power of the ArcGIS API for Python". This webinar is part of the newly established GeoDev Webinar Series started by the Developer Outreach at Esri. These webinars were designed to keep an on-going discussion within the developer community about developer-related products, ideas, and APIs available from Esri and ways to continue assisting the developer community in leveraging their own projects with the use of our tools.

In this webinar, both Ben and Atma show attendees how the ArcGIS Python API can help in scripting and automating their tasks. They take the attendees on a tour of the API and demonstrate some of the powerful capabilities such as mapping, query, analysis, portal administration, and much more. 

Throughout the webinar, attendees send in their questions to get answered. At the end, Atma was able to address a number of questions, but was not able to get to all of them within the hour. We have included the remaining questions that came up during the webinar below. 

Q: Are tokens consumed differently if using the API for spatial analysis or geocoding?

A: No, tokens are used the same way, as when a user uses the http://arcgis.com map viewer.

Q: Are you going to share the notebook used in the webinar?

A: Yes…we will make the notebooks available via Github.

Q: Are you using Anaconda? Do you recommend using Anaconda Python?

A: Yes, we recommend using Anaconda. It comes with a lot of useful 3rd party packages. For users that have ArcGIS Pro, Anaconda ships with Pro, so no need to download and install it separately.

Q: Can I use it to geocode places in Africa like Sierra Leone?

A: Yes, the world geocoder with your ArcGIS Online account can be used to geocode the whole world.

Q: Can scripts use aspects of both ArcPy and Python API? For example, preprocess layers in desktop using ArcPy before uploading to portal using Python API all in one script. 

A: Yes, to use both ArcPy and Python API, install the API using ArcGIS Pro as explained here: https://developers.arcgis.com/python/guide/install-and-set-up/#Install-using-ArcGIS-Pro

Q: Can the ArcGIS API access an ArcGIS Server that is not part of a Portal?

A: Yes, we added support for stand-alone ArcGIS Servers.

Q: Can we set symbol renderer with ArcGIS API for Python?

A: Yes, checkout this useful resource where you can select a symbol of your choice and get the code for that symbol: esri.github.io/arcgis-python-api/tools/symbol.html

Q: Can we use a "Clip" tool in Python API?

A: Yes, you can clip both raster and vector layers. For instance, see this help https://developers.arcgis.com/python/guide/raster-analysis-advanced-concepts/#Clipping-to-an-area-of...

Q: Can we use Anaconda on Python 2.7?

A: No, the minimum version of Python required is 3.5.

Q: I am using ArcMap10.4.1 and Python 2.7. Then can I install Anaconda?

A: Yes, you can install Anaconda separately on your computer and install Python API using that Anaconda.

Q: Can we use for ArcGIS server map services?

A: Yes, the MapImageLayer class in arcgis.mapping module allows you use map services http://esri.github.io/arcgis-python-api/apidoc/html/arcgis.mapping.html#mapimagelayer

Q: Is it possible to consolidate both (ArcPy) and ArcGIS for Python into one?

A: There are no plans as of now to consolidate both these libraries into one.

Q: Do we need any ArcGIS licenses to use Python?

A: No, the ArcGIS API for Python is free to use.

Q: Can you please provide the link to the online documentation?

A: ArcGIS API for Python | ArcGIS for Developers 

Q: Can you talk a bit about building/updating web applications with ArcPy?

A: Jupyter project has a nice feature called 'Jupyter Dashboards' which were used in the demo. Using this, you can quickly prototype your dashboard style application all in Python. You can then decide to use a web dev language like JavaScript to build it. TO learn more about dashboards, go to http://jupyter-dashboards-layout.readthedocs.io/en/latest/

Q: Can you use python to create groups/subgroups to publish layers in ArcGIS portal?

A: Yes, checkout https://developers.arcgis.com/python/sample-notebooks/publishing-sd-shapefiles-and-csv/ and the rest of the publisher samples

Q: Can you use the API to automate the downloading of data from AGOL?

A: Yes you can. Check out this lab: https://developers.arcgis.com/labs/data/python/download-data/

Q: Can you use the Python API to update description sections in Story Maps? For instance, automate a nightly process to pull a description field text from a database row and overwrite an existing description section in a Story Map.

A: No, this is currently beyond the scope of the API. However, you can read the story map data using Item.get_data() method and make updates. Then call Item.update() method to push the changes.

Q: Can you use your custom created basemaps with the API?

A: We are adding support for this feature.

Q: Does analysis in Jupyter Notebook use credits?

A: Yes, it uses the same amount of credits as when doing it using ArcGIS Online


Q: Any Special instructions for installing the module with Conda behind a corporate proxy?  Is there a .tar file available instead?

A: Yes, you can perform an offline install. Instructions and helper scripts are here: https://developers.arcgis.com/python/guide/install-and-set-up/#Offline-install

Q: Hi all. Is possible to develop a spatial regression analysis (OLS, logistic regression) with this ArcGIS API for Python inside Jupyter? 

A: Yes, Python API can be used to read data from feature layer. Then using third party libraries like Scikit-Learn Ordinary Least Square regression or any other regression can be preformed. The results can then be published back to the GIS using the Python API.

Q: So I assume the dependent variable and independente variable can be set up in Sklearn through the columns of the attribute table of my feature layer. Right?I  have JSON files from a HTTP rest of a mobile app about destinations. Is possible to convert this JSON to GeoJSON with ArcGIS API for Python? And return this new GeoJSON to my HTTP rest and use this in ant webmapping with Web Appbuilder?

A: That is correct. We are adding support for GeoJSON, so not possible now.


Q: Can we define new widgets for Web Appbuilder with this API?

A: No, that is beyond the scope of the API

Q: What's the function we can use to copy Annotation feature class fastest with a where clause to a SDE database?

A: We would recommend looking into using ArcPy to accomplish this.

Q: If I have anaconda for Python 2.7, I have to install Anaconda for Python 3.6 for the ArcGIS API?

A: That is correct. You will have to install Python 3.x to work with the API.

Q:  I would like to bulk process a large number of landsat and sentinel images on the API without having to download them individually. Is there a way to invoke the respective Landsat and Sentinel libraries using the API? Also, if you have time, could you show a possible example of a "for loop" to process a certain number of images, perhaps looping a cropping process?

A: The best way is to create a mosaic dataset using the images and publish them as image services. Then you can define masks using raster functions which are equivalent to clipping. We will plan to write a sample explaining the workflow in future.

 

Q: How do you import ArcPy into your Jupyter Notebook?

A: You must install the Python API as explained here https://developers.arcgis.com/python/guide/install-and-set-up/#Install-using-ArcGIS-Pro. Then start the 'Python command prompt' app and type 'Jupyter Notebook'. Now you can import both ArcPy and the Python API.

Q: How is python API different from Javascript API ?

A: They are similar in that they both work with web GIS using the ArcGIS REST API. The difference comes in the purpose you would use each for. JS for building web app, Python for automating and managing your web GIS - users, groups, services, items, maps etc. And Python API allows you to make use of the rich data analysis ecosystem possible with Python.


Q: Can Python work offline and can it work in Demo?

A: Yes, it can. You would need an ArcGIS Enterprise in your disconnected network for the API to connect to and work offline.

Q: I have ArcMap on my computer. How do I get the ArcGIS API in ArcMap?

A: You need ArcGIS Pro to get Python API. Or you can install anaconda and install Python API. Instructiosn here: https://developers.arcgis.com/python/guide/install-and-set-up/.

Q: Do I need ArcGIS Pro installed to use the ArcGIS API for Python?

A: No, its optional.

Q: If you export code to .py and run, will maps open similarly to the Jupyter environment?

A: No, you need the Jupyter Notebook IDE to visualize the map widget.

Q: In the demos, everything is typed in the Jupyter Notebook by the user. But how do you script this in a file and how do you schedule this script (like with a task scheduler)?

A: You can use the API from a Python script instead of a Jupyter Notebook. But if you already have a notebook, you can download the notebook as a Python file from the File menu.

Q: Is it possible to combine both ArcGIS Pro ArcPy and Python API into one Jupyter Notebook to make use of both ArcGIS Online data connection and ArcGIS Pro analysis capabilities?

A: Yes you can. You need to install the API using ArcGIS Pro as explained here: https://developers.arcgis.com/python/guide/install-and-set-up/#Install-using-ArcGIS-Pro Then you can import both ArcPy and Python API into your scripts.

Q: Not very related to ArcGIS API: In ArcMap i was able to create AddIn, in future will be possible create Python AddIn in ArcGIS Pro?

A: Yes, you can make add-ins with Python; however, they are made with ArcPy, NOT the ArcGIS API for Python.

Q: On your online Jupyter Notebook site do you have a sample of using an SDE source to update ArcGIS online data?

A: No, we don’t have one. But, we will consider this for future.

Q: So at this point (locating address) you're creating a new point layer and filling in attribute fields just by geocoding that address?

A: Yes, thats correct.

Q: What about SAML say with Okta? 

A: Users with SAML are recommended to connect using Arcgis Pro. Help link is here: https://developers.arcgis.com/python/guide/working-with-different-authentication-schemes/#Connecting...

Q: What is the module for accessing and adminstering ArcGIS Server directly?

A: It is the 'server' module. Help doc here: http://esri.github.io/arcgis-python-api/apidoc/html/arcgis.gis.server.html#

Q: When I do a process in ArcGIS, can I see the process the Python script? For example, let's say I do some step to get the NDVI (Normalized Difference Vegetation Index). If I do a process for getting it, can I see this process that I did in Python?

A: If you used Python API, then yes, the Jupyter Notebook keeps a record of it

Q: When you are using the "tools" like buffer or hotspot are you consuming credits?

A: Yes you are consuming credits.


Q: Where are the iPython Notebooks you mentioned in your introduction? 

A: GitHub - Esri/arcgis-python-api: Documentation and samples for ArcGIS Python API 


Q: You say the Python API can be installed using ArcGIS Pro, does it install this jupyter program too?

A: Yes it does install Jupyter Notebook as well.

Q: You showed shapefiles to publish, what's the best way to publish geodatabase content using the API to enterprise or online?

A: You can zip your file geodatabase and publish that as a feature layer.

Q: Can the ArcGIS API for Python easily do with geo-analysis/process, similar to the toolbox in ArcGIS Desktop? I see arcgis.geoprocessing module in the online Reference page. But I do not see the sample code and wonder if this module can connect with tools in ArcGIS Toolbox. The reason to ask the question is that we have some complicated geo-processes at the desktop level. I wonder if the complicated geoprocess can be moved to AGOL.

A: The doc here explains how to use geoprocessing tools form Python API and contains sample code https://developers.arcgis.com/python/guide/an-introduction-to-geoprocessing/

Q: Can the ArcGIS API for Python connect with SQL Server? My organization only uses SQL Server.

A: Python API cannot direclty connect to your SQL server. However you can use Pandas library to connect to it, read data then use Python API to publish that layer to your GIS and make it available for rest of the analysis or processing.

If you do not see a question you have listed above, leave one in the comment section below, and we'll check it out and get you your answer!

To view the recording of this webinar, or any of our past webinars, please be sure to check out go.esri.com/geodev.

We look forward to seeing you at our next webinar!

3 Comments
EurecatBigDataAnalytics
New Contributor

Hi all,

Thank you very much for this great blog.

I just need a confirmation: is possible to build interactive web apps with the ArcGSI API for Phyton? Like this example:

https://developers.arcgis.com/python/sample-notebooks/building-a-change-detection-app-using-jupyter-...

To share as a webapp I need to use the Jupyter dashboard?

So, I want to build a interactive web app for geocluistering based on DBSCAN algorithm:

And I can create widget controls to:

- user can select the geographical area to perform the clustering;
- user can set the values of the 2 parameters of DBCAN, namely: "Epsilon (EPS)" and "Mininum Number of Points".

Is possible?

Best regards,

Francisco Gutierres
Eurecat - Technological Center of Catalunya, Spain

AmyNiessen
Esri Regular Contributor

Hi Francisco!

Yes, you can build interactive web apps that interact with the ArcGIS API for Python. There are not any classes in the ArcGIS API for Python that are used to directly build a web app interface.  Instead to make interface control, folks use other python packages to do this.  

 

If you are interested in building the interface right in Jupyter Notebook, check out Jupyter Dashboard. The is a sample in the help:

https://developers.arcgis.com/python/sample-notebooks/building-a-change-detection-app-using-jupyter-...

 

If you want a standalone web app outside of jupyter notebook, check out one of the python Web Frameworks:

https://wiki.python.org/moin/WebFrameworks

We hope this helps! 

EurecatBigDataAnalytics
New Contributor

Hi all,

I have a problem, the ArcGIS Python API with Jupyter Notebook is not displaying Maps. Always worked but since today when I use my_gis.map() any map isn't returned.

I already check this link but nothing is working.

https://community.esri.com/thread/180979

I am using Phyton 3 and Anaconda 3. Any idea?

Thanks,

Best

Francisco