Title: | Facilitates matching lat/lon data with administrative units and other geographic shapes |
---|---|
Description: | Facilitates matching lat/lon data with administrative units and other geographic shapes |
Authors: | Giorgio Comai [aut, cre] |
Maintainer: | Giorgio Comai <[email protected]> |
License: | GPL-3 |
Version: | 0.0.0.9008 |
Built: | 2024-11-02 05:43:56 UTC |
Source: | https://github.com/giocomai/latlon2map |
Run the Shiny Application
ll_app(max_file_size = 100, ll_folder_path = NULL, ...)
ll_app(max_file_size = 100, ll_folder_path = NULL, ...)
max_file_size |
Maximum file size to accept for upload expressed in MB, defaults to 100. |
ll_folder_path |
If given, sets the folder to use for caching, corresponds to |
... |
A series of options to be used inside the app. |
This is useful in particular to make geom_sf()-based ggplots with consistent aspect ratio.
ll_bbox(sf, ratio = "4:3")
ll_bbox(sf, ratio = "4:3")
sf |
An sf object. |
ratio |
Defaults to "4:3". A chacters string, in the form of e.g. "4:3" or "16:9" or "1:1" (other values possible) |
A bounding box vector, same as with sf::st_bbox()
, but with the given ratio set and compatible with crs 4326.
## Not run: # The following two graphs will have same 4:3 aspect ratio ll_set_folder("~/R/") library("ggspatial") sf_location <- ll_get_nuts_it(name = "Palmanova", level = "lau", resolution = "low") ggplot() + annotation_map_tile(type = "osm", zoomin = -1, cachedir = fs::path(ll_set_folder(), "ll_data")) + geom_sf(data = sf::st_as_sfc(ll_bbox(sf_location)), fill = NA, color = NA) + geom_sf( data = sf_location, colour = "darkred", size = 2, fill = NA, alpha = 0.8 ) sf_location <- ll_get_nuts_it(name = "Pinzolo", level = "lau", resolution = "low") ggplot() + annotation_map_tile(type = "osm", zoomin = -1, cachedir = fs::path(ll_set_folder(), "ll_data")) + geom_sf(data = sf::st_as_sfc(ll_bbox(sf_location)), fill = NA, color = NA) + geom_sf( data = sf_location, colour = "darkred", size = 2, fill = NA, alpha = 0.8 ) ## End(Not run)
## Not run: # The following two graphs will have same 4:3 aspect ratio ll_set_folder("~/R/") library("ggspatial") sf_location <- ll_get_nuts_it(name = "Palmanova", level = "lau", resolution = "low") ggplot() + annotation_map_tile(type = "osm", zoomin = -1, cachedir = fs::path(ll_set_folder(), "ll_data")) + geom_sf(data = sf::st_as_sfc(ll_bbox(sf_location)), fill = NA, color = NA) + geom_sf( data = sf_location, colour = "darkred", size = 2, fill = NA, alpha = 0.8 ) sf_location <- ll_get_nuts_it(name = "Pinzolo", level = "lau", resolution = "low") ggplot() + annotation_map_tile(type = "osm", zoomin = -1, cachedir = fs::path(ll_set_folder(), "ll_data")) + geom_sf(data = sf::st_as_sfc(ll_bbox(sf_location)), fill = NA, color = NA) + geom_sf( data = sf_location, colour = "darkred", size = 2, fill = NA, alpha = 0.8 ) ## End(Not run)
Create folders to store geographic data
ll_create_folders( geo, level, resolution, year, file_type = c("shp", "zip", "rds") )
ll_create_folders( geo, level, resolution, year, file_type = c("shp", "zip", "rds") )
geo |
The geographic unit of reference as a two-letter code |
level |
E.g. NUTS0, NUTS1, or county, state, ecc. |
resolution |
Either resolution level as given by the data distributor, or generic such as "high", "low", or "default |
file_type |
By defaults, it creates folder for zip, shp, and rds files. |
Attention: this function requires libkml.
ll_export_sf_to_kml( sf, path, name = NULL, keep_other_columns = TRUE, description = NULL, label_text = NULL, label_font = "Roboto Sans, Noto Sans, Helvetica", label_size = "24pt", label_placement = "m", label_scale = NULL, line_colour = "#ffffffff", line_width = "3px", icon_url = "", icon_colour = "#000000ff", icon_scale = NULL, fill_colour = NULL )
ll_export_sf_to_kml( sf, path, name = NULL, keep_other_columns = TRUE, description = NULL, label_text = NULL, label_font = "Roboto Sans, Noto Sans, Helvetica", label_size = "24pt", label_placement = "m", label_scale = NULL, line_colour = "#ffffffff", line_width = "3px", icon_url = "", icon_colour = "#000000ff", icon_scale = NULL, fill_colour = NULL )
sf |
An object of class |
path |
Path where to save the .kml output. |
name |
Column to be used for names. |
keep_other_columns |
Logical, defaults to TRUE. If you don't want to keep in the output data columns present in the original |
description |
Column to be used for description. |
label_text |
Column to be used as label text. Defaults to NULL. Corresponds to "LABEL" element in OGR. |
label_font |
Font family to be used for the font. Defaults to "Roboto Sans, Noto Sans, Helvetica" |
label_size |
Size of the label. Defaults to "24pt" |
label_placement |
Defaults to "m" (centre and middle-aligned). For more options, check: https://gdal.org/user/ogr_feature_style.html |
label_scale |
Scale of label. Defaults to NULL. If given, changes label size (e.g. 1 = default, 2 = twice as big, 0.5, half as big, etc.) |
line_colour |
Defaults to "#ffffffff" (i.e. white, with 100% opacity). Line corresponds to "PEN" in OGR. Accepts 8-digit hex codes to include transparency. |
line_width |
Defaults to "3pt". Line corresponds to "PEN" in OGR. Besides pt (points), other acceptable units are |
icon_url |
Defaults to "" for no URL. Corresponds to "SYMBOL" in OGR. In case of wrong inputs, Google Earth may show you an ugly yellow pushpin instead (i.e. default to http://maps.google.com/mapfiles/kml/pushpin/ylw-pushpin.png). Available icons offered by Google available at this link: http://kml4earth.appspot.com/icons.html |
icon_colour |
Defaults to "#000000ff" (i.e. black, with 100% opacity). |
icon_scale |
Defaults to NULL. If given, changes icon size (e.g. 1 = default, 2 = twice as big, 0.5, half as big, etc.) |
fill_colour |
Defaults to NULL. Fill corresponds to "BRUSH" in OGR. If given, colour to be used for filling polygons. |
Attention: label styling is not currently functional, likely due to issues in passing arguments to libkml. In order to change label size, use label_scale, which directly edits the xml file.
For further details on the exact meaning of each of the parameters, please consult the documentation of OGR (used by GDAL to pass parameters to .kml): https://gdal.org/user/ogr_feature_style.html
Find file names. Mostly used internally
ll_find_file(geo, level, resolution, year, name = "abl", file_type = "rds")
ll_find_file(geo, level, resolution, year, name = "abl", file_type = "rds")
name |
Name of specific dataset being downloaded. Defaults to abl, i.e. administrative boundary line |
file_type |
Find the population-weighted centre of a municipality
ll_find_pop_centre( sf_location, sf_population_grid, power = 2, join = sf::st_intersects, adjusted = FALSE )
ll_find_pop_centre( sf_location, sf_population_grid, power = 2, join = sf::st_intersects, adjusted = FALSE )
power |
Defaults to 2. To give more weight to cells with higher population density, raise the number of residents by the power of. |
join |
Defaults to sf::st_intersects. |
adjusted |
If adjusted is set to TRUE, join is ignored. The population of cells along the boundary line are weighted by the share of the cell included within the border. |
ll_set_folder("~/R/") name <- "Pinzolo" sf_location <- ll_get_nuts_it(name = name, level = "lau", resolution = "high") lau_grid_name_temp <- stringr::str_c(name, "_lau_high-st_intersects") sf_location_grid <- ll_get_population_grid( match_sf = sf_location, match_name = lau_grid_name_temp, match_country = "IT", join = sf::st_intersects ) pop_centre <- ll_find_pop_centre( sf_location = sf_location, sf_population_grid = sf_location_grid, power = 2 )
ll_set_folder("~/R/") name <- "Pinzolo" sf_location <- ll_get_nuts_it(name = name, level = "lau", resolution = "high") lau_grid_name_temp <- stringr::str_c(name, "_lau_high-st_intersects") sf_location_grid <- ll_get_population_grid( match_sf = sf_location, match_name = lau_grid_name_temp, match_country = "IT", join = sf::st_intersects ) pop_centre <- ll_find_pop_centre( sf_location = sf_location, sf_population_grid = sf_location_grid, power = 2 )
Source: https://data.humdata.org/
ll_get_adm_ocha( geo, level = 0, match_name = NULL, source_url = NULL, silent = FALSE )
ll_get_adm_ocha( geo, level = 0, match_name = NULL, source_url = NULL, silent = FALSE )
geo |
A twe letter country code, such as "IT" for Italy and "DE" for Germany |
match_name |
A name to be used for local caching if a subset of the grid is used. It is the responsibility of the user to keept it consistent. If not given, data are not cached locally. |
source_url |
A direct link to the zipped version of the csv file in the original database, if automatic download with the country code does not work. For example, for Italy this would be "https://data.humdata.org/dataset/0eb77b21-06be-42c8-9245-2edaff79952f/resource/1e96f272-7d86-4108-b4ca-5a951a8b11a0/download/population_ita_2019-07-01.csv.zip" |
silent |
if (interactive) { ll_get_adm_ocha(geo = "UA", level = 3) }
if (interactive) { ll_get_adm_ocha(geo = "UA", level = 3) }
2022 / WGS 84 / UTM zone 32N
ll_get_electoral_districts_it( name = NULL, level = "Circoscrizioni_Camera", year = 2022, silent = FALSE, no_check_certificate = FALSE )
ll_get_electoral_districts_it( name = NULL, level = "Circoscrizioni_Camera", year = 2022, silent = FALSE, no_check_certificate = FALSE )
level |
Defaults to "Circoscrizioni_Camera". Valid values:
|
year |
Defaults to 2022 (latest available). Currently no other year accepted. |
no_check_certificate |
Logical, defaults to TRUE. Enable only if certificate issues, and if you are aware of the security implications. |
Column names metadata:
COD_REG Codice della regione/circoscrizione elettorale del Senato della Repubblica
DEN_REG Denominazione della regione amministrativa/circoscrizione elettorale Senato della Repubblica
COD_PRO Codice della provincia
DEN_P_CM Denominazione della provincia o città metropolitana
COD_CM Codice della città metropolitana
PRO_COM Codice del comune
DEN_COM Denominazione del comune
CAP_DEN Denominazione del capoluogo di provincia o città metropolitana
POP_2011 Popolazione - Censimento 2011
ASC_COD Codice concatenato comune e area sub-comunale
ASC_COD1 Codice progressivo area sub-comunale
ASC_COD2 Codice alfanumerico dell'area sub-comunale attribuito dal comune
ASC_NOME Denominazione dell'area sub-comunale
ASC_TIPO Tipologia di area-sub-comunale
CIRC_COD Codice della circoscrizione elettorale della Camera dei deputati
CIRC_DEN Denominazione della circoscrizione elettorale della Camera dei deputati
CU20_COD Codice del collegio elettorale uninominale della Camera dei deputati
CP20_COD Codice del collegio elettoraleplurinominale della Camera dei deputati
SU20_COD Codice del collegio elettorale uninominale del Senato della Repubblica
SP20_COD Codice del collegio elettorale plurinominale del Senato della Repubblica
CU20_DEN Denominazione del collegio elettorale uninominale della Camera dei deputati
CP20_DEN Denominazione del collegio elettorale plurinominale della Camera dei deputati
SU20_DEN Denominazione del collegio elettorale uninominale del Senato della Repubblica
SP20_DEN Denominazione del collegio elettorale plurinominale del Senato della Repubblica
CU20_C1 Sigla del collegio elettorale uninominale della Camera dei deputati
CP20_C1 Sigla del collegio elettorale plurinominale della Camera dei deputati
SU20_C1 Sigla del collegio elettorale uninominale del Senato della Repubblica
SP20_C1 Sigla del collegio elettorale plurinominale del Senato della Repubblica
ll_set_folder(fs::path(fs::path_home_r(), "R")) ll_get_electoral_districts_it() ll_get_electoral_districts_it(name = "Lombardia 2") ll_get_electoral_districts_it() %>% ggplot2::ggplot() + ggplot2::geom_sf() + ggplot2::labs(title = "Circoscrizioni Camera") ll_get_electoral_districts_it(level = "SENATO_CollegiUNINOMINALI_2020") %>% ggplot2::ggplot() + ggplot2::geom_sf() + ggplot2::labs(title = "Collegi uninominali - Senato")
ll_set_folder(fs::path(fs::path_home_r(), "R")) ll_get_electoral_districts_it() ll_get_electoral_districts_it(name = "Lombardia 2") ll_get_electoral_districts_it() %>% ggplot2::ggplot() + ggplot2::geom_sf() + ggplot2::labs(title = "Circoscrizioni Camera") ll_get_electoral_districts_it(level = "SENATO_CollegiUNINOMINALI_2020") %>% ggplot2::ggplot() + ggplot2::geom_sf() + ggplot2::labs(title = "Collegi uninominali - Senato")
Source: https://gadm.org/
ll_get_gadm(geo, level = 0, version = "4.1")
ll_get_gadm(geo, level = 0, version = "4.1")
geo |
Three letter country codes. If a two letter country code is given, it will tentatively be converted to a three-letter country code. Check consistency. |
level |
Defaults to 0. Available labels, depending on data availability for the specific country, between 0 and 3. |
version |
Defaults to "4.0". Untested with others. |
An sf
object
ll_get_gadm(geo = "UKR", level = 2)
ll_get_gadm(geo = "UKR", level = 2)
Source: https://ec.europa.eu/eurostat/web/gisco/geodata/reference-data/administrative-units-statistical-units/lau#lau18
ll_get_lau_eu( gisco_id = NULL, name = NULL, year = 2021, silent = FALSE, lau_sf = NULL, fallback = TRUE )
ll_get_lau_eu( gisco_id = NULL, name = NULL, year = 2021, silent = FALSE, lau_sf = NULL, fallback = TRUE )
gisco_id |
Gisco identifier of the relevant administrative unit. If given, takes precedence over name. |
name |
Name of the local administrative unit in the local language. Use gisco_id whenever possible, as names of local administrative units are not unique, e.g. there are 11 "Neuenkirchen" in the dataset. If both |
year |
Year of mapping, defaults to most recent (2021). Available starting with 2011. |
silent |
Defaults to FALSE. If TRUE, hides copyright notice. Useful e.g. when using this in reports or in loops. The copyright notice must still be shown where the final output is used. |
lau_sf |
sf object, exactly such as the one that would be returned by |
European LAU in sf format
ll_set_folder("~/R/") ll_get_lau_eu()
ll_set_folder("~/R/") ll_get_lau_eu()
Source: https://ec.europa.eu/eurostat/web/gisco/geodata/reference-data/administrative-units-statistical-units/lau
ll_get_lau_nuts_concordance(lau_year = 2019, nuts_year = 2016, silent = FALSE)
ll_get_lau_nuts_concordance(lau_year = 2019, nuts_year = 2016, silent = FALSE)
lau_year |
Defaults to 2019. See |
nuts_year |
Defaults to 2016. See |
silent |
Defaults to FALSE. If TRUE, hides copyright notice. Useful e.g. when using this in reports or in loops. The copyright notice must still be shown where the final output is used. |
Warning: due to issues in the original data, nuts may not always correspond to the given year for all countries, e.g. in files with nuts 2016 one may find nuts 2013 for single country, e.g. Italy. Do check the sources for details and ensure complete matching.
A tibble with a correspondence table.
ll_set_folder("~/R/") ll_get_lau_nuts_concordance() ## Not run: lau_with_nuts_df <- ll_get_lau_eu(year = 2018) %>% sf::st_drop_geometry() %>% filter(is.na(LAU_NAME) == FALSE) %>% dplyr::rename(gisco_id = GISCO_ID) %>% dplyr::left_join( y = ll_get_lau_nuts_concordance( lau_year = 2018, nuts_year = 2016 ), by = "gisco_id" ) ## End(Not run)
ll_set_folder("~/R/") ll_get_lau_nuts_concordance() ## Not run: lau_with_nuts_df <- ll_get_lau_eu(year = 2018) %>% sf::st_drop_geometry() %>% filter(is.na(LAU_NAME) == FALSE) %>% dplyr::rename(gisco_id = GISCO_ID) %>% dplyr::left_join( y = ll_get_lau_nuts_concordance( lau_year = 2018, nuts_year = 2016 ), by = "gisco_id" ) ## End(Not run)
Source: https://dados.gov.pt/pt/datasets/freguesias-de-portugal/
ll_get_lau_pt( id = NULL, name = NULL, year = 2017, level = "concelho", silent = FALSE )
ll_get_lau_pt( id = NULL, name = NULL, year = 2017, level = "concelho", silent = FALSE )
id |
A character vector composed of six digits. Corresponds to "dicofre". |
year |
Defaults to 2017 (latest and currently only available). |
level |
Defaults to "freguesia". Valid value include "freguesia", "concelho", "distrito", "des_simpli". |
ll_set_folder(fs::path(fs::path_home_r(), "R")) ll_get_lau_pt() ll_get_lau_pt(name = "Porto")
ll_set_folder(fs::path(fs::path_home_r(), "R")) ll_get_lau_pt() ll_get_lau_pt(name = "Porto")
Source: https://ec.europa.eu/eurostat/web/gisco/geodata/reference-data/administrative-units-statistical-units/nuts#nuts16
ll_get_nuts_eu( nuts_id = NULL, nuts_name = NULL, level = 3, resolution = 60, year = 2021, silent = FALSE )
ll_get_nuts_eu( nuts_id = NULL, nuts_name = NULL, level = 3, resolution = 60, year = 2021, silent = FALSE )
nuts_id |
NUTS id. Must correspond to the level given. e.g. "DE149" for the NUTS3 regionion of Sigmaringen in Germany. |
nuts_name |
Name of the NUTS region. Run |
level |
Defaults to 3, corresponding to nuts3. Available values are: 0, 1, 2, and 3. |
resolution |
Defaults to "60", for 1:60 Million. Available values: are 20, 10, 3, 1 (1 is highest quality available). |
year |
Defaults to 2021 Available values: 2021, 2016, 2013, 2010, 2006, 2003 |
NUTS in sf format
ll_get_nuts_eu()
ll_get_nuts_eu()
2019 / WGS84 UTM32N
ll_get_nuts_it( name = NULL, level = 2, year = 2023, resolution = "low", silent = FALSE, no_check_certificate = FALSE )
ll_get_nuts_it( name = NULL, level = 2, year = 2023, resolution = "low", silent = FALSE, no_check_certificate = FALSE )
level |
Defaults to "2", i.e. regioni. Available: "3" (i.e. province), and "lau", local administrative units. |
year |
Defaults to 2023 (latest available). |
resolution |
Defaults to "low". Valid values are either "low" or "high". |
no_check_certificate |
Logical, defaults to FALSE. Enable only if certificate issues, and if you are aware of the security implications. |
ll_set_folder(fs::path(fs::path_home_r(), "R")) ll_get_nuts_it() ll_get_nuts_it(name = "Rimini", level = 3)
ll_set_folder(fs::path(fs::path_home_r(), "R")) ll_get_nuts_it() ll_get_nuts_it(name = "Rimini", level = 3)
Source: https://www.census.gov/geographies/mapping-files/time-series/geo/carto-boundary-file.html
ll_get_nuts_us(level = "county", resolution = "500k", year = 2018)
ll_get_nuts_us(level = "county", resolution = "500k", year = 2018)
level |
Defaults to "county". Available options are: "cd116" (for congressional districts of the 116th Congress) |
resolution |
Defaults to "500k", max available resolution. Available options are: "5m" and "20m" |
year |
Defaults to 2018 |
ll_get_nuts_us(level = "county", resolution = "500k", year = 2018)
ll_get_nuts_us(level = "county", resolution = "500k", year = 2018)
Source: https://ec.europa.eu/eurostat/web/gisco/geodata/reference-data/population-distribution-demography/geostat More details: https://ec.europa.eu/eurostat/statistics-explained/index.php/Population_grids
ll_get_population_grid( year = 2018, match_sf = NULL, match_name = NULL, match_country = NULL, join = sf::st_intersects, silent = FALSE, population_grid_sf = NULL )
ll_get_population_grid( year = 2018, match_sf = NULL, match_name = NULL, match_country = NULL, join = sf::st_intersects, silent = FALSE, population_grid_sf = NULL )
year |
Defaults to 2018. Currently, the EU population grid is available only for the year 2006, 2011, and 2018. |
match_sf |
An sf object to be matched with the population grid. If not given, full grid is returned. |
match_name |
A name to be used for local caching. It is the responsibility of the user to keept it consistent. If not given, data are not cached locally. |
match_country |
Defaults to NULL. If given, used to speed up processing. |
join |
The function to use for filtering. Defaults to sf::st_intersects. Alternative includes the likes of sf::st_within, sf::st_touches, etc. |
population_grid_sf |
Defaults to NULL. If given, it uses this one as population grid of reference. Useful to bulk process items, as it removes the need for re-loading the grid from local storage at each iteration. |
An sf object with the population grid.
Source: https://data.humdata.org/organization/facebook Details on methodology: https://dataforgood.fb.com/docs/methodology-high-resolution-population-density-maps-demographic-estimates/
ll_get_population_grid_hr( geo, match_sf = NULL, match_name = NULL, population_grid_sf = NULL, join = sf::st_intersects, file_format = "CSV", dataset = "population|general", source_url = NULL, silent = FALSE )
ll_get_population_grid_hr( geo, match_sf = NULL, match_name = NULL, population_grid_sf = NULL, join = sf::st_intersects, file_format = "CSV", dataset = "population|general", source_url = NULL, silent = FALSE )
geo |
A twe letter country code, such as "IT" for Italy and "DE" for Germany |
match_sf |
An sf object to me matched with the population grid. If not given, full grid is returned. |
match_name |
A name to be used for local caching if a subset of the grid is used. It is the responsibility of the user to keept it consistent. If not given, data are not cached locally. |
file_format |
Defaults to "CSV". Other available formats include "GeoTIFF", "JSON", "zip", "GDAL Virtual Format". Currently only CSV supported. |
dataset |
Defaults to "population". Beginning of the name of the dataset. For alternatives, see e.g. |
source_url |
A direct link to the zipped version of the csv file in the original database, if automatic download with the country code does not work. For example, for Italy this would be "https://data.humdata.org/dataset/0eb77b21-06be-42c8-9245-2edaff79952f/resource/1e96f272-7d86-4108-b4ca-5a951a8b11a0/download/population_ita_2019-07-01.csv.zip" |
silent |
Get countries as an sf object
ll_get_world(resolution = "60", year = 2020, name = NULL)
ll_get_world(resolution = "60", year = 2020, name = NULL)
resolution |
Defaults to "60", for 1:60 Million. Available values: are 20, 10, 3, 1 (1 is highest quality available)- |
year |
Defaults to 2020. Available values: 2020, 2016, 2013, 2010, 2006, 2001 |
Matches a data frame with longitude and latitude to an sf object
ll_match( data, longitude = 1, latitude = 2, join = sf::st_intersects, sample = NULL, match = longlat2map::ll_get_world() )
ll_match( data, longitude = 1, latitude = 2, join = sf::st_intersects, sample = NULL, match = longlat2map::ll_get_world() )
data |
A data frame or tibble with a column for longitude and one for latitude or an onject of the sf class. If an sf object is given, the longitude and latitude parameters are ignored. |
longitude |
The exact column name or the column index (e.g. 1 if first column) for longitude. Defaults to 1. |
latitude |
The exact column name or the column index (e.g. 1 if first column) for latitude. Defaults to 2. |
join |
A function of the sf class determining the type of join. Defaults to |
sample |
Defaults to NULL. If given, it runs the matching with only a subset of the original dataframe. Suggested for testing in particular when working with big datasets. |
match |
An sf object to be matched with the given dataframe, defaults to |
An sf object with CRS 4326.
A dataset with all names of countries, continents, as included in the Geofabrik database.
They are used to download files with ll_osm_download()
ll_osm_countries
ll_osm_countries
A tibble
Name of the continent
Name of the country
Link to shapefiles in a tibble
Links to shapefiles are stored as tibbles. Unnest to see them, e.g.
ll_osm_countries %>% tidyr::unnest(link)
or for a single country:
ll_osm_countries %>% dplyr::filter(country == "italy") %>% tidyr::unnest(link)
N.B. Names do not always correspond to official name of countries and may include different geographic entities.
For a full list of available "countries" as made available by Geofabrik, see the internal dataset ll_osm_countries
.
Be considered in downloading files.
ll_osm_download(countries, overwrite = FALSE, wget = FALSE)
ll_osm_download(countries, overwrite = FALSE, wget = FALSE)
countries |
One or more country names. For details on available country names see the dataset included in this package: |
overwrite |
Logical, defaults to FALSE. If true, downloads new files even if already present. |
wget |
Logical, defaults to FALSE. If TRUE, it downloads files with wget (if available), otherwise uses default method. Setting wget to TRUE may contribute to prevent download timeouts; notice that apparent freeze of the download progress in the console are common, and mostly the download is just continuing in the background (for reference, check file size in folder.) |
Used only for its side effects (downloads osm data).
## Not run: ll_osm_download(countries = "Romania") ll_osm_download(countries = c("chile", "colombia")) ## End(Not run)
## Not run: ll_osm_download(countries = "Romania") ll_osm_download(countries = c("chile", "colombia")) ## End(Not run)
See ll_osm_it_gpkg
for all available files.
ll_osm_download_it( level = "comuni", name = NULL, code = NULL, overwrite = FALSE, wget = FALSE, quiet = FALSE )
ll_osm_download_it( level = "comuni", name = NULL, code = NULL, overwrite = FALSE, wget = FALSE, quiet = FALSE )
level |
One of "regioni", "provincie", "comuni". Defaults to "comuni". |
name |
Name of geographic entity. Check |
code |
Used in alternative to name. Check |
wget |
Logical, defaults to FALSE. If TRUE, it downloads files with wget (if available), otherwise uses default method. Setting wget to TRUE may contribute to prevent download timeouts; notice that apparent freeze of the download progress in the console are common, and mostly the download is just continuing in the background (for reference, check file size in folder.) |
quiet |
Logical, defaults to FALSE. If TRUE no messages about download advancement are printed. |
Used only for its side effects (downloads osm data).
## Not run: ll_osm_download_it(level = "comuni", name = "Trento") ## End(Not run)
## Not run: ll_osm_download_it(level = "comuni", name = "Trento") ## End(Not run)
See ll_osm_it_gpkg
for all available files.
ll_osm_extract_it( level = "comuni", name = NULL, code = NULL, layer = "lines", quiet = FALSE )
ll_osm_extract_it( level = "comuni", name = NULL, code = NULL, layer = "lines", quiet = FALSE )
level |
One of "regioni", "provincie", "comuni". Defaults to "comuni". |
name |
Name of geographic entity. Check |
code |
Used in alternative to name. Check |
layer |
Defaults to "lines". Must be one of "points", "lines", "multilinestrings", "multipolygons", or "other_relations" |
quiet |
Logical, defaults to FALSE. If TRUE, supresses messages generated when reading the geopackage file. |
An sf object.
## Not run: ll_osm_extract_it(level = "comuni", name = "Trento") ## End(Not run)
## Not run: ll_osm_extract_it(level = "comuni", name = "Trento") ## End(Not run)
Extract from zip shape files of roads from previously downloaded
ll_osm_extract_roads(countries, download_if_missing = TRUE, overwrite = FALSE)
ll_osm_extract_roads(countries, download_if_missing = TRUE, overwrite = FALSE)
countries |
The name of one or more geographic entities from files typically previously downloaded with |
download_if_missing |
Logical, defaults to TRUE. If TRUE, downloads country files with |
overwrite |
Logical, defaults to FALSE. If TRUE, extracts files from zip even if folder already existing. |
Nothing, used for its side effects (extracts shapefiles from country-level zip files)
## Not run: ll_extract_roads(countries = "Romania") ## End(Not run)
## Not run: ll_extract_roads(countries = "Romania") ## End(Not run)
Relies on the output of ll_get_lau_eu()
for the boundaries of local
administrative units.
ll_osm_get_lau_streets( gisco_id, country = NULL, unnamed_streets = TRUE, lau_boundary_sf = NULL, streets_sf = NULL, country_code_type = "eurostat", year = 2021, fallback = TRUE )
ll_osm_get_lau_streets( gisco_id, country = NULL, unnamed_streets = TRUE, lau_boundary_sf = NULL, streets_sf = NULL, country_code_type = "eurostat", year = 2021, fallback = TRUE )
gisco_id |
Gisco identifier. |
country |
Name of country as included in Geofabrik's datasets, does not
always match common country names or geography. For details on available
country names see the dataset included in this package: |
unnamed_streets |
Defaults to TRUE. If FALSE, it drops all streets with missing "name" or missing "fclass". |
lau_boundary_sf |
Defaults to NULL. If given, used to speed up
processing. Must be an |
streets_sf |
Defaults to NULL. If given, used to speed up processing.
Must be an |
country_code_type |
Defaults to "eurostat". An alternative common value
is "iso2c". See |
year |
Year of LAU boundaries, defaults to most recent (2021), passed to
|
fallback |
Logical, defaults to TRUE. If a |
An sf
objects with all streets of a given LAU based on
OpenStreetMap
## Not run: ll_osm_get_lau_streets(gisco_id = "IT_022205", unnamed_streets = FALSE) # or if country name does not match ll_osm_get_lau_streets(gisco_id = "EL_01020204", country = "greece") ## End(Not run)
## Not run: ll_osm_get_lau_streets(gisco_id = "IT_022205", unnamed_streets = FALSE) # or if country name does not match ll_osm_get_lau_streets(gisco_id = "EL_01020204", country = "greece") ## End(Not run)
Relies on the output of ll_get_nuts_eu()
for the boundaries of NUTS.
ll_osm_get_nuts_streets( nuts_id, level = 3, resolution = 1, country = NULL, unnamed_streets = TRUE, nuts_boundary_sf = NULL, streets_sf = NULL, country_code_type = "eurostat", year = 2021 )
ll_osm_get_nuts_streets( nuts_id, level = 3, resolution = 1, country = NULL, unnamed_streets = TRUE, nuts_boundary_sf = NULL, streets_sf = NULL, country_code_type = "eurostat", year = 2021 )
nuts_id |
NUTS region identifier. |
country |
Name of country as included in Geofabrik's datasets, does not
always match common country names or geography. For details on available
country names see the dataset included in this package: |
unnamed_streets |
Defaults to TRUE. If FALSE, it drops all streets with missing "name" or missing "fclass". |
streets_sf |
Defaults to NULL. If given, used to speed up processing.
Must be an |
country_code_type |
Defaults to "eurostat". An alternative common value
is "iso2c". See |
year |
Year of LAU boundaries, defaults to most recent (2021), passed to
|
An sf
objects with all streets of a given NUTS regions based on
OpenStreetMap
## Not run: ll_osm_get_nuts_streets(nuts_id = "PT16D", country = "portugal") ## End(Not run)
## Not run: ll_osm_get_nuts_streets(nuts_id = "PT16D", country = "portugal") ## End(Not run)
Extract shape files of roads from previously downloaded
ll_osm_get_roads(country, silent = FALSE)
ll_osm_get_roads(country, silent = FALSE)
country |
The name of one or more geographic entities from files typically previously downloaded with |
silent |
Defaults to FALSE. If TRUE, hides copyright notice. Useful e.g. when using this in reports or in loops. The copyright notice must still be shown where the final output is used. |
All roads in a country by OpenStreetMap.
## Not run: ll_osm_get_roads(country = "Romania") ## End(Not run)
## Not run: ll_osm_get_roads(country = "Romania") ## End(Not run)
A dataset with all names of geographic entities available for direct download as geopackage files
They are used to download files with ll_osm_download_it()
ll_osm_it_gpkg
ll_osm_it_gpkg
A list of tibbles
https://osmit-estratti.wmcloud.org/
Set folder for caching data
ll_set_folder(path = NULL)
ll_set_folder(path = NULL)
path |
A path to a location. If the folder does not exist, it will be created. |
The path to the caching folder, if previously set.
It is used to download files with ll_get_population_grid_hr()
population_grid_hr_metadata
population_grid_hr_metadata
A tibble
Name of the country in English
Two letter code as used by eurostat, see also countrycode::codelist$eurostat
Link to zipped dataset
Link to page describing the dataset