Title: | Interface to Cartociudad API |
---|---|
Description: | Access to Cartociudad cartography API, which provides mapping and other related services for Spain. |
Authors: | Carlos J. Gil Bellosta [cre, aut], Luz Frías [aut] |
Maintainer: | Carlos J. Gil Bellosta <[email protected]> |
License: | GPL-3 |
Version: | 0.6.3 |
Built: | 2024-11-01 11:29:26 UTC |
Source: | https://github.com/rOpenSpain/caRtociudad |
Geolocation of Spanish addresses via Cartociudad API calls, providing the
full address in a single text string via full_address
. It is
advisable to add the street type (calle, etc.) and to omit the country
name.
cartociudad_geocode(full_address, on.error = "fail", ...)
cartociudad_geocode(full_address, on.error = "fail", ...)
full_address |
Character string providing the full address to be geolocated; e.g., "calle miguel servet 5, zaragoza". Adding the country may cause problems. |
on.error |
Defaults to |
... |
Other parameters for the API. See Details section below. |
The entity geolocation API admits more parameters beyond the address field such as id
or type
.
You can use these extra arguments (see the References or the Examples sections below for further information)
at your own risk.
A data frame consisting of a single row per guess. See the reference below for an explanation of the data frame columns.
Carlos J. Gil Bellosta
http://www.cartociudad.es/recursos/Documentacion_tecnica/CARTOCIUDAD_ServiciosWeb.pdf
# standard usage res <- cartociudad_geocode(full_address = "plaza de cascorro 11, 28005 madrid") #' # km 41 of A-23 motorway res <- cartociudad_geocode("A-23 41") # specific usage (see References for details) res <- cartociudad_geocode("A-23 41", type = "portal", id = "600000000045", portal = 41) # vectorized call ## Not run: addresses <- paste("A-23", 1:10) res <- lapply(addresses, cartociudad_geocode, on.error = "warn") ## End(Not run)
# standard usage res <- cartociudad_geocode(full_address = "plaza de cascorro 11, 28005 madrid") #' # km 41 of A-23 motorway res <- cartociudad_geocode("A-23 41") # specific usage (see References for details) res <- cartociudad_geocode("A-23 41", type = "portal", id = "600000000045", portal = 41) # vectorized call ## Not run: addresses <- paste("A-23", 1:10) res <- lapply(addresses, cartociudad_geocode, on.error = "warn") ## End(Not run)
Returns the polygon that describes the area
cartociudad_get_area(latitude, longitude, radius)
cartociudad_get_area(latitude, longitude, radius)
latitude |
Point latitude in geographical coordinates (e.g., 40.3930144) |
longitude |
Point longitude in geographical coordinates (e.g., -3.6596683) |
radius |
Distance in meters (e.g., 500) |
This function calculates the area given a point and a radius in meters
A dataframe with the polygon that describes the area.
Luz Frias
http://www.cartociudad.es/recursos/Documentacion_tecnica/CARTOCIUDAD_ServiciosWeb.pdf
cartociudad_get_area(40.3930144, -3.6596683, 500)
cartociudad_get_area(40.3930144, -3.6596683, 500)
Returns the administrative information related to a geographical point in Spain: province, municipality, censal district, censal section, cadastral reference and reverse geocoding data.
cartociudad_get_location_info(latitude, longitude, year = 2016, info.source = c("census", "cadastre", "reverse"))
cartociudad_get_location_info(latitude, longitude, year = 2016, info.source = c("census", "cadastre", "reverse"))
latitude |
Point latitude in geographical coordinates (e.g., 40.473219) |
longitude |
Point longitude in geographical coordinates (e.g., -3.7227241) |
year |
Reference year; see Details section |
info.source |
A character vector specifying the APIs to consult. Possible values are "census", "cadastre" and "reverse" |
This function consults administrative information for a point within Spain. Censal information is consulted from a different set of layers, each one corresponding to a different year. Whereas provincial and municipal information is mostly stable, censal districts and sections may be subject to greater changes over the years.
A list contaning the administrative information for the given point.
For info.source = "census"
it contains the province, municipality,
censal discrict and censal section codes. For info.source =
"cadastre"
it contains the cadastral reference and the url to the spanish
cadastre website. For info.source = "reverse"
it contains the
details of the address closest to the specified location, such us road
type, number, zip code, street name, ... More information about reverse
geocoding in cartociudad_reverse_geocode
.
Luz Frías with small edits by Carlos J. Gil Bellosta
INE's web service is mostly undocumented and the function has been built by reverse engineering API calls. However, users may want to check the capabilities of INEs WMS service at http://goo.gl/aKn3vj. Cadastre web service documentation can be consulted at http://goo.gl/lKkwK and WMS service capabilities at http://goo.gl/5JAd9N.
cartociudad_get_location_info(40.473219, -3.7227241)
cartociudad_get_location_info(40.473219, -3.7227241)
Downloads static maps using Cartociudad API. These maps can be
then plotted by functions such as ggmap
.
cartociudad_get_map(center, radius, add.censal.section = FALSE, add.postcode.area = FALSE, add.cadastral.layer = FALSE, height = 800, width = 1200)
cartociudad_get_map(center, radius, add.censal.section = FALSE, add.postcode.area = FALSE, add.cadastral.layer = FALSE, height = 800, width = 1200)
center |
a pair of numbers (latitude and longitude of the center of the map) |
radius |
approximate map "width" in kilometers |
add.censal.section |
whether to add the limit of censal sections and districts to the base map; note that this layer may not be available at low zoom levels |
add.postcode.area |
whether to add the limit of postal code areas to the base map; note that this layer may not be available at low zoom levels |
add.cadastral.layer |
whether to add cadastral information |
height |
map height in pixels |
width |
map width in pixels |
This function, similar to get_googlemap
or
get_openstreetmap
downloads a map from Cartociudad API and creates a
ggmap
compatible version of it.
An object of class ggmap
and raster
which can be used
within the ggmap
framework.
Carlos J. Gil Bellosta
http://www.cartociudad.es/recursos/Documentacion_tecnica/CARTOCIUDAD_ServiciosWeb.pdf
## Not run: soria <- cartociudad_geocode("plaza de san esteban, soria") soria_map <- cartociudad_get_map(c(soria$lat, soria$lng), 1) ggmap::ggmap(soria_map) ## End(Not run)
## Not run: soria <- cartociudad_geocode("plaza de san esteban, soria") soria_map <- cartociudad_get_map(c(soria$lat, soria$lng), 1) ggmap::ggmap(soria_map) ## End(Not run)
Cartociudad API provides driving and walking routes between two points. This function quieries the API and provides the user the data in convenient form.
cartociudad_get_route(latlon.orig, latlon.dest, vehicle = "car")
cartociudad_get_route(latlon.orig, latlon.dest, vehicle = "car")
latlon.orig |
Latitude and longitude of the starting point |
latlon.dest |
Latitude and longitude of the destination point |
vehicle |
Either |
A list containing the fields described in Cartociudad API documentation (see the link below).
Carlos J. Gil Bellosta
http://www.cartociudad.es/recursos/Documentacion_tecnica/CARTOCIUDAD_ServiciosWeb.pdf
res <- cartociudad_get_route(c(39.48,-0.37), c(39.484336,-0.358171), vehicle = "car")
res <- cartociudad_get_route(c(39.48,-0.37), c(39.484336,-0.358171), vehicle = "car")
Returns the address details of a geographical point in Spain.
cartociudad_reverse_geocode(latitude, longitude)
cartociudad_reverse_geocode(latitude, longitude)
latitude |
Point latitude in geographical coordinates (e.g., 40.473219) |
longitude |
Point longitude in geographical coordinates (e.g., -3.7227241) |
This function performs reverse geocoding of a location. It returns the details of the closest address in Spain.
A list with the following items:
tipo |
type of location. |
tipo.via |
road type. |
nombre.via |
road name. |
num.via |
road number. |
num.via.id |
internal id of this address in cartociudad database. |
municipio |
town. |
provincia |
province. |
cod.postal |
zip code. |
Luz Frias
http://www.cartociudad.es/recursos/Documentacion_tecnica/CARTOCIUDAD_ServiciosWeb.pdf
cartociudad_reverse_geocode(40.473219, -3.7227241)
cartociudad_reverse_geocode(40.473219, -3.7227241)
Returns the polygon that describes the area
get_cartociudad_area(latitude, longitude, radius)
get_cartociudad_area(latitude, longitude, radius)
latitude |
Point latitude in geographical coordinates (e.g., 40.3930144) |
longitude |
Point longitude in geographical coordinates (e.g., -3.6596683) |
radius |
Distance in meters (e.g., 500) |
This function calculates the area given a point and a radius in meters
A dataframe with the polygon that describes the area.
Luz Frias
http://www.cartociudad.es/recursos/Documentacion_tecnica/CARTOCIUDAD_ServiciosWeb.pdf
## Not run: get_cartociudad_area(40.3930144, -3.6596683, 500) ## End(Not run)
## Not run: get_cartociudad_area(40.3930144, -3.6596683, 500) ## End(Not run)
Returns the administrative information related to a geographical point in Spain: province, municipality, censal district, censal section, cadastral reference and reverse geocoding data.
get_cartociudad_location_info(latitude, longitude, year = 2016, info.source = c("census", "cadastre", "reverse"))
get_cartociudad_location_info(latitude, longitude, year = 2016, info.source = c("census", "cadastre", "reverse"))
latitude |
Point latitude in geographical coordinates (e.g., 40.473219) |
longitude |
Point longitude in geographical coordinates (e.g., -3.7227241) |
year |
Reference year; see Details section |
info.source |
A character vector specifying the APIs to consult. Possible values are "census", "cadastre" and "reverse" |
This function consults administrative information for a point within Spain. Censal information is consulted from a different set of layers, each one corresponding to a different year. Whereas provincial and municipal information is mostly stable, censal districts and sections may be subject to greater changes over the years.
A list contaning the administrative information for the given point.
For info.source = "census"
it contains the province, municipality,
censal discrict and censal section codes. For info.source =
"cadastre"
it contains the cadastral reference and the url to the spanish
cadastre website. For info.source = "reverse"
it contains the
details of the address closest to the specified location, such us road
type, number, zip code, street name, ... More information about reverse
geocoding in cartociudad_reverse_geocode
.
Luz Frías with small edits by Carlos J. Gil Bellosta
INE's web service is mostly undocumented and the function has been built by reverse engineering API calls. However, users may want to check the capabilities of INEs WMS service at http://goo.gl/aKn3vj. Cadastre web service documentation can be consulted at http://goo.gl/lKkwK and WMS service capabilities at http://goo.gl/5JAd9N.
## Not run: get_cartociudad_location_info(40.473219, -3.7227241) ## End(Not run)
## Not run: get_cartociudad_location_info(40.473219, -3.7227241) ## End(Not run)
Downloads static maps using Cartociudad API. These maps can be
then plotted by functions such as ggmap
.
get_cartociudad_map(center, radius, add.censal.section = FALSE, add.postcode.area = FALSE, add.cadastral.layer = FALSE, height = 800, width = 1200)
get_cartociudad_map(center, radius, add.censal.section = FALSE, add.postcode.area = FALSE, add.cadastral.layer = FALSE, height = 800, width = 1200)
center |
a pair of numbers (latitude and longitude of the center of the map) |
radius |
approximate map "width" in kilometers |
add.censal.section |
whether to add the limit of censal sections and districts to the base map; note that this layer may not be available at low zoom levels |
add.postcode.area |
whether to add the limit of postal code areas to the base map; note that this layer may not be available at low zoom levels |
add.cadastral.layer |
whether to add cadastral information |
height |
map height in pixels |
width |
map width in pixels |
This function, similar to get_googlemap
or
get_openstreetmap
downloads a map from Cartociudad API and creates a
ggmap
compatible version of it.
An object of class ggmap
and raster
which can be used
within the ggmap
framework.
Carlos J. Gil Bellosta
http://www.cartociudad.es/recursos/Documentacion_tecnica/CARTOCIUDAD_ServiciosWeb.pdf
## Not run: soria <- cartociudad_geocode("plaza de san esteban, soria") soria_map <- get_cartociudad_map(c(soria$lat, soria$lng), 1) ggmap::ggmap(soria_map) ## End(Not run)
## Not run: soria <- cartociudad_geocode("plaza de san esteban, soria") soria_map <- get_cartociudad_map(c(soria$lat, soria$lng), 1) ggmap::ggmap(soria_map) ## End(Not run)
Cartociudad API provides driving and walking routes between two points. This function quieries the API and provides the user the data in convenient form.
get_cartociudad_route(latlon.orig, latlon.dest, vehicle = "car")
get_cartociudad_route(latlon.orig, latlon.dest, vehicle = "car")
latlon.orig |
Latitude and longitude of the starting point |
latlon.dest |
Latitude and longitude of the destination point |
vehicle |
Either |
A list containing the fields described in Cartociudad API documentation (see the link below).
Carlos J. Gil Bellosta
http://www.cartociudad.es/recursos/Documentacion_tecnica/CARTOCIUDAD_ServiciosWeb.pdf
## Not run: res <- get_cartociudad_route(c(39.48,-0.37), c(39.484336,-0.358171), vehicle = "car") ## End(Not run)
## Not run: res <- get_cartociudad_route(c(39.48,-0.37), c(39.484336,-0.358171), vehicle = "car") ## End(Not run)