opensensmapr: opensensmapr: Get sensor data from opensensemap.org

opensensmaprR Documentation

opensensmapr: Get sensor data from opensensemap.org

Description

The opensensmapr package provides functions for

  • retrieval of senseBox metadata,

  • retrieval of senseBox measurements,

  • general statistics about the openSenseMap database.

Additionally, helper functions are provided to ease the integration with the sf package for spatial analysis as well as dplyr for general data handling.

Retrieving senseBox metadata

On the openSenseMap, measurements are provided by sensors which are assigned to a sensor station ("senseBox"). A senseBox consists of a collection of sensors, a location (-history), an ID, as well as metadata about its owner & placement. senseBoxes can be retrieved either by ID, or as a collection with optional filters on their metadata

  • osem_box: Get metadata about a single box by its ID.

  • osem_boxes: Get metadata about all boxes, optionally filtered by their attributes.

The data is returned as a data.frame with the class sensebox attached. To help in getting an overview of the dataset additional functions are implemented:

  • summary.sensebox(): Aggregate the metadata about the given list of senseBoxes.

  • plot.sensebox(): Shows the spatial distribution of the given list of senseBoxes on a map. Requires additional packages!

  • osem_phenomena: Get a named list with counts of the measured phenomena of the given list of senseBoxes.

Retrieving measurements

There are two ways to retrieve measurements:

  • osem_measurements_archive: Downloads measurements for a single box from the openSenseMap archive. This function does not provide realtime data, but is suitable for long time frames.

  • osem_measurements: This function retrieves (realtime) measurements from the API. It works for a single phenomenon only, but provides various filters to select sensors by

    • a list of senseBoxes, previously retrieved through osem_box or osem_boxes.

    • a geographic bounding box, which can be generated with the sf package.

    • a time frame

    • a exposure type of the given box

    Use this function with caution for long time frames, as the API becomes quite slow is limited to 10.000 measurements per 30 day interval.

Data is returned as tibble with the class osem_measurements.

Retrieving statistics

Count statistics about the database are provided with osem_counts.

Using a different API instance / endpoint

You can override the functions osem_endpoint and osem_endpoint_archive inside the package namespace:

assignInNamespace("osem_endpoint", function() "http://mynewosem.org", "opensensmapr")

Integration with other packages

The package aims to be compatible with the tidyverse. Helpers are implemented to ease the further usage of the retrieved data:

  • osem_as_sensebox & osem_as_measurements: Transform a foreign object to a sensebox data.frame or osem_measurements by attaching the required classes and attributes.

  • st_as_sf.sensebox & st_as_sf.osem_measurements: Transform the senseBoxes or measurements into an sf compatible format for spatial analysis.

  • filter.sensebox() & mutate.sensebox(): for use with dplyr.

Author(s)

Maintainer: Jan Stenkamp jan.stenkamp@uni-muenster.de [contributor]

Authors:

Other contributors:

See Also

Report bugs at https://github.com/sensebox/opensensmapR/issues

openSenseMap API: https://api.opensensemap.org/

official openSenseMap API documentation: https://docs.opensensemap.org/


opensensmapr documentation built on March 31, 2023, 11:45 p.m.