Skip to content
Permalink
Browse files

v1.4.2 submitted to CRAN

  • Loading branch information...
jlacko committed Aug 20, 2019
1 parent 960374e commit 7d24f887e451fad50732128129a5ef751ac21861
Showing with 47 additions and 43 deletions.
  1. +3 −2 DESCRIPTION
  2. +3 −1 NEWS.md
  3. +1 −0 R/geocode.R
  4. +9 −7 README.md
  5. +6 −5 cran-comments.md
  6. +9 −9 tests/testthat/test-1-data-structures.R
  7. +16 −19 vignettes/vignette.Rmd
@@ -2,7 +2,7 @@ Package: RCzechia
Type: Package
Title: Spatial Objects of the Czech Republic
Version: 1.4.2
Date: 2019-08-XX
Date: 2019-08-20
Author: Jindra Lacko
Maintainer: Jindra Lacko <jindra.lacko@gmail.com>
Description: Administrative regions and other spatial objects of the Czech Republic.
@@ -30,6 +30,7 @@ Suggests:
knitr,
testthat,
roxygen2,
devtools
devtools,
rmarkdown
RoxygenNote: 6.1.1
VignetteBuilder: knitr
@@ -1,5 +1,7 @@
## version 1.4.2
- KFME grid cells (faunistické čtverce) object added
- KFME grid cells (faunistické čtverce) object added

- minor optimization of geocode() and tests

## version 1.4.1

@@ -123,6 +123,7 @@ geocode <- function(address, crs = 4326) {
colnames(result) <- c("target", "typ", "address", "x", "y") # get the names right

result <- sf::st_as_sf(result, coords = c("x", "y")) %>%
sf::st_set_agr("constant") %>% # to avoid those pesky warnings
sf::st_set_crs(crs) # set CRS as required
} else {
# if no, then report a failure
@@ -6,16 +6,18 @@ This project downloads a set of shapefiles relevant to the Czech Republic. It wa
</p>

For examples of RCzechia in action please see the package vignette:
* [Visualizing Czech Population](https://cran.r-project.org/web/packages/RCzechia/vignettes/vignette.html#visualizing-czech-population)
* [Geocoding Locations & Drawing them on a Map](https://cran.r-project.org/web/packages/RCzechia/vignettes/vignette.html#geocoding-locations-drawing-them-on-a-map)
* [Unemployment in the Czech Republic - a Chloropleth](https://cran.r-project.org/web/packages/RCzechia/vignettes/vignette.html#unemployment-in-the-czech-republic---a-chloropleth)
* [Distance Between Prague and Brno](https://cran.r-project.org/web/packages/RCzechia/vignettes/vignette.html#distance-between-prague-and-brno)
* [Geographical Center of the City of Brno](https://cran.r-project.org/web/packages/RCzechia/vignettes/vignette.html#geographical-center-of-the-city-of-brno)
* [Interactive Map](https://cran.r-project.org/web/packages/RCzechia/vignettes/vignette.html#interactive-map)
* [Dissolving sf Polygons](https://cran.r-project.org/web/packages/RCzechia/vignettes/vignette.html#dissolving-sf-polygons)

* [Visualizing Czech Population](https://CRAN.R-project.org/package=RCzechia/vignettes/vignette.html#visualizing-czech-population)
* [Geocoding Locations & Drawing them on a Map](https://CRAN.R-project.org/package=RCzechia/vignettes/vignette.html#geocoding-locations-drawing-them-on-a-map)
* [Unemployment in the Czech Republic - a Chloropleth](https://CRAN.R-project.org/package=RCzechia/vignettes/vignette.html#unemployment-in-the-czech-republic---a-chloropleth)
* [Distance Between Prague and Brno](https://CRAN.R-project.org/package=RCzechia/vignettes/vignette.html#distance-between-prague-and-brno)
* [Geographical Center of the City of Brno](https://CRAN.R-project.org/package=RCzechia/vignettes/vignette.html#geographical-center-of-the-city-of-brno)
* [Interactive Map](https://CRAN.R-project.org/package=RCzechia/vignettes/vignette.html#interactive-map)
* [Dissolving sf Polygons](https://CRAN.R-project.org/package=RCzechia/vignettes/vignette.html#dissolving-sf-polygons)


The shapefiles are based on ArcČR 500 (https://www.arcdata.cz/produkty/geograficka-data/arccr-500) with some adjustments:

* the encoding was adjusted to handle Czech accents correctly in R
* coordinate reference system was changed from a local CRS ([S-JSTK](https://epsg.io/5513-1623)) to global WGS84 ([EPSG:4326](https://epsg.io/4326))
* demographic data were removed, as they get out of date rather fast and are very easy to re-attach using the `sf` and `tidyverse` workflow
@@ -1,9 +1,9 @@
## Test environments
* ubuntu 18.04.2 LTS, R 3.6.0 (desktop)
* ubuntu 16.04.6 LTS, R 3.6.0 (Travis)
* ubuntu 18.04.3 LTS, R 3.6.1 (2019-07-05) (desktop)
* ubuntu 16.04.6 LTS, R 3.6.1 (2017-01-27) (Travis)
* macOS 10.11 El Capitan, R-release (rhub)
* Windows R version 3.6.0 (2019-04-26) (win_builder)
* Windows R Under development (unstable) (2019-06-27 r76748)
* Windows R version 3.6.1 (2019-07-05) (win_builder)
* Windows R Under development (unstable) (2019-08-19 r77043)

## R CMD check results
Status: OK
@@ -12,4 +12,5 @@ There were no NOTES, ERRORs or WARNINGs.
## Downstream dependencies
There are no downstream dependencies.


## CRAN checks
There is an error in r-devel-linux-x86_64-debian-clang that I am unable to reproduce; it is most likely related to character encoding issues on server side (the string in question is UTF-8 and works everywhere else).
@@ -241,17 +241,17 @@ context("faunistické čtverce")

expect_error(KFME_grid("bflm")) # neznámé rozlišení - očekávám high(default) / low

telc <- geocode("Telč") %>%
filter(typ == "Obec") %>% # bod Telč
st_set_agr("constant")
telc <- geocode("Telč") %>% # známý bod Telč
filter(typ == "Obec")

hrcava <- geocode("Hrčava") %>%
filter(typ == "Obec") %>% # bod Hrčava
st_set_agr("constant")

cernousy <- geocode("Černousy") %>%
filter(typ == "Obec") %>% # bod Hrčava
st_set_agr("constant")
hrcava <- geocode("Hrčava") %>% # známý bod Hrčava
filter(typ == "Obec")


cernousy <- geocode("Černousy") %>% # známý bod Černousy
filter(typ == "Obec")


expect_equal(sf::st_intersection(KFME_grid("low"), telc)$ctverec, 6858) # bod Telč je ve velkém čtverci 6858
expect_equal(sf::st_intersection(KFME_grid("high"), telc)$ctverec, "6858b") # bod Telč je v malém čtverci 6858b
@@ -67,16 +67,12 @@ To get the geocoded data frame function `RCzechia::geocode()` is used.

```{r geocode, echo = T, eval = T, message = F, fig.align="center", dpi = 100, out.width = "100%"}
library(RCzechia)
library(dplyr)
library(tmap)
library(sf)
borders <- RCzechia::republika("low")
rivers <- RCzechia::reky()
rivers <- rivers %>%
filter(Major == T)
rivers <- subset(RCzechia::reky(), Major == T)
mista <- data.frame(misto = c("Kramářova vila",
"Arcibiskupské zahrady v Kromeříži",
@@ -146,11 +142,9 @@ library(units)
obce <- RCzechia::obce_polygony()
praha <- obce %>%
filter(NAZ_OBEC == "Praha")
praha <- subset(obce, NAZ_OBEC == "Praha")
brno <- obce %>%
filter(NAZ_OBEC == "Brno")
brno <- subset(obce, NAZ_OBEC == "Brno")
vzdalenost <- sf::st_distance(praha, brno) %>%
units::set_units("kilometers") # easier to interpret than meters, miles or decimal degrees..
@@ -171,8 +165,7 @@ library(RCzechia)
library(tmap)
library(sf)
brno <- RCzechia::obce_polygony() %>%
filter(NAZ_OBEC == "Brno")
brno <- subset(RCzechia::obce_polygony(), NAZ_OBEC == "Brno")
pupek_brna <- brno %>%
st_transform(5514) %>% # planar CRS (eastings & northings)
@@ -262,9 +255,9 @@ plot(poly, key.pos = 1)

## KFME Grid Cells

The Kartierung der Flora Mitteleuropas (KFME) grid is a commonly used technique in biogeography of the Central Europe. It uses a grid of 10 × 6 arc-minutes, with cells numbered from north to south and west to east.
The Kartierung der Flora Mitteleuropas (KFME) grid is a commonly used technique in biogeography of the Central Europe. It uses a grid of 10×6 arc-minutes (in Central European lattitudes this translates to near squares), with cells numbered from north to south and west to east.

A selection of the grid cells appropriate for faunistical mapping of the Czech Republic is available in the RCzechia package.
A selection of the grid cells relevant for faunistical mapping of the Czech Republic is available in the RCzechia package.

This example covers a frequent use case:

@@ -279,7 +272,7 @@ library(ggplot2)
library(dplyr)
library(sf)
obec <- "Vlkov pod Oškobrhem" # a Czech location
obec <- "Humpolec" # a Czech location
# geolocate centroid of a place
place <- RCzechia::geocode(obec) %>%
@@ -290,14 +283,18 @@ ctverec_id <- sf::st_intersection(RCzechia::KFME_grid(), place)$ctverec
print(paste0("Location found in grid cell number ", ctverec_id, "."))
# a single KFME square to be highlighted
highlighted_cell <- KFME_grid() %>%
filter(ctverec == ctverec_id)
# a summary plot
ggplot() +
geom_sf(data = RCzechia::republika(), size = .85) + # Czech borders
geom_sf(data = filter(KFME_grid(), ctverec == ctverec_id), # a specific KFME cell
fill = "limegreen", alpha = .5) +
geom_sf(data = RCzechia::KFME_grid(), size = .33,
color = "gray80", fill = NA) + # all KFME grid cells
geom_sf(data = place, color = "red", pch = 4) + # actual location
geom_sf(data = highlighted_cell, # a specific KFME cell ...
fill = "limegreen", alpha = .5) + # ... highlighted in lime green
geom_sf(data = KFME_grid(), size = .33, # all KFME grid cells, thin
color = "gray80", fill = NA) + # in gray and without fill
geom_sf(data = place, color = "red", pch = 4) + # X marks the spot!
ggtitle(paste("Location", obec, "in grid cell number", ctverec_id))
```

0 comments on commit 7d24f88

Please sign in to comment.
You can’t perform that action at this time.