Title: | Finnish Meteorological Institute open data API R client |
---|---|
Description: | R client for the Finnish Meteorological Institute (FMI) open data API. This package supersedes the obsolete fmi package. Client can be used to fetch geospatial over FMI's WFS <https://en.ilmatieteenlaitos.fi/open-data-manual-accessing-data> and converted into geospatial objects in R. |
Authors: | Joona Lehtomaki [aut, cre], Leo Lahti [aut] , Ilari Scheinin [ctb] |
Maintainer: | Joona Lehtomaki <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.2.0 |
Built: | 2025-01-30 11:24:18 UTC |
Source: | https://github.com/rOpenGov/fmi2 |
Describe FMI observation variable(s).
describe_variables(x)
describe_variables(x)
x |
character vector of observation variables to be described. |
FMI provides a machine-reabable (XML) description of different observation variables. Use this function to see the specifications of a given variable.
tibble containing the following columns:
Observation variable name
Variable (parameter) label used by the FMI
Base phenomenon that the variable is characterising
Variabel unit
Statistical function used the derive the variable value
Aggregation time period
Joona Lehtomäki [email protected]
## Not run: desc <- describe_variables(c("TG_PT12H_min", "rrday")) ## End(Not run)
## Not run: desc <- describe_variables(c("TG_PT12H_min", "rrday")) ## End(Not run)
Requests to FMI API.
fmi_api(request, storedquery_id = NULL, ...)
fmi_api(request, storedquery_id = NULL, ...)
request |
character request type of either |
storedquery_id |
character id of the stored query id. If |
... |
stored query specific parameters. NOTE: it's up to the high-level functions to check the validity of the parameters. |
Make a request to the FMI API. The base url is opendata.fmi.fi/wfs?service=WFS&version=2.0.0 to which other components defined by the arguments are appended.
This is a low-level function intended to be used by other higher level functions in the package.
Note that GET requests are used using httpcache
meaning that requests
are cached. If you want clear cache, use httpcache::clearCache()
. To turn
the cache off completely, use httpcache::cacheOff()
fmi_api (S3) object with the following attributes:
XML payload.
path provided to get the resonse.
the original response object.
Joona Lehtomäki [email protected]
# List stored queries fmi_api(request = "DescribeStoredQueries")
# List stored queries fmi_api(request = "DescribeStoredQueries")
Data is retrieved using a FMI API stored query.
fmi_stations()
fmi_stations()
a tibble
of active observation stations
Joona Lehtomaki [email protected]
https://en.ilmatieteenlaitos.fi/observation-stations
For valid stored query IDs, see list_queries
.
list_parameters(query_id)
list_parameters(query_id)
query_id |
character string query ID. |
a tibble describing the valid parameters.
Joona Lehtomäki [email protected]
## Not run: list_parameters("fmi::observations::weather::daily::timevaluepair") ## End(Not run)
## Not run: list_parameters("fmi::observations::weather::daily::timevaluepair") ## End(Not run)
Stored queries are identifiers for data sets. The current version on the Open Data WFS service of the Finnish Meteorological Institute uses the stored queries extensively to enable users to select the features, areas and times they require as easily as possible. See the Open data WFS Service for more detailed information about the available stored queries and their request parameters.
list_queries(all = FALSE)
list_queries(all = FALSE)
all |
logical should all stored queries available through the API be listed(default: FALSE)? |
tibble containing the following columns:
ID of the storied query.
Description of the storied query.
Number of parameters.
Name of the function in fmi2 if wrapped, NA otherwise.
Joona Lehtomäki [email protected]
https://en.ilmatieteenlaitos.fi/open-data-manual-fmi-wfs-services
## Not run: # List the stored queres that have been wrapped (i.e. are accessible) by # the fmi2 package list_queries() # List all stored queries available through the API list_queries(all = TRUE) ## End(Not run)
## Not run: # List the stored queres that have been wrapped (i.e. are accessible) by # the fmi2 package list_queries() # List all stored queries available through the API list_queries(all = TRUE) ## End(Not run)
Daily weather observations from weather stations.
obs_weather_daily(starttime, endtime, fmisid = NULL, place = NULL)
obs_weather_daily(starttime, endtime, fmisid = NULL, place = NULL)
starttime |
character or Date start of the time interval in ISO-format. character will be coerced into a Date object. |
endtime |
character or Date end of the time interval in ISO-format. character will be coerced into a Date object. data. |
fmisid |
numeric FMI observation station identifier (see fmi_stations. |
place |
character location name for which to provide data. |
Default set contains daily precipitation rate, mean temperature, snow depth, and minimum and maximum temperature. By default, the data is returned from last 744 hours. At least one location parameter (geoid/place/fmisid/wmo/bbox) has to be given.
The FMI WFS stored query used by this function is
fmi::observations::weather::daily::simple
. For more informations, see the
FMI documentation page.
sf object in a long (melted) form. Observation variables names are
given in variable
column. Following variables are returned:
Precipitation amount
Snow depth
Average air temperature
Minimum air temperature
Maximum air temperature
Ground minimum temperature
For a complete description of the accepted arguments, see
list_parameters("fmi::observations::weather::daily::simple")
.
https://en.ilmatieteenlaitos.fi/open-data-manual-fmi-wfs-services,
Default set contains hourly air temperature average, maximum and minimum, air relative humidity average, wind speed average, minumum (10 minute average) and maximum (10 minute average), wind direction average, wind gust speed maximum (3 second average), rain accumulated, rain intensity maximum, air pressure average and the most significant weather code. By default, the data is returned from last 24 hours. At least one location parameter (geoid/place/fmisid/wmo/bbox) has to be given.
obs_weather_hourly(starttime, endtime, fmisid = NULL)
obs_weather_hourly(starttime, endtime, fmisid = NULL)
starttime |
character begin of the time interval in ISO-format. |
endtime |
character end of time interval in ISO-format. data. |
fmisid |
numeric FMI observation station identifier (see fmi_stations. |
The FMI WFS stored query used by this function is
fmi::observations::weather::hourly::simple
. For more informations, see
the FMI documentation page.
sf object in a long (melted) form. Observation variables names are
given in variable
column. Following variables are returned:
Precipitation amount
Snow depth
Average air temperature
Minimum air temperature
Maximum air temperature
Ground minimum temperature
For a complete description of the accepted arguments, see
list_parameters("fmi::observations::weather::hourly::simple")
.
https://en.ilmatieteenlaitos.fi/open-data-manual-fmi-wfs-services,
FMI API response object's XML (GML) content is temporarily wrtitten on disk and then immediately read back in into a sf object.
to_sf(api_obj)
to_sf(api_obj)
api_obj |
fmi api object |
sf object
For internal use, not exported.
Joona Lehtomäki [email protected]
## Not run: response <- fmi_api(request = "getFeature", storedquery_id = "fmi::observations::weather::daily::timevaluepair", starttime = "2019-01-01", endtime = "2019-01-04", fmisid = 100946) sf_obj <- to_sf(response) ## End(Not run)
## Not run: response <- fmi_api(request = "getFeature", storedquery_id = "fmi::observations::weather::daily::timevaluepair", starttime = "2019-01-01", endtime = "2019-01-04", fmisid = 100946) sf_obj <- to_sf(response) ## End(Not run)
fmisid
is a ID numbering system used by the FMI.
valid_fmisid(fmisid)
valid_fmisid(fmisid)
fmisid |
numeric or character ID number. |
logical
Joona Lehtomaki [email protected]