Adding An ArcGIS Feature Layer Dataset
In this example, we will be using a fire perimeter layer from the HIFLD Open Data Catalogue . This layer is an ArcGIS feature service with polygons showing the perimeters of fires in the US from 2000 to 2013. The layer is available here . Because this is a public layer, we can access it without any credentials.
Setup
First to do some initial setup. We start by importing geodesic:
import geodesic
If you haven't yet, you will need to authenticate geodesic using the following command:
geodesic.authenticate()
This process is covered in more detail in the Quickstart.
We need to set the active project to ensure that our dataset is saved to the correct project. We do
this using the uid of our desired project. If you do not know the uid, you can fetch a dictionary of
existing project that you can access by running ~geodesic.account.projects.get_projects()
. For
this example, we will use the 'tutorials' project. If you own the project you can pass the project
name as a string, otherwise you will need to pass the project uid.
geodesic.set_active_project('tutorials')
Creating The Provider
The Geodesic python API provides the method, ~geodesic.boson.dataset.Dataset.from_arcgis_layer()
which makes adding an ArcGIS Layer dataset extremely straightforward. To add our fire perimeter
dataset, we simply run:
ds = geodesic.Dataset.from_arcgis_layer(
name='fire-perimeters',
url='https://services3.arcgis.com/T4QMspbfLg3qTGWY/arcgis/rest/services/Historic_Geomac_Perimeters_Combined_2000_2018/FeatureServer/0'
)
ds.save()
This will create a new dataset in our active project called 'fire-perimeters' and save it to the project.
Testing The Provider
Now to run a quick test to ensure that the provider is working. Let's search run a simple search to check that features are returned
ds.search()
This should return the first ten features from the ArcGIS Layer as a GeoDataFrame dataframe.
As a slightly less trivial example, let's search for fires from the year 2011, that took place in Texas, and were larger than 150k acres:
from geodesic import cql
feats = ds.search(
limit=10,
filter=cql.CQLFilter.logical_and(
cql.CQLFilter.eq('fireyear', '2011'),
cql.CQLFilter.gte('gisacres', 150000),
cql.CQLFilter.eq('state', 'TX'))
)
feats
This should return three results, which are the three fires that meet the criteria we specified.
Finally, if you have installed the relevant dependencies, you can use the geodesic mapping utilities to visualize these features on a map using the following lines:
from geodesic import mapping
m = mapping.Map(center = [31.657327,-100.568419], zoom = 6)
m.add_feature_collection('fires', feats)
m
If you use the map to navigate to the area of Texas, you should see the three features from our search: