Last active
February 4, 2023 21:09
-
-
Save kadyb/1961dae1ac0e020b02607454c1ae187e to your computer and use it in GitHub Desktop.
Extract national roads from Microsoft's dataset (Bing Maps) in R
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library("sf") | |
library("readr") | |
library("geojsonsf") | |
## download all roads for Europe | |
data = "https://usaminedroads.blob.core.windows.net/road-detections/Europe-Full.zip" | |
options(timeout = 6000) | |
download.file(data, "Europe-Full.zip") | |
unzip("Europe-Full.zip") | |
## read data in chunks (and select only in Czech Republic) | |
f = function(x, pos) subset(x, country == "CZE") | |
df = read_tsv_chunked("Europe-Full.tsv", DataFrameCallback$new(f), | |
col_names = c("country", "geom"), | |
chunk_size = 100000, col_types = "fc") | |
geom = geojson_sfc(df$geom) | |
write_sf(geom, "CZE.gpkg") # save as geopackage |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment