Title: | An API Wrapper Package for DAWA - The Danish Address Web API |
---|---|
Description: | Package providing functions to interact with all sections of the official Danish Address Web API (also known as DAWA). The development of this package is completely independent from the [government entity that maintains the API](sdfi.dk). |
Authors: | Aleksander Bang-Larsen [aut, cre, cph] |
Maintainer: | Aleksander Bang-Larsen <[email protected]> |
License: | GPL (>= 3) |
Version: | 0.1.0 |
Built: | 2024-09-20 09:18:44 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.
available_sections(as_list = FALSE, format = NULL, verbose = TRUE)
available_sections(as_list = FALSE, format = NULL, verbose = TRUE)
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 |
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 )
dawa( section, ..., append_to_url = NULL, format = NULL, verbose = TRUE, cache = TRUE, dry_run = FALSE )
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. |
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 |
Wether 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)
get_map_data(type)
type |
Defines the type of map data to request from DAWA. Run
|
Returns a data.frame
object that contains polygons for the section
provided.
x <- get_map_data("regioner") ggplot2::ggplot(x) + ggplot2::geom_sf()
x <- get_map_data("regioner") ggplot2::ggplot(x) + ggplot2::geom_sf()
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. The API that this package wraps is one of these. It checks this status url. The status can also be followed on the official X-page.
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 dataframe 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)