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 https://petrbouchal.github.io/pragr/dev.

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:

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):

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 in his blog post 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

library(pragr)
library(dplyr)
#> 
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#> 
#>     filter, lag
#> The following objects are masked from 'package:base':
#> 
#>     intersect, setdiff, setequal, union
library(sf)
#> Linking to GEOS 3.8.1, GDAL 3.1.1, PROJ 6.3.1
library(ggplot2)
praha1 <- CzechData::load_RUIAN_settlement(prg_kod, "MOMC_P", WGS84 = F) %>% 
  filter(nazev == 'Praha 1')
#> ✓ Data downloaded and unpacked.

Note that the possible values of the tile_service and image_service parameters can be found in prg_endpoints.

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).

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, 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, 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

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 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 or vignette("data-sources", package = "pragr").

See also:

Acknowledgments

  • Most importantly, IPR Praha for providing the open data!
  • The approach draws heavily on code provided by @yutannihilation in her blogpost
  • logo designed using the 📦 bunny by @dmi3kno following his blog post
  • font in logo is Trivia Serif by František Štorm

Code of Conduct

Please note that the pragr project is released with a Contributor Code of Conduct. By contributing to this project, you agree to abide by its terms.