Adding data to a feature service via script

The use of Raspberry Pis are increasingly common in schools – especially in STEM, Maker, and field experience courses.  Raspberry Pis (version 4 at the time of this blog) hold the computing power of a laptop – at a fraction of the cost.  They can also run off of 5V battery power and have wifi built-in.  In short, they can useful for collecting data in and around school.  Oh, and did I mention there are dozens if not hundreds of cheap sensors that can be plugged directly into the device for data collection?

Raspi-PGB001.png

This isn’t a new technique at all, but we are seeing more sensors and increased computing capacity within the Pi platform – making it increasingly interesting.  I started writing on this about two years ago.  You can see how far we’ve come in that time.

By way of a quick example, I created a Survey123 form with a grade (numeric) and short name (text) fields.  I set the permissions to allow anyone to contribute data (without logging in).  Survey123 creates some ArcGIS Online components for you when you create a new survey.  Here, I’m only going to focus on the “field_worker”  feature service it creates.  Using a little Python code and the point layer’s “Add Feature” REST functionality, I can send data directly into my field_worker feature service with a few lines of code.  In this case, that code looks like:

import requests
import json

url = 'https://services.arcgis.com/BG6nSlhZSAWtExvp/ArcGIS/rest/services/survey123_1570d91b042744f8af17caad...'
params={"f":"pjson","token":"","rollbackOnFailure":"false","features":'{"attributes" : {"shortname" : "test_user_name"}}'}
x = requests.post(url, params=params)

In the first two lines we import two basic Python libraries (json and requests). In the next line, we identify the URL of the “Add Feature” function associated with our feature service’s REST endpoint. Parameters allow us to specify the data to pass.  You’ll see a few non-attribute parameters like “f”, “token”, and “rollbackOnFailure”.  For starting out, just keep these as-is and change the attribute “short name” to the attribute in your feature service.

As my colleague, @Kylie has noted, this code can also be converted to run inside of a webhook tool like Microsoft Power Automate or Integromat (using the HTTP module).  In a webhook-based case, you may be using the script (with a different endpoint) to update a feature service’s data rather than just adding it.

If you or your students are into the STEM, Maker, coder, or IoT learning scenes, be sure to turn on your students’ ArcGIS Online Notebook access and check out the Python API!

2020 Interface B Presentation Resources

Links and downloads will be available here by February 25.


Feb 24, 2020 10:00 AM, Cedar Cove:

Getting started with map-based data

PDF version of the presentation

Key weblink:

 


Feb 24, 2020 12:30 PM, Cedar Cove:

Visualizing and Analyzing your Data on a Map

2019 NCSS NCGE Presentations

For the moment, this is a placeholder page that will eventually house presentation resources for my three co-presentations.

  • Baker, T.R., Jo, I, Duke, B. (Nov). Advance Your Geospatial Technology – Empowered by Your Curriculum Standards. 
  • Palmer, A. & Baker, T.R. Interactive Mapping Infuses Geography Across the Curriculum. 
  • Shin, E., Bednarz, S., & multiple presenters. (Nov). Panel on Spatial Citizenship. CUFA/NCSS. 

 

GIS Day presentation with Missouri Social Studies Teachers

This page has links and resources from the presentation to the Missouri Social Studies teachers on November 12, 2019,. in Jefferson City, MO.

Files:

Key URLs:

 

GeoTools for Inquiry

On this past Wednesday, the Esri Education Team delivered a webinar through Directions Magazine to teachers who use GIS and mapping tools in projects and research.  The graphic below is one that we prepared to help illustrate where in the research cycle a particular geotool is most valuable.

These tool recommendations are not absolute; in the hands of an experienced student or educator, there can be a great deal of fluidity.  This chart may be considered a starting point.

geotools-for-inquiry-2019-q4