Skip to content

Commit 69a1094

Browse files
committed
Add folding, rm commented docs
1 parent aa4762c commit 69a1094

File tree

1 file changed

+59
-116
lines changed

1 file changed

+59
-116
lines changed

osm.qmd

Lines changed: 59 additions & 116 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
---
22
title: "Processing large OpenStreetMap datasets for research"
33
# Fold code by default:
4-
output:
5-
html_document:
6-
code_folding: hide
4+
format:
5+
html:
6+
code-fold: false
7+
code-summary: "Show the code"
78
---
89

910
# Introduction
@@ -100,168 +101,110 @@ You may want to install the following packages for @sec-command-line:
100101

101102
# How and where to download OSM data {#sec-download}
102103

103-
<!---
104-
This is the docs from osmextract:
105-
106-
107-
Skip to contents
108-
rOpenSci
109-
osmextract
110-
0.5.0.9000
111-
112-
Get started
113-
Reference
114-
Articles
115-
Changelog
116-
117-
Comparing the supported OSM providers
118-
Source: vignettes/providers_comparisons.Rmd
104+
As outlined in the [`providers_comparison`](https://docs.ropensci.org/osmextract/articles/providers_comparisons.html) vignettte in the [`osmextract`](https://docs.ropensci.org/osmextract/) package, there are several providers of OSM data. The main ones that provide regular extracts without need for logins are:
119105

120-
This vignette presents a simple comparison between the OSM providers supported by osmextract, explaining their pros and cons. We decided to write this vignette since, as you will see in the following examples, even if you always start from the same pre-defined place, you can get significantly different OSM extracts according to the chosen provider. Hence, we want to help you choose the best suitable provider for a given situation.
106+
- [geofabrik](https://download.geofabrik.de/)
107+
- [openstreetmap_fr](http://download.openstreetmap.fr/)
108+
- [bbbike](https://download.bbbike.org/osm/bbbike/)
121109

122-
We assume that you are already familiar with the basic functions in osmextract, otherwise please check the “Get Started” vignette for a more detailed introduction. Now, let’s start with an example, but, first of all, we have to load the package:
123110

111+
```{r}
124112
library(osmextract)
125-
#> Data (c) OpenStreetMap contributors, ODbL 1.0. https://www.openstreetmap.org/copyright.
126-
#> Check the package website, https://docs.ropensci.org/osmextract/, for more details.
127113
library(sf)
128-
#> Linking to GEOS 3.10.2, GDAL 3.4.1, PROJ 8.2.1; sf_use_s2() is TRUE
129-
130-
We geocode the coordinates of Lima, the Capital of Peru,
131-
132-
lima = tmaptools::geocode_OSM("Lima, Peru")$coords
133-
134-
and look for a match in the OSM extracts using oe_match():
135-
136-
oe_match(lima, provider = "geofabrik")
137-
#> $url
138-
#> [1] "https://download.geofabrik.de/south-america/peru-latest.osm.pbf"
139-
#>
140-
#> $file_size
141-
#> [1] 1.86e+08
142-
oe_match(lima, provider = "bbbike")
143-
#> $url
144-
#> [1] "https://download.bbbike.org/osm/bbbike/Lima/Lima.osm.pbf"
145-
#>
146-
#> $file_size
147-
#> [1] 15941307
148-
oe_match(lima, provider = "openstreetmap_fr")
149-
#> $url
150-
#> [1] "http://download.openstreetmap.fr/extracts/south-america-latest.osm.pbf"
151-
#>
152-
#> $file_size
153-
#> [1] 3559974408
114+
```
154115

155-
We can see that:
116+
Extracts from each provider are shown in the figures below, generated by code that can be 'unfolded' by clicking on the arrows:
156117

157-
when we used geofabrik provider (which is also the default provider), then the input place was matched with an OSM extract corresponding to Peru region;
158-
when we used the bbbike provider, then the input place was matched with an OSM extract corresponding to the city of Lima;
159-
when we used openstreetmap_fr provider, then the input data was matched with an OSM extract covering the whole of South America.
160118

161-
The reason behind these differences is that each OSM provider divides the geographical space into different discrete chunks, and, in the following paragraphs, we will show the tessellation used by each provider.
162-
Geofabrik
119+
## Geofabrik
163120

164-
geofabrik is a society that provides map-based services and free downloads of OSM extracts that are updated daily. These extracts are based on a division of the world into different regions, covering a whole continent (plus Russian Federation):
121+
`geofabrik` is a society that provides map-based services and free downloads of OSM extracts that are updated daily.
122+
These extracts are based on a division of the world into different regions, covering a whole continent (plus Russian Federation):
165123

124+
```{r}
125+
#| code-fold: true
166126
par(mar = rep(0, 4))
167127
plot(geofabrik_zones[geofabrik_zones$level == 1, "name"], key.pos = NULL, main = NULL)
128+
```
168129

169-
or several countries all around the world:
130+
or several countries all around the world:
170131

132+
```{r}
133+
#| code-fold: true
171134
plot(geofabrik_zones[geofabrik_zones$level == 2, "name"], key.pos = NULL, main = NULL)
135+
```
172136

173-
Geofabrik also defines several special zones, such as Alps, Britain and Ireland, Germany, Austria and Switzerland, US Midwest, US Northeast, US Pacific, US South and US West. Moreover, it contains extracts relative to some administrative subregions, mainly in Europe, Russia, Canada and South America:
137+
Geofabrik also defines several special zones, such as Alps, Britain and Ireland, Germany, Austria and Switzerland, US Midwest, US Northeast, US Pacific, US South and US West.
138+
Moreover, it contains extracts relative to some administrative subregions, mainly in Europe, Russia, Canada and South America:
174139

140+
```{r}
141+
#| code-fold: true
175142
plot(geofabrik_zones[geofabrik_zones$level == 3, "name"], key.pos = NULL, main = NULL)
143+
```
144+
145+
Check `?geofabrik_zones` and the [provider's webpage](http://download.geofabrik.de/) for more details.
176146

177-
Check ?geofabrik_zones and the provider’s webpage for more details.
178-
Openstreetmap.fr
147+
## Openstreetmap.fr
179148

180-
openstreetmap_fr extracts are taken from http://download.openstreetmap.fr/, a web-service that provides OSM data updated every few minutes. The extracts are based on several regions, such as the continents:
149+
`openstreetmap_fr` extracts are taken from http://download.openstreetmap.fr/, a web-service that provides OSM data updated every few minutes.
150+
The extracts are based on several regions, such as the continents:
181151

152+
```{r}
153+
#| code-fold: true
182154
# Russian federation is considered as a level 1 zone
183155
plot(openstreetmap_fr_zones[openstreetmap_fr_zones$level == 1, "name"], key.pos = NULL, main = NULL)
156+
```
184157

185-
or some countries around the world (less than geofabrik):
158+
or some countries around the world (less than `geofabrik`):
186159

160+
```{r}
161+
#| code-fold: true
187162
plot(openstreetmap_fr_zones[openstreetmap_fr_zones$level == 2, "name"], key.pos = NULL, main = NULL)
163+
```
188164

189-
It can be noticed that there are several holes (such as Peru, which is the reason why, in the first example, Lima was matched with South America data), implying that openstreetmap_fr cannot always be used for geographical matching of a place. Nevertheless, it provides extremely detailed extracts for some regions of the world, like China,
165+
It can be noticed that there are several holes (such as Peru, which is the reason why, in the first example, Lima was matched with South America data), implying that `openstreetmap_fr` cannot always be used for geographical matching of a `place`.
166+
Nevertheless, it provides extremely detailed extracts for some regions of the world, like China,
190167

168+
```{r}
169+
#| code-fold: true
191170
plot(openstreetmap_fr_zones[openstreetmap_fr_zones$parent == "china", "name"], key.pos = NULL, main = NULL)
171+
```
192172

193-
India,
173+
India,
194174

175+
```{r}
176+
#| code-fold: true
195177
plot(openstreetmap_fr_zones[openstreetmap_fr_zones$parent == "india", "name"], key.pos = NULL, main = NULL)
178+
```
196179

197-
France,
180+
France,
198181

182+
```{r}
183+
#| code-fold: true
199184
ids_2 = openstreetmap_fr_zones$parent %in% "france"
200185
ids_3 = openstreetmap_fr_zones$parent %in% openstreetmap_fr_zones$id[ids_2]
201186
202187
plot(openstreetmap_fr_zones[ids_2 | ids_3, "name"], key.pos = NULL, main = NULL)
188+
```
203189

204190
and Brazil
205191

192+
```{r}
193+
#| code-fold: true
206194
ids_2 = openstreetmap_fr_zones$parent %in% "brazil"
207195
ids_3 = openstreetmap_fr_zones$parent %in% openstreetmap_fr_zones$id[ids_2]
208196
209197
plot(openstreetmap_fr_zones[ids_2 | ids_3, "name"], key.pos = NULL, main = NULL)
198+
```
210199

211-
BBBike
212-
213-
bbbike provider is based on https://download.bbbike.org/osm/bbbike/. It is quite different from any other provider supported in osmextract since it contains OSM data for more than 200 cities worldwide.
214-
215-
par(mar = rep(0, 4))
216-
plot(sf::st_geometry(spData::world))
217-
plot(sf::st_geometry(bbbike_zones), border = "darkred", add = TRUE, lwd = 3)
218-
219-
bbbike provider is the safest choice if you are looking for OSM data relative to a particular city in the world.
220-
On this page
221-
222-
Geofabrik
223-
Openstreetmap.fr
224-
BBBike
225-
226-
About
227-
About rOpenSci
228-
Software Review
229-
Our Team
230-
Jobs
231-
Donate
232-
Contact Us
233-
234-
Community
235-
Our Community
236-
Community calls
237-
Events
238-
Join the Discussion
239-
Code of conduct
240-
241-
Resources
242-
Packages
243-
Use Cases
244-
Talks & Publications
245-
Documentation
246-
Newsletter
247-
Cite rOpenSci
248-
249-
rOpenSci is a fiscally sponsored project of NumFOCUS.
250-
251-
252-
--->
253-
254-
As outlined in the [`providers_comparison`](https://docs.ropensci.org/osmextract/articles/providers_comparisons.html) vignettte in the [`osmextract`](https://docs.ropensci.org/osmextract/) package, there are several providers of OSM data. The main ones that provide regular extracts without need for logins are:
255-
256-
- [geofabrik](https://download.geofabrik.de/)
257-
- [openstreetmap_fr](http://download.openstreetmap.fr/)
258-
- [bbbike](https://download.bbbike.org/osm/bbbike/)
259-
260-
These are shown in the figures below, generated by code that can be 'unfolded' by clicking on the arrows:
200+
## BBBike
261201

202+
`bbbike` provider is based on https://download.bbbike.org/osm/bbbike/.
203+
It is quite different from any other provider supported in `osmextract` since it contains OSM data for more than 200 cities worldwide.
262204

205+
![](https://docs.ropensci.org/osmextract/reference/figures/96640949-3f7f7480-1324-11eb-9dca-a971c8103a4e.png)
263206

264-
...
207+
`bbbike` provider is the safest choice if you are looking for OSM data relative to a particular city in the world.
265208

266209
# How to process small amounts of OSM data using the osmdata R package {#sec-osmdata}
267210

0 commit comments

Comments
 (0)