Skip navigation
All Places > ArcGIS API for Python > Blog
1 2 Previous Next

ArcGIS API for Python

20 posts

Quite often, people wonder how to use the ArcGIS API for Python to update layer symbology. After a quick search through posts and documentation, one may discover that there are a number of ways to accomplish this and find oneself uncertain of how to proceed. If you land on this page my hope is that everything will start to make a bit more sense. In this post I'll go over:

  1. How to update layer symbology in a Web Map
  2. How to update layer symbology on a layer item
  3. How to update symbology on a Feature Service Layer

 

If the above all seem the same don't worry - presently, the distinctions between #1, #2, and #3 will become clear and you will get a better sense of when you might want to choose one method over another.

 

Note: Although I'm illustrating how to update symbology, you can apply the same concepts to update/configure other properties such as pop-ups, labels, etc. I encourage you to build upon the below standalone scripts or use only the parts you need!

 

 

How to Update Layer Symbology in a Web Map:

Let's suppose you add this Map Service to your content in ArcGIS Online/Portal for ArcGIS: https://sampleserver6.arcgisonline.com/arcgis/rest/services/USA/MapServer

 

You add the item to a Web Map and for a little while it suits your needs:

initial_webmap

 

But one day you decide that you don't really like the color orange and would get more use out of the Web Map if you could better visualize total population of each county.

 

After some time, you settle on the symbology included in the attached webmaplyr.json. It's a bit a long so I won't include it here - this is fine because you probably won't want to define the JSON in your script anyway, preferring to read from a file.

 

Note:

If you don't know where to get started as far as generating your own JSON don't fret. Simply start by creating a Web Map exactly as you want it to appear (apply styles, labels, options, etc.). From there, you can go to (where itemID is the item id of the Web Map):

 

Alternatively, you can get the JSON using the ArcGIS API for Python with a few lines:

from arcgis import GIS
import json

conn = GIS("https://machine.domain.com/portal", "admin", "password")
item = conn.content.get(<itemID>)
item_data = item.get_data()
# Include the below line for prettified JSON
print(json.dumps(item_data, indent=4, sort_keys=True))

 

 

The below script illustrates how to read your prepared JSON from a file and apply it to the Web Map:

from arcgis import GIS
import json, sys

def search_item(conn,layer_name):
    search_results = conn.content.search(layer_name, item_type='Web Map')
    proper_index = [i for i, s in enumerate(search_results) if
                    '"'+layer_name+'"' in str(s)]
    found_item = search_results[proper_index[0]]
    get_item = conn.content.get(found_item.id)
    return get_item

def update_wm_layerdef(item):
    item_data = item.get_data()

    print("*******************ORIGINAL DEFINITION*********************")
    print(json.dumps(item_data, indent=4, sort_keys=True))
    # Open JSON file containing symbology update
    with open('/path/to/webmaplyr.json') as json_data:
        data = json.load(json_data)

    # Set the item_properties to include the desired update
    item_properties = {"text": json.dumps(data)}

    # 'Commit' the updates to the Item
    item.update(item_properties=item_properties)

    # Print item_data to see that changes are reflected
    new_item_data = item.get_data()
    print("***********************NEW DEFINITION**********************")
    print(json.dumps(new_item_data, indent=4, sort_keys=True))

def main():
    conn = GIS("https://machine.domain.com/portal",
               "admin", "password")
   
    # Search for item, get item data)
    item = search_item(conn, 'wm_lyrsym')
    update_wm_layerdef(item)

if __name__ == '__main__':
    sys.exit(main())

 

After the script runs, you end up with the below:

updated web map

 

 

How to Update Portal/ArcGIS Online Item Symbology:

The difference here is subtle. In Option #1, the item being updated is a Web Map. Here, the item being updated is a Feature/Map Image Service Layer. The service might be something you published to ArcGIS Online/Portal for ArcGIS, or a Map/Feature Service you added as an item to your content.

 

Option #1 is great if all you need to do is change the styles in a Web Map, but perhaps you need to change the style for an item in your Organization. Since this item is used by many people (and deliverables are occasionally provided to stakeholders outside of the organization) you wish to standardize its appearance.

 

In this example, I use the same Map Service as before (https://sampleserver6.arcgisonline.com/arcgis/rest/services/USA/MapServer) and perform a similar update to the symbology, only on the Layer item itself.

 

 

Note that this example is a bit more specific on how the symbology is updated:

layer_def = item_data['layers'][3]['layerDefinition']

  • Here you see that only the layer at index 3 is updated (counties) - everything else in the service is left alone.
  •  Review drawingInfo.json and you can see that the renderer is updated from Single symbol to Classified.

 

 

You might wonder why this is included:

    else:
        print("There is no Layer Definition at the moment..creating one...")
        create_layer_def(item)

  • A layer definition isn't necessarily created by default. Let's suppose I only just added that Map Service as an item to my content - that ArcGIS Online/Portal for ArcGIS item has no layer definition attached it.
    • If added the item to a Web Map, made a simple symbology change, and saved the layer this would generate an layer definition.
    • complete.json contains the layer definitions that would apply to the entire item (all 4 layers).

 

from arcgis import GIS
import json, sys

def search_layer(conn,layer_name):
    search_results = conn.content.search(layer_name, item_type='*')
    proper_index = [i for i, s in enumerate(search_results) if
                    '"'+layer_name+'"' in str(s)]
    found_item = search_results[proper_index[0]]
    get_item = conn.content.get(found_item.id)
    return get_item

def update_layer_def(item):
    item_data = item.get_data()
    if item_data is not None:
        # Here note we are changing a specific part of the Layer Definition
        layer_def = item_data['layers'][3]['layerDefinition']
        print("*******************ORIGINAL DEFINITION*********************")
        print(json.dumps(item_data, indent=4, sort_keys=True))

        # Open JSON file containing symbology update
        with open('/path/to/drawingInfo.json') as json_data:
            data = json.load(json_data)

        # Set the drawingInfo equal to what is in JSON file
        layer_def['drawingInfo'] = data

        # Set the item_properties to include the desired update
        item_properties = {"text": json.dumps(item_data)}

        # 'Commit' the updates to the Item
        item.update(item_properties=item_properties)

        # Print item_data to see that changes are reflected
        new_item_data = item.get_data()
        print("***********************NEW DEFINITION**********************")
        print(json.dumps(new_item_data, indent=4, sort_keys=True))
   
    else:
        print("There is no Layer Definition at the moment..creating one...")
        create_layer_def(item)

def create_layer_def(item):  
    with open('/path/to/complete.json') as json_data:
        data = json.load(json_data)

    # Set the item_properties to include the desired update
    item_properties = {"text": json.dumps(data)}

    # 'Commit' the updates to the Item
    item.update(item_properties=item_properties)

    # Print item_data to see that changes are reflected
    item_data = item.get_data()
    print("*********************CREATED DEFINITION************************")
    print(json.dumps(item_data, indent=4, sort_keys=True))  
   
def main():
    conn = GIS("https://machine.domain.com/portal",
               "admin", "password")
   
    # Search for item, get item data)
    item = search_layer(conn, 'earl_api_usalyraw')
    # Attempt to update Layer Definition
    update_layer_def(item)

if __name__ == '__main__':
    sys.exit(main())

 

 

How to Update Feature Service Symbology:

In this last example, I illustrate how to update symbology on a Feature Service Layer. Behind the scenes, this method really just performs this operation: Update Definition (Feature Layer)—ArcGIS REST API: Services Directory | ArcGIS for Developers 

 

So, what's the difference here and when would you want to use this approach?

  • This will only work for Feature Services.
  • You would want to use this approach when you want to make high-level updates to your Feature Service Layers. This can be used to standardize the appearance of Feature Service Layers across the board - without making any client-side modifications, someone adding the Feature Service to a ArcGIS Online/Portal for ArcGIS Web Map would see the same thing as a developer consuming the service in an application.

 

For this example, I published a Hosted Feature Service containing 2 layers:

  1. US States/Canada Provinces
  2. North America Major Railroads

 

The original Feature Service looks like this:

fs-original

 

The JSON for this example isn't very long. I just make a few changes to color and width on the States/Provinces layer:

{
  "drawingInfo": {
    "renderer": {
      "type": "simple",
      "symbol": {
        "type": "esriSFS",
        "style": "esriSFSSolid",
        "color": [
          202,
          46,
          204,
          105
        ],
        "outline": {
          "type": "esriSLS",
          "style": "esriSLSSolid",
          "color": [
            10,
            10,
            210,
            55
          ],
          "width": 0.5
        }
      }
    },
    "scaleSymbols": true,
    "transparency": 0,
    "labelingInfo": null
  }
}

 

 

In this scenario, since we're updating a Feature Service and not an item we need to use arcgis.features.

from arcgis import GIS
from arcgis.features import FeatureLayerCollection
import json, sys


def search_layer(conn,layer_name):
    search_results = conn.content.search(layer_name, item_type='Feature Layer')
    proper_index = [i for i, s in enumerate(search_results) if
                    '"'+layer_name+'"' in str(s)]
    found_item = search_results[proper_index[0]]
    flc = FeatureLayerCollection.fromitem(found_item)
    return flc


def update_layer_def(layer):
    # Open JSON file containing symbology update
    with open('/path/to/hosted_drawinfo_lyr.json') as json_data:
        data = json.load(json_data)
   
    layer.manager.update_definition(data)
    print("*******************UPDATED DEFINITION**********************")
    print(layer.properties)

   
def main():
    conn = GIS("https://machine.domain.com/portal",
               "admin", "password")
   
    # Search for item, get item data)
    flc = search_layer(conn, 'layerdef')
    layer = flc.layers[1]
    print(layer.properties)
    update_layer_def(layer)

if __name__ == '__main__':
    sys.exit(main())
  • The States/Provinces layer was at index 1.

 

The update result:

fs-update

 

 

That concludes this overview on how to update layer symbology. Hopefully with this guide you can get a good sense of how to implement similar workflows in your organization!

Our Storm Water personnel maintain several feature classes in an enterprise geodatabase, which is currently at version 10.6.  Each of these feature classes is related to two tables: one for inspections and one for events.  Each feature class has a field which represents the number of days since the feature was visited, either by inspection or event.  They symbolize their layers by this field, using graduated colors, to show how long it's been since the feature was visited.  For example, red features haven't been visited in a long time while green ones have been visited recently.  Storm Water wanted this field updated automatically every night.

 

I wrote a Python script which performs the update.  I recently extrapolated it to be very general, to apply to any geodatabase layer and any number of related tables.  I call the method once per feature class.  I apologize if the documentation is not in a format to your liking, but I followed some examples I found on-line.  Since it is just a script, you're free to modify it to your whim:

 

# Script written by Roger Dunn, Information Technology Division, City Manager's Office, City of Orem, Utah
# February 2019
# Requires ArcGIS Desktop Standard or Advanced.
# Written with ArcPy for Desktop 10.6.1
# Target geodatabase is a 10.6 geodatabase affectionately called Knight, but really called OREMEGDB

# Use ArcPy
import arcpy

# DateTime functions needed
import datetime

def UpdateMasterFeatureClassDayRangeFieldFromMostRecentDetailEventTable(\
    arcSDEConnectionFileName \
    , masterFeatureClassName \
    , masterKeyFieldName \
    , masterDayRangeFieldName \
    , detailEventTableNames \
    , detailEventForeignKeyFieldNames \
    , detailEventDateFieldNames \
    , valueIfNoHistoryFound
    ):
    '''
    Updates an ArcGIS geodatabase feature class field which represents the number of days
    since something happened in a detail event table (which may or may not be related via
    a relationship class in ArcGIS).  This method doesn't return a value.

    :param str arcSDEConnectionFileName: The name of an .sde connection file.  If this
    script is running in ArcGIS Desktop, then it suffices to use 'Database Connections\'
    followed by the name of the file.  If this is automated, then the .sde file should
    be in the same directory as this script.
   
    :param str masterFeatureClassName: The name of the feature class to be modified.  The
    connection information in arcSDEConnectionFileName should have the user name and
    password (saved) of a user with permissions to modify masterFeatureClassName.  Note
    that masterFeatureClassName does not include the name of the parent feature dataset.

    :param str masterKeyFieldName: The name of the primary key field in the master feature
    class.

    :param str masterDayRangeFieldName: The name of the field in the master feature class
    which will hold the date range from today's date back to the most recent event in any
    of the detailEventTableNames.

    :param str[] detailEventTableNames: The names of tables related to the master feature
    class.

    :param str[] detailEventForeignKeyFieldNames: For each table listed in detailEventTableNames,
    include the name of the field in that table that corresponds to the master feature class'
    primary key field.  Therefore, this list is as long as detailEventTableNames.

    :param str[] detailEventDateFieldNames: For each table listed in detailEventTableNames,
    include the name of the field in that table that contains the event date.  Therefore, this
    list is as long as detailEventTableNames.

    :param var valueIfNoHistoryFound: The default value to insert in the master feature class'
    DayRangeField if no history can be found in any of the detailEventTableNames for that
    particular feature.
    ...
    '''


    # Change the environment workspace, and allow previous temporary datasets be overridden
    arcpy.env.workspace = arcSDEConnectionFileName
    arcpy.env.overwriteOutput = True
    # Store "today" (don't let it change during the script's iterations
    scriptToday = datetime.date.today()
    # Create a dictionary from the detail tables where the key is the unique ID of the master record
    # and the value is the most recent date for a detail record.
    # Initialize the dictionary
    valueDict = {}
    for detailTableIndex in range(len(detailEventTableNames)):
        detailFields = [\
            detailEventForeignKeyFieldNames[detailTableIndex] \
            , detailEventDateFieldNames[detailTableIndex] \
        ]
        with arcpy.da.SearchCursor(detailEventTableNames[detailTableIndex], detailFields) as readRows:
            for readRow in readRows:
                masterID = readRow[0]
                dateVal = readRow[1]
                if not masterID is None and not dateVal is None:
                    dateOnly = dateVal.date()
                    if not masterID in valueDict:
                        valueDict[masterID] = dateOnly
                    else:
                        if dateOnly > valueDict[masterID]:
                            valueDict[masterID] = dateOnly
                    del dateOnly
                del masterID
                del dateVal
                del readRow
        del detailFields
    del detailTableIndex
    #print valueDict

    # With valueDict now populated, it's time to modify the masterFeatureClass' DayRangeField with
    # what we've found
   
    masterFields = [masterKeyFieldName, masterDayRangeFieldName]
    edit = arcpy.da.Editor(arcSDEConnectionFileName)
    # Edit session is started without an undo/redo stack for versioned data (for second argument,
    # use False for unversioned data)
    edit.startEditing(False, True)
    try:
        with arcpy.da.UpdateCursor(masterFeatureClassName, masterFields) as masterRows:
            for masterRow in masterRows:
                masterID = masterRow[0]
                if masterID in valueDict:
                    daysSince = (scriptToday - valueDict[masterID]).days
                else:
                    daysSince = valueIfNoHistoryFound
                # If the calculated value for the date range doesn't equal what's already in the
                # field, modify it.  We only want delta rows where there's really a change.
                if masterRow[1] != daysSince:
                    # Start an edit operation
                    edit.startOperation()
                    try:
                        masterRow[1] = daysSince
                        masterRows.updateRow(masterRow)
                        #print '{0} {1} updated. Field {2} = {3}'.format(masterKeyField, masterID, masterEditField, daysSince)
                        # Stop the edit operation.
                        edit.stopOperation()
                    except:
                        edit.abortOperation()
                del daysSince
                del masterID
                del masterRow
    finally:
        # Stop the edit session and save the changes
        edit.stopEditing(True)
    del edit
    del valueDict
    del scriptToday
    del masterFields

 

I call the function like this, but I'm not going to give out the real database, feature class, and table names:

 

from UpdateLayersFromTables import UpdateMasterFeatureClassDayRangeFieldFromMostRecentDetailEventTable

# Update Feature Class 1
UpdateMasterFeatureClassDayRangeFieldFromMostRecentDetailEventTable( \
    'MyConnection.sde' \
    , 'MySQLDB.SchemaOwner.FeatureClass1' \
    , 'UniqueID' \
    , 'DaysSince' \
    , ['MySQLDB.SchemaOwner.Class1Inspections', 'MySQLDB.SchemaOwner.Class1Events'] \
    , ['FeatClass1UniqueID', 'FeatClass1UID'] \
    , ['InspectionDate', 'EventDate'] \
    , 10000 \
    )

# Update Feature Class 2
UpdateMasterFeatureClassDayRangeFieldFromMostRecentDetailEventTable( \
    'MyConnection.sde' \
    , 'MySQLDB.SchemaOwner.FeatureClass2' \
    , 'UID' \
    , 'DaysSince' \
    , ['MySQLDB.SchemaOwner.Class2Inspections', 'MySQLDB.SchemaOwner.Class2Events'] \
    , ['FeatClass2UniqueID', 'FeatClass2UID'] \
    , ['InspectionDate', 'EventDate'] \
    , 10000 \
    )

 

"Roj"

Let's say you have a Hosted Feature Layer named worldEQ which contains data on Earthquakes that have occurred throughout the world for the last 50 years:

 

earthquakes

 

You wish to create a view named worldEQView from this Hosted Feature Layer. To do that, you could use the following snippet:

from arcgis import GIS
from arcgis.features import FeatureLayerCollection
gis = GIS("https://www.arcgis.com", "username","password")

# Search for Source Hosted Feature Layer
source_search = gis.content.search("world_earthquakes")[0]
source_flc = FeatureLayerCollection.fromitem(source_search)

# Create View from Source Hosted Feature Layer
new_view = source_flc.manager.create_view(name="worldEQView")

 

This works out great and your view is created:

viewresult

 

 

Let's suppose you next want to use the view to show only earthquakes that occurred before the year 1988. Reviewing the Data tab of the view's Item Details, you see that you can filter by a column year_:

tbl

 

 

When you set a View Definition, that definition is defined at the service level. If you quickly set a test definition in the ArcGIS Online/Portal for ArcGIS user interface and take a look at the view service's Service Definition, you'll see the property that needs to be updated is viewDefinitionQuery:

 

Click on 'View' in the View's Item Details page

 

servurl

 

Next, click on the Layer:

 

layerrest

 

Click on 'JSON'

 

 

jsonrest

 

 

Scroll all the way to the bottom to see the 'viewDefinitionQuery' property:

defrest
Note: changing the value of viewDefinitionQuery also updates the related definitionQuery property

 

 

To update the viewDefinitionQuery property with the ArcGIS API for Python, you do the following:

# Search for newly created View
view_search = gis.content.search("worldEQView")[0]
view_flc = FeatureLayerCollection.fromitem(view_search)

# The viewDefinitionQuery property appears under layers
view_layer = view_flc.layers[0]

# Define a SQL query to filter out events past 1988
view_def = {"viewDefinitionQuery" : "year_ < 1988"}

# Update the definition to include the view definition query
view_layer.manager.update_definition(view_def)

 

You should be able to see this update reflected after refreshing the view Item Details page > Visualization

 

def

 

 

Altogether, the script to create a View from the Hosted Feature Layer and then to set a View Definition is:

from arcgis import GIS
from arcgis.features import FeatureLayerCollection
gis = GIS("https://www.arcgis.com", "username","password")

# Search for Source Hosted Feature Layer
source_search = gis.content.search("world_earthquakes")[0]
source_flc = FeatureLayerCollection.fromitem(source_search)

# Create View from Source Hosted Feature Layer
new_view = source_flc.manager.create_view(name="worldEQView")

# Search for newly created View
view_search = gis.content.search("worldEQView")[0]
view_flc = FeatureLayerCollection.fromitem(view_search)

# The viewDefinitionQuery property appears under layers
view_layer = view_flc.layers[0]

# Define a SQL query to filter out events past 1988
view_def = {"viewDefinitionQuery" : "year_ < 1988"}

# Update the definition to include the view definition query
view_layer.manager.update_definition(view_def)

 

This can be generalized into a standalone script like this one:

 

import sys
from arcgis import GIS
from arcgis.features import FeatureLayerCollection

def search_layer(conn,layer_name):
    search_results = conn.content.search(layer_name, item_type="Feature Layer")
    proper_index = [i for i, s in enumerate(search_results)
                    if '"' + layer_name + '"' in str(s)]
    found_item = search_results[proper_index[0]]
    flc = FeatureLayerCollection.fromitem(found_item)
    return flc

def create_view(conn, source_flc, view_name, layer_index, view_def):
    new_view = source_flc.manager.create_view(name=view_name)
    # Search for newly created View
    view_flc = search_layer(conn, view_name)
    # The viewDefinitionQuery property appears under layers
    view_layer = view_flc.layers[layer_index]
    # Update the definition to include the view definition query
    view_layer.manager.update_definition(view_def)
    print("View created")

def main():
    conn = GIS("https://www.arcgis.com",
               "username", "password")
    # Index of the Layer to be filtered
    layer_index = 0
    # Define a SQL query to filter out events past 1988
    view_def = {"viewDefinitionQuery" : "year_ < 1988"}
    # Search for target Hosted Feature Layer
    source_flc = search_layer(conn, "world_earthquakes")
    # Create View from Hosted Feature Layer
    create_view(conn, source_flc, "worldEQView", layer_index, view_def)

if __name__ == '__main__':
    sys.exit(main())

 

If you need to define an area of interest, this would be approached like so:

view_def = {"viewLayerDefinition":{"filter":   
{"operator":"esriSpatialRelIntersects","value":
{"geometryType":"esriGeometryEnvelope","geometry":
{"xmin":4485937.7074932605,"ymin":1543545.165101517,
"xmax":9417043.276225261,"ymax":6239836.182941515,
"spatialReference":{"wkid":102100,"latestWkid":3857}}}}}}
view_layer.manager.update_definition(update_dict)

The `gis.users.create()` method creates users for your Web GIS in ArcGIS Enterprise or ArcGIS Online. The recent update to ArcGIS Online introduced new parameters when creating users not yet implemented for users when created in Enterprise. The API for Python release 1.5.2 `create()` method tried to populate these new parameters when creating users in Enterprise, leading to an error. We logged BUG-000119265 to track the problem.

 

We've caught the problem. We have containment. We've updated the `gis.users.create()` method with the API for Python version 1.5.3, which will be coming soon. The method now properly unpacks the parameters whether the `create()` method is run for Enterprise or ArcGIS Online. We've corrected it and are moving onward. Stay tuned for future releases full of great new functionality!

I have been working on a project were I am looping through rows of data and importing them into a geodatabase. While some of the data had coordinates, some didn't, but did have a street address. With that, I needed to quickly geocode a single address while looping through the records. Along with my coworker @TomSellsted we created a python function to do just this.

 

As a disclaimer, it requires the 'requests' library that is in the ArcGIS Pro and 10.6 install. 

 

Let me know how it works for you! 

Tonight's update to ArcGIS Online introduces a new concept of "User Types". You will not be able to interact with these new user types unless you are using v1.5.2 of the Python API, also released tonight. Please install or upgrade this newest version of the Python API via:

 

conda install -c esri arcgis

or

pip install arcgis

 

Other new features and bug fixes associated with this release can be viewed here. This includes a MapView.take_screenshot() function, Spatially Enabled DataFrame updates, and more! Integrate this new version of the Python API into your environment, and as always let us know your feedback!

The ArcGIS API for Python Version 1.5 is here. You've waited for the Map Widget to use the JavaScript 4x, and the wait is finally over. It's all happening. Fully supported Web Scenes in the Jupyter Notebook no longer reside in a galaxy far, far away - they are now at your front door with all the 3D visualization you can handle. Not just old-faithful Jupyter notebooks, either...there's full support for JupyterLab. Take a look here! You can also specify autocast JavaScript renderers, export your maps from notebooks to HTML, and set up an external JavaScript CDN for use in a disconnected environment. We can't hardly stand what you're about to do with the new capabilities in this API.

 

The wicked flexible Spatial Dataframe turns up the volume with a new accessor-based implementation that allows for access to spatial operations as a property on the steady, reliable Pandas Dataframe. Just use the sdf property and you're all set. With this new way of working with the Spatial Dataframe comes improved rendering and projection support along with enabling Arcade expressions.

 

And you know that's not all, so head on over to the API for Python Guide Release Notes to scope out the details...and then stay tuned for an awesome new series of blogs coming soon to the ArcGIS Blog that will highlight intense new workflows incorporating these new features!

v1.5.0 of the API is public!

Do NOT use this beta, use the public non-beta v1.5.0.The rest of this blog post is no longer relevant: Please see this blog post for more information.

 

If watching today's UC Plenary inspired you to think about "What's Next?", then try downloading the new bleeding-edge beta v1.5 of the ArcGIS API for Python! This version of the API includes support for 3D Mapping, WebScenes, exporting maps to standalone HTML, and more!

 

 

 

To install the new beta of the API, create and activate a new conda environment by running the following:

 

conda create --name beta_v15

(Windows) activate beta_v15

(Unix) source activate beta_15

 

You can then install the beta version of the API by running the following command:

 

conda install -c esri/label/beta arcgis

jupyter notebook

 

PLEASE NOTE THAT THIS IS A BETA RELEASE. It is not as stable as v1.4.2, and should not be used in production anywhere. The API is subject to change before it's official v1.5 release.

 

Getting Started

The best place to get started is to view this example notebook that will walk you through all of the new features of this map widget. You can view the API reference for this new beta release here.

 

Let us know what you think!

Feel free to report an issue for any bugs you find in this beta release, as well as if you want to recommend features or just tell us your thoughts! We really do value your feedback, so drop us a line and let us know what you're thinking!

What’s new in the ArcGIS API for Python v1.4

We've released the next version of the ArcGIS API for Python - version 1.4. Click here for instructions on how to upgrade, and view the whole range of release notes.  There's a ton to be excited about it in this latest offering, and just in time for the 2018 Esri Developer Summit.  Let's highlight some of the new features so you can make the most of what this API has to offer.

You wanted the option to install the ArcGIS API for Python with pip, so we've responded and made a pip package available through PyPi, allowing you to install the API according to your needs. See the documentation here for full details on using the pip package manager to install the API, differences between installing with pip and conda, and much more! 

We've also added options to the connection experience for using your Web GIS. You now have the ability to initialize a GIS object from a token created externally. The token generated from apps or sessions elsewhere will allow you to connect with the API and access Enterprise or Organization resources.  Also upon connecting, we've enabled the persistence of profiles so that you can store your credentials locally in a secure manner and log into the GIS using the name of a profile instead of entering credentials. You're even able to store multiple profiles and use them simultaneously. Check out more details in the Guide for Working with different authentication schemes.

We're really pleased with improvements we've made to the Spatial DataFrame. Incorporation of the shapely package enhances the interoperability of the ArcGIS API for Python. Working with shapely and other geospatial data science packages like GeoPandas and fiona allows the ArcGIS API for Python to read and write almost any geospatial format on any platform. Improvements to the plotting method of the Spatial DataFrame provide an extensive range of symbology options for visualizing data with the Map widget.  We've also added upload management functionality to the Feature Layer Collection object so you have more ways to attach information where it's most useful in your GIS.  And with more functions added in the raster functions module, the future is bright for all kinds of analysis, visualization and data management with the ArcGIS API for Python.

At 1.4, the API has a wider range of symbology options. Take a look:

df.plot(kind='map', 
map_widget=m,
colors='Reds_r',
marker_size=10,
outline_color='Blues',
symbol_style='d')

 


The Python API in Jupyter notebooks is great for exploratory data analysis. You can quickly visualize data using symbology from matplotlib.

With the new graphing capability for displaying a complex raster chain analysis, you can clearly visualize your workflows:

Interested in learning and using the Python API? We encourage you to consider making it priority number one. Check out this video recording of the GeoDev Webinar Series to get a broad perspective of what you can do with the API. Also, add the ArcGIS for Developers Sample Notebooks and Dev Labs to your to-do list to inspect the capabilities of the ArcGIS API for Python for yourself.

 

Sessions galore for you to explore at The Developer Summit in Palm Springs - We'll see you there!

Title

Date & Time

Room

Repeat Date & Time

Repeat Room

ArcGIS API for Python:

Administering Your Web GIS

Tuesday, Mar. 6

5:30 – 6:30 pm

Primrose B

Thursday, Mar. 8

5:30 – 6:30 pm

Primrose B

ArcGIS API for Python:

Introduction to Scripting Your Web GIS

Tuesday Mar. 6

1:00 – 2:00 pm

Primrose B

Thursday, Mar. 8

9:00 – 10:00 am

Primrose B

ArcGIS API for Python for Analysts and Data Scientists

Thursday, Mar. 8

4:00 – 5:00 pm

Mesquite G-H

Friday, Mar. 9

10:00 – 11:00 am

Mesquite C

ArcGIS API for Python:

Advanced Scripting

Wednesday, Mar. 7

2:30 – 3:30 pm

Catalina/Madera

Friday, Mar. 9

1:00 – 2:00 pm

Mesquite B

ArcGIS API for Python:

Mapping, Visualization, and Analysis

Thursday, Mar. 8

2:30 – 3:30 pm

Catalina/Madera

 

 

ArcGIS API for Python:

Cloning your GIS

Wednesday, Mar. 7

11:00 – 11:30 am

Demo Theatre 3:

Oasis 1-2

 

 

ArcGIS Online:

Using the Python API for Transportation Network Analysis

Thursday, Mar. 8

10:30 – 11:30 am

Santa Rosa

 

 

ArcGIS API for Python:

ArcGIS in a Notebook

Tuesday, Mar. 6

5:30 – 6:00 pm

Demo Theatre 3:

Oasis 1-2

 

 

Distributed Image Analysis Using the ArcGIS API for Python

Friday, Mar. 9

10:00 – 11:00 am

San Jacinto

 

 

We're pleased to announce that the ArcGIS API for Python is now available through pip! Pip is a package management system used to install and manage software packages written in Python, similar to conda. Many pip packages can be found in the Python Package Index (PyPI), including the ArcGIS API for Python pip package. To install the API with pip, open a terminal and enter the following command:

pip install arcgis

Pip can be configured to be a more lightweight than conda. It is often distributed with operating systems or other software, and can be installed very easily if you already have python on your computer. You can take advantage of this, for example, by installing the ArcGIS API for Python with minimal dependencies. This might be useful if you want a lightweight API to use just for administrating your GIS servers.

 

Pip and conda are totally separate package managers, and should avoid being used interchangeably. The API is still also available for download through conda, and it is recommended that you use conda to install the API if you are a beginner user. Read more about the differences between pip and conda here.


Click here to view the official installation guide for pip.

What’s new in the ArcGIS API for Python v1.3

We are pleased to announce the newest release of the ArcGIS API for Python (version 1.3) ahead of the holiday season. This version packs some serious enhancements for GIS administration, content management, and performing spatial analysis.

Cloning content from one org to another is a popular use case for many users. GIS administrators and publishers can now leverage the built-in ability to clone items using the latest API. At v1.3, you can pass a bunch of Item objects to the clone_items() method and have those items, and their dependent web layers be cloned along with their content and metadata. The API takes care of swapping the URL in the web maps and apps to match the new web layer URLs.

Admins can work with and manage their unfederated ArcGIS Servers. The ‘server’ module of the API has been enhanced to support authenticating and working with stand-alone ArcGIS servers.

At 1.3, the API has brought to life a feature that many users have been asking for.  You can now easily save your map widget into a web map. The map widget in Jupyter notebooks has been enhanced to list the layers you added, remove them interactively and finally save the widget into a web map. This lets you save your outputs and analysis results for use in other ArcGIS applications. In addition, the WebMap class has been enhanced and lets you author and edit web maps. Analysts and publishers can then create web maps when using the API in a headless or script mode.

Visualize spatial and attribute data in Jupyter notebooks with Python API

The Python API in Jupyter notebooks is great for exploratory data analysis. You can quickly visualize spatial patterns using smart mapping, as well as the attribute data in a tabular form.

When performing an analysis, often you face questions such as, “who are the people that live in this area?”, “how diverse is this neighborhood?”, “what is the average commute times and mode of transportation for residents of this zip code?”. Enriching your GIS data set with socio-economic attributes like these will greatly enhance explaining a prevailing geographical phenomenon or will simply add more context to the conclusions that you are drawing specifically from your analysis work. With the newly added ‘geoenrichment module, users of the Python API can call into the ArcGIS GeoEnrichment Service and collect demographic and other thematic information about their study areas. To empower your imagery analysis, many raster functions have been added.

In addition to these new capabilities, several enhancements and bug fixes have been included in the 1.3 release. Check out the release notes for more details.

Learning resources

With the new year upon us, are you thinking about any resolutions? If learning and using the Python API isn’t one, we encourage you to consider making it one. Check out this video recording  from the GeoDev Webinar Series to get a broad perspective of what you can do with the API. Also, add the recent ArcUser article “Harness the Power of GIS with the ArcGIS API for Python” to your holiday reading list. Still not convinced about Jupyter notebooks? Check out this blog post: A Whole New Way to Experience GIS.

From the Python API team, we wish you very happy holidays!@



 

Atma Bharathi Maniarcgis api for python python scripting python automation python

We are excited to announce the release of version 1.2.4 of the ArcGIS API for Python. This version includes a number of bug fixes and updated documentation. You can find the list of reported bugs addressed in the release notes.

 

Please upgrade your package using the command in your Anaconda shell or terminal:

conda upgrade -c esri arcgis

If this is the first time you’re installing the Python API, use the following command:

conda install -c esri arcgis

If you installed using ArcGIS Pro, you can also update your package by using the 'Update Packages' tab from the 'Python' tab in Pro backstage.

 

Thank you,
ArcGIS API for Python team.

We are excited to announce the v1.2.1 of the ArcGIS API for Python which includes a number of bug fixes and updated documentation for a lot of the new features introduced earlier in v1.2. You can find the list of reported bugs addressed in the release notes. This release includes documentation for building a distributed GIS using collaborationsmanaging your ArcGIS servers using Python APIadministering your ArcGIS Org / Enterprisecustomizing the appearance of your Org.

 

Please upgrade your package using the command in your Anaconda shell or terminal:

conda upgrade -c esri arcgis

If this is the first time you’re installing the Python API, use the following command:

conda install -c esri arcgis

If you installed using ArcGIS Pro, you can also update your package by using the 'Update Packages' tab from the 'Python' tab in Pro backstage.

 

Thank you,
ArcGIS API for Python team.

We are excited to announce the v1.2 of the ArcGIS API for Python to coincide with the Esri User Conference 2017. This is release packs a slew of new features, samples and numerous bug fixes to both the API and the samples. You can find the list of fixes and enhancements in the release notes.

 

Please upgrade your package using the command

conda upgrade -c esri arcgis

If this is the first time you’re installing the Python API, use the following command:

conda install -c esri arcgis

 

Note:

  • The v1.2 version requires Python interpreter 3.5 and later. This means, it would not work with the Python installed with ArcGIS Pro 1.3. We request our Pro users to upgrade to ArcGIS Pro 1.4 or 2.0 and reinstall the latest arcgis package.
  • If you were using v1.0 in Python 3.4 environment, please create a new environment and install either Python 3.5x or 3.6x and then install the arcgis API.

 

You can create a new environment in conda using the following command: In the command below, you can give a name of your choice and specify either 3.5 or 3.6 for Python version

conda create --name my_latest_python_env python=3.5

 

Then activate the environment and install the package using the command below:

activate my_latest_python_env
conda install -c esri arcgis

 

Thank you,
ArcGIS API for Python team.

We are just a few hours from Esri User Conference 2017! Below are some sessions to attend if you would like to learn more about the ArcGIS API for Python.

Python API sessions @ UC 2017

Stop by the 'Developer Expo area' at Exhibit Hall B-1 to meet the team. We will be available all week to answer your questions, learn about your workflows and requirements. Hope to meet you at the UC!