Title: | An API Wrapper for 'DAWA' - 'The Danish Address Web API' |
---|---|
Description: | Functions for interacting with all sections of the official 'Danish Address Web API' (also known as 'DAWA') <https://api.dataforsyningen.dk>. The development of this package is completely independent from the government agency, Klimadatastyrelsen, who maintains the API. |
Authors: | Aleksander Bang-Larsen [aut, cre, cph] |
Maintainer: | Aleksander Bang-Larsen <[email protected]> |
License: | GPL (>= 3) |
Version: | 0.2.4 |
Built: | 2024-11-12 11:16:12 UTC |
Source: | https://github.com/aleksanderbl29/dawaR |
autocomplete
of sections.This function is very handy when needing to either validate or simply "fill in gaps" with autocompletion from the API.
autocomplete(section, input, ...)
autocomplete(section, input, ...)
section |
Defines what section of the api should be called.
|
input |
The input to autocomplete. Could be a name, a place and similar. |
... |
< |
Returns the autocomplete information for the provided section
given the input.
autocomplete("regioner", "midt")
autocomplete("regioner", "midt")
dawa()
Simple function to list all available options for the section
parameter in dawa()
. Useful when getting to know the base api function of
this package. To filter based on funciton usage you can provide format = "geojson"
to ensure compatability with get_map_data()
and func = "get_data"
to ensure compatability with get_data()
.
available_sections(as_list = FALSE, format = NULL, verbose = TRUE, func = NULL)
available_sections(as_list = FALSE, format = NULL, verbose = TRUE, func = NULL)
as_list |
This options controls the output format. The output is either a named list or an atomic vector with the available sections |
format |
Specify a format type. The function now returns only available
sections that can respond with that format. Currently |
verbose |
whether or not to provide |
func |
Sepcify the function you would like to ensure section compatability with. |
The function returns either a named list or an atomic vector with the
available sections in the API. The format is decided by as_list
.
available_sections() available_sections(as_list = TRUE)
available_sections() available_sections(as_list = TRUE)
This function is the foundation of all communication with the api in this package. Not intended for end-users, but it provides all the flexibility of the api without the nice conveniences of the other functions in this package. By default it reformats the api response (which is json) to a list object.
dawa( section, ..., append_to_url = NULL, format = NULL, verbose = TRUE, cache = TRUE, dry_run = FALSE, func_params = list() )
dawa( section, ..., append_to_url = NULL, format = NULL, verbose = TRUE, cache = TRUE, dry_run = FALSE, func_params = list() )
section |
Defines what section of the api should be called.
|
... |
< |
append_to_url |
This options enables you to append a string to the url.
It is inserted in the request after the |
format |
The format to provide as a query parameter for the api call. By
default it has value |
verbose |
whether or not to provide |
cache |
Option to use caching in a |
dry_run |
With this option enabled, the function will output the request that has been created - Without sending it to the api. This is useful for debugging. |
func_params |
Option to include extra parameters (just like |
By default returns the API response as a list output. For
geojson(z)
formats it returns the raw json. When dry_run = TRUE
it
returns the request that has been created but does not run it.
x <- dawa(section = "sogne") x[[1]]
x <- dawa(section = "sogne") x[[1]]
Get data from section
get_data(section, as_list = FALSE, ...)
get_data(section, as_list = FALSE, ...)
section |
Defines what section of the api should be called.
|
as_list |
Whether or not to return the data as a list or in a dataframe. Data.frame is the default output. |
... |
< |
Returns either a dataframe with all the data for the specified section or a list with the same information.
x <- get_data("regioner") head(x)
x <- get_data("regioner") head(x)
{sf}
.This function returns map data from DAWA. It is ready to use
with {sf}
functions. The returned dataframe has date-time columns to inform
when the information was last changed. It is returned in Europe/Copenhagen
time as that is the local time for the API. You can change that behavior by
setting Sys.setenv(TZ = "Your/Timezone")
.
get_map_data(type, cache = TRUE, ...)
get_map_data(type, cache = TRUE, ...)
type |
Defines the type of map data to request from DAWA. Run
|
cache |
Boolean to determine whether or not to cache the api call and
the function output. Default is |
... |
< |
Returns a data.frame
object that contains polygons (or points) for
the section provided.
## Not run: x <- get_map_data("regioner") ggplot2::ggplot(x) + ggplot2::geom_sf() ## End(Not run)
## Not run: x <- get_map_data("regioner") ggplot2::ggplot(x) + ggplot2::geom_sf() ## End(Not run)
reverse geocoding
of sections.This function reverse geocodes the coordinates provided. When
used out of the box, the function wants WGS84 coordinates (lat/long). ETRS89
or UTM zone 32 can be provided as well. When coordinates from outside of
Denmark is provided, the function will fail with a code 404
.
reverse(section, x, y, verbose = TRUE, type = NULL, ...)
reverse(section, x, y, verbose = TRUE, type = NULL, ...)
section |
Defines what section of the api should be called.
|
x |
The X coordinate to geocode. If no |
y |
The Y coordinate to geocode. If no |
verbose |
whether or not to provide |
type |
The coordinate type for the API to parse. By default none is
provided and |
... |
< |
Returns a list object with information about the provided section
for the location that is input.
reverse("regioner", x = 12.58515, y = 55.68324)
reverse("regioner", x = 12.58515, y = 55.68324)
This function fetches the status of all available SDFI services.
This package depends on at least one of these. It checks the official
status page. The status can also be followed on their official X-page
@DriftDataforsyn
.
status_check(return_df = FALSE, error_if_unavailable = FALSE)
status_check(return_df = FALSE, error_if_unavailable = FALSE)
return_df |
This option makes the function return a data.frame object with the services and their statuses listed |
error_if_unavailable |
This option forces the function to throw an error in the event that one or more services are unreachable. |
Returns a data frame object with the services and their statuses. Is
only returned if return_df = TRUE
.
status_check() status_check(return_df = TRUE)
status_check() status_check(return_df = TRUE)