Skip to content

Instantly share code, notes, and snippets.

@maptastik
Last active December 11, 2017 18:28

Revisions

  1. maptastik revised this gist Dec 11, 2017. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion agolToDF.py
    Original file line number Diff line number Diff line change
    @@ -16,7 +16,7 @@ def agolSearch(term):
    item_list.append(item)
    return item_list

    results = agolSearch(<some search terms>)
    results = agolSearch('search terms')
    results_select = results[0] # select the index postions at which the item you want is positione. This example selects the first result.
    # Create dataframe from selected dataset
    results_select_df = results_select.layers[0].query().df
  2. maptastik created this gist Dec 11, 2017.
    25 changes: 25 additions & 0 deletions agolToDF.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,25 @@
    import pandas as pd
    from arcgis.gis import GIS

    # Login to AGOL
    gis = GIS()

    # For other login methods see: https://developers.arcgis.com/python/guide/working-with-different-authentication-schemes/
    # use for logging in within active ArcGIS Pro session
    # gis = GIS('pro')

    # Create a function that returns a list of feature layer collections for a search
    def agolSearch(term):
    item_list = []
    items = gis.content.search(term, item_type="Feature Layer Collection")
    for item in items:
    item_list.append(item)
    return item_list

    results = agolSearch(<some search terms>)
    results_select = results[0] # select the index postions at which the item you want is positione. This example selects the first result.
    # Create dataframe from selected dataset
    results_select_df = results_select.layers[0].query().df

    # Check out the first 5 records of the new DataFrame
    results_select_df.head()