@@ -33,6 +33,20 @@ pkgs = c(
3333remotes :: install_cran(pkgs )
3434```
3535
36+ Note: as of 2023-08-31 you also need to install the development version of ` sf ` as follows:
37+
38+ ``` r
39+ remotes :: install_github(" r-spatial/sf" )
40+ ```
41+
42+ ``` {r}
43+ #| include: false
44+ # For debugging
45+ # remotes::install_github("r-spatial/sf")
46+ # remotes::install_version("sf", "1.0-10")
47+ # remotes::install_dev("osmextract")
48+ ```
49+
3650You may want to install the following packages for @sec-command-line :
3751
3852- [ osmium] ( https://osmcode.org/osmium-tool/ )
@@ -194,12 +208,6 @@ The package makes your life easy by automating many parts of the OSM extract ide
194208
195209Let's see how it works for the city of Poznan:
196210
197-
198- ``` {r}
199- library(osmextract)
200- library(sf)
201- ```
202-
203211We geocode the coordinates of Poznan, Poland
204212
205213``` {r, eval = FALSE}
@@ -235,7 +243,7 @@ We can download the extract using `oe_get()`, noting the user of `layer = "point
235243``` {r, warning = FALSE, message = FALSE}
236244#| eval: false
237245#| echo: false
238- poznan = oe_get("Poznan", provider = "bbbike", type = "points", force_vectortranslate = TRUE)
246+ poznan = oe_get("Poznan", provider = "bbbike", layer = "points", force_vectortranslate = TRUE)
239247# fails with
240248# The input place was matched with: Poznan
241249# The chosen file was already detected in the download directory. Skip downloading.
@@ -246,30 +254,38 @@ poznan = oe_get("Poznan", provider = "bbbike", type = "points", force_vectortran
246254```
247255
248256``` {r}
257+ #| eval: false
249258poznan = oe_get("Poznan", provider = "bbbike", force_vectortranslate = TRUE)
250259```
251260
252261Note: that takes quite a while download, so we will use a smaller extract for the rest of the session:
253262
263+ ``` {r}
264+ monaco_osm_points = oe_get("monaco", provider = "bbbike", layer = "points")
265+
266+ ```
267+
254268``` {r, warning = FALSE, message = FALSE}
255- #| eval: false
256269# ?oe_get
257- malta_osm_lines = oe_get("malta", provider = "bbbike", type = "lines")
258- malta_osm_mlines = oe_get("malta", provider = "bbbike", type = "multilinestrings")
259- malta_osm_polygons = oe_get("malta", provider = "bbbike", type = "mutlipolygons")
260- malta_osm_other = oe_get("malta", provider = "bbbike", type = "other_relations")
270+ monaco_osm_lines = oe_get("monaco", provider = "bbbike", layer = "lines", skip_vectortranslate = TRUE)
271+ f = list.files(oe_download_directory(), pattern = "monaco", full.names = TRUE)
272+ monaco = sf::read_sf(f[1])
273+ monaco = sf::read_sf(f[2], layer = "lines")
274+ monaco_osm_mlines = oe_get("monaco", provider = "bbbike", layer = "multilinestrings")
275+ monaco_osm_polygons = oe_get("monaco", provider = "bbbike", layer = "multipolygons")
276+ monaco_osm_other = oe_get("monaco", provider = "bbbike", layer = "other_relations")
261277```
262278
263279Let's take a look at the size of each layer, in units of MB:
264280
265281``` {r}
266- #| code-fold: true
267- #| eval: false
268- sapply(list(malta_osm_points, malta_osm_lines, malta_osm_mlines, malta_osm_polygons, malta_osm_other), function(x) {
282+ sapply(list(monaco_osm_points, monaco_osm_lines, monaco_osm_mlines, monaco_osm_polygons, monaco_osm_other), function(x) {
269283 round(object.size(x) / 1e6, 1)
270284})
271285```
272286
287+
288+
273289# Other command line tools for working with OSM data {#sec-command-line}
274290
275291...
0 commit comments