-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME.Rmd
169 lines (117 loc) · 8.06 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
warning = F,
dev = "ragg_png",
fig.width = 10,
out.width = "100%",
dpi = 300,
fig.asp = .7,
fig.retina = 3,
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# pragr: use Prague geodata in R <a href='https://petrbouchal.github.io/pragr'><img src='man/figures/logo.png' align="right" height="138.5" /></a>
<!-- badges: start -->
[](https://www.tidyverse.org/lifecycle/#experimental)
[](https://CRAN.R-project.org/package=pragr)
[](https://github.com/petrbouchal/pragr/actions/workflows/R-CMD-check.yaml)
<!-- badges: end -->
```{r, results='asis', echo=FALSE}
if(pkgdown:::dev_mode(pkgdown:::read_desc()$get_version(), pkgdown:::read_desc()$get_version()) == "devel") {
meta_dest <- pkgdown:::read_meta(".")$development$destination
meta_base_url <- pkgdown:::read_meta(".")$url
if(is.null(meta_dest)) {
dst <- "dev"
} else {
dst <- meta_dest
}
devurl <- paste0(meta_base_url, "/", dst)
cat(paste0("> Note: this is the documentation for the latest released version (the github release). Documentation for the current development version (reflecting the state of the master branch) is at [", devurl, "](", devurl,")."))
}
```
`pragr` aims to provide tools for visualising data about Prague. Currently, it makes Prague raster geodata accessible for use in R via `ggplot2`.
It also provides a set of utilities and shortcuts to simplify handling data about Prague.
## Installation
You can install the current version of `pragr` from GitHub with:
``` r
remotes::install_github("petrbouchal/pragr")
```
## What it does
Currently, the 📦 enables you to do two things:
1. Add raster tiles from the Prague geoopen data portal to a `ggplot2` object (`prg_tile()`)
2. Add other raster layer to a `ggplot2` object (`prg_basemap()`)
The basic logic of the two core functions is that given a simple feature dataset, they provide the tiles or image to create the base map for those coordinates.
It relies on the REST API of ArcGis map/image services that power the geoportal, using documentation for the following operations (endpoints):
- [Image Tile endpoint](https://developers.arcgis.com/rest/services-reference/image-tile.htm)
- [Export Image endoint](https://developers.arcgis.com/rest/services-reference/export-image.htm)
- [Export Map (image) endpoint](https://developers.arcgis.com/rest/services-reference/export-map.htm)
Additionally, the package provides
- quick access to a number of codes that identify Prague in various administrative or statistical registers.
- a function for downloading official Prague admin geodata (admin boundaries etc.)
- square and hex tiles for equal-area plotting
- a grid object suitable for use in the `geofacet::facet_geo()` function.
- basic demographic data about Prague districts
## Credit, inspiration and extensibility
The approach draws heavily on code provided by @[yutannihilation](https://github.com/yutannihilation) in her [blog post](https://yutani.rbind.io/post/2018-06-09-plot-osm-tiles/) on using OpenStreetMap tiles in 📦 `ggplot2`.
The approach should be generalisable to other ArcGIS-driven servers with the same REST API, though the package as it now is assumes a projected CRS measured in meters, specifically the Krovak CRS (EPSG 5514).
## Usage
```{r setup}
library(pragr)
library(dplyr)
library(sf)
library(ggplot2)
```
```{r load-data}
praha1 <- CzechData::load_RUIAN_settlement(prg_kod, "MOMC_P", WGS84 = F) %>%
filter(nazev == 'Praha 1')
```
Note that the possible values of the `tile_service` and `image_service` parameters can be found in `prg_endpoints`.
```{r example-tiles}
ggplot() +
prg_tile(data = praha1, zoom = 10, alpha = 1, buffer = 200,
tile_service = 'orto') +
geom_sf(data = praha1, colour = alpha("red", 0.6), fill = NA, shape = "dotted") +
theme_void()
```
The `layer` parameter can take values that you can find by inspecting the given image service (see note on sources below).
```{r example-base}
ggplot() +
prg_basemap(data = praha1, alpha = 1, buffer = 200, width = 1000,
image_service = 'cisarske_otisky_1840_velke', layer = 1) +
geom_sf(data = praha1, colour = alpha("red", 0.6), fill = NA, shape = "dotted") +
theme_void()
```
## What's in a name?
The name of the package refers to [Karel Prager](https://en.wikipedia.org/wiki/Karel_Prager), a renowned Czech modernist architect. Among other things, he designed - and for a long time worked in - the office buildings in which the [Institute for Planning and Development](https://iprpraha.cz), Prague's public urban planning body, is housed today.
The institute's excellent data team develops and maintains the data and software infrastructure for Prague's geographical data on which this package - and much of Prague's planning, government and business - relies.
Prag is of course how the city was once called by its many German-speaking inhabitants.
## Data sources:
Most map/image services are accessible via <http://www.geoportalpraha.cz/cs/clanek/22/mapove-sluzby>
A more technical route to lists of services is via
- <https://tiles.arcgis.com/tiles/SBTXIEUGWbqzUecw/arcgis/rest/services> for all tile services, including the in-preparation Metropolitan Plan
- <http://gs-pub.iprpraha.cz/arcgis/rest/services/> for most tile, image as well as feature servers
- <https://gs.iprpraha.cz/arcgis/rest/services/> for undocumented services, including the Atlas 5000 map collection which contains data from the 2016 ÚAP (Core Spatial Analytics) report for Prague, in the [`/uap/` collection](https://gs.iprpraha.cz/arcgis/rest/services/uap) The [`/urk/` collection](https://gs.iprpraha.cz/arcgis/rest/services/urk) contains some interesting data (incl. construction limits ([stavební uzávěry](https://gs.iprpraha.cz/arcgis/rest/services/urk/StavebniUzavery/MapServer)) or the spread of the build-up area over time ([vývoj Prahy](https://gs.iprpraha.cz/arcgis/rest/services/urk/vyvoj_prahy/MapServer))).
Many of these services can be used in WMS mode, i.e. as tiles for `leaflet` maps, or as feature layers for webmaps - see the [web article](/articles/web.html) for an example.
There has recently been a migration from the "mpp.*" servers to the "gs[-pub]*" servers; see <http://app.iprpraha.cz/apl/app/service_viewer/> for the translation. Some services still run on <http://mpp.iprpraha.cz/arcgis/rest/services> but presumably these will go away at some point. For now, this is the only place where the full current Spatial plan lives (<http://mpp.iprpraha.cz/arcgis/rest/services/PUP>).
For some of the services, shortcut notation is implemented for use in the tile/basemap functions. See `prg_endpoints`. **Not all endpoint metadata in `prg_endoints` has been updated to reflect the new URLs.**
## Note on geodata about Prague
There will be a [vignette](articles/data-sources.html) or `vignette("data-sources", package = "pragr")`.
# See also:
- [CzechData](https://jancaha.github.io/CzechData)
- [RCzechia](https://github.com/jlacko/RCzechia)
- [czso](https://github.com/petrbouchal/czso)
- [GiscoR](https://dieghernan.github.io/giscoR/)
## Acknowledgments
- Most importantly, IPR Praha for providing the open data!
- The approach draws heavily on code provided by @[yutannihilation](https://github.com/yutannihilation) in her [blog post]
- logo designed using the 📦 bunny by @[dmi3kno](https://github.com/dmi3kno) following his [blog post]([https://www.ddrive.no/post/making-hex-and-twittercard-with-bunny-and-magick/])
- font in logo is Trivia Serif by [František Štorm](https://stormtype.com)
## Code of Conduct
Please note that the pragr project is released with a [Contributor Code of Conduct](https://petrbouchal.github.io/pragr/CODE_OF_CONDUCT.html). By contributing to this project, you agree to abide by its terms.