Code Monkey home page Code Monkey logo

rczechia's Introduction

RCzechia

R-CMD-check CRAN CRAN-checks Codecov test coverage Downloads-weekly Downloads-total DOI DOI

This project downloads a set of shapefiles relevant to the Czech Republic. It was inspired by the popular tigris package for US datasets.

Kraje České republiky

For examples of RCzechia in action please see the package vignette:

The administrative area polygons are based on the RÚIAN register; the natural objects were based originally on ArcČR 500 by ARCDATA and later moved to Data200 by ČÚZK.

The shapefiles are by necessity larger than the limits of a CRAN package size allow. The data are therefore stored remotely (on Amazon Cloud / AWS S3) and downloaded as required. As consequence a working internet connection is required to fully use the package.

For the most commonly used shapes (republika, kraje and okresy) an optional low resolution version is also included. To access it specify the value of resolution parameter as "low" (default is "high").

Access to the external files is logged, from time to time I check the logs (mainly to better understand my bandwidth charges).

A note to Czech users

Tohle je "oficiální", a tedy anglické, readme. Českou verzi naleznete na http://www.jla-data.net/cze/package-rczechia/

Installation

The package is on CRAN (as of March 2018) so to get a stable version simply run:

install.packages("RCzechia")

You can also get the latest development version by running remotes::install_github("jlacko/RCzechia"). The main branch should be always reasonably stable, but I do not suggest cloning of development branches unless you know what you are doing - these are where the raw action is happening, red in tooth and claw.

The following spatial objects are included:

administrative:

  • republika: borders of the Czech Republic as a polygon
  • kraje: 14 regions of the Czech Republic & Prague
  • okresy: 76 districts (LAU1 areas) of the Czech Republic + Prague (legally not a district but the capital)
  • orp_polygony 205 municipalities with extended powers (in Czech: obce s rozšířenou působností) + Prague (legally not a city but the capital)
  • obce_polygony: 6.258 municipalities of the Czech Republic
  • obce_body the same as obce_polygony, but centroids instead of polygons
  • casti: primarily 57 city parts of Prague, but also of other cities with defined parts (Brno, Ostrava and other)
  • katastry: 13.076 cadastral areas (katastrální území) of the Czech Republic
  • senat_obvody: 81 senate districts (volební obvody senátu)
  • volebni_okrsky: 14.733 general election districts (volební okrsky)
  • zip_codes: 2.671 ZIP code areas (poštovní směrovací čísla / PSČ)
  • historie: historical administrative areas + census data, notably including data on German speaking residents before the second world war

natural:

  • reky: streams and rivers
  • plochy: stillwaters (lakes and ponds).
  • silnice: roads (highways, speedways etc.)
  • zeleznice: railroads
  • chr_uzemi: protected natural areas (chráněná území)
  • lesy: woodland areas (more than 30 ha in area)
  • KFME_grid: KFME grid cells (faunistické čtverce)
  • vyskopis: terrain of the Czech republic as a {terra} package raster object
  • geomorfo: geomorphological division of the Czech Republic

All objects are implemented as functions returning data frames, so must be followed by brackets (i.e. hranice <- republika()).

In addition a number of utility functions is provided:

  • geocode: interfaces to geocoding API of ČÚZK.
  • revgeo: interfaces to reverse geocoding API of ČÚZK.

Call for Action

The project is actively maintained, and ideas & suggestions to improve the package are greatly welcome. Should you feel more at ease with old fashioned email than the GitHub ticketing system - do drop me a line.

But raising an issue is preferable, as I am human and I forget; GitHub does not suffer from such a failing, and will keep on reminding me till the sun and moon are darkened, and the stars no longer shine.

More detailed information can be found in the CONTRIBUTING document.

Code of Conduct

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

rczechia's People

Contributors

jlacko avatar krlmlr avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

rczechia's Issues

Community guidelines: JOSS Review

You do say people can contribute, but I think it would be good to have a CONTRIBUTING.md file, similar to this:

https://github.com/kadyb/rgugik/blob/master/CONTRIBUTING.md

And a Code of Conduct. These integrate with GitHub's issues etc.

I think it would also be worth mentioning somewhere about adding new data / updating existing data. At the minimum, "If you would like to contribute new data to this library, or notice data that needs updating, please open an issue" or similar.

openjournals/joss-reviews#5082

digest individual objects

Once the Data50 is in principle understood it will be necessary to prepare updated versions of:

  • reky
  • lesy
  • plochy
  • zeleznice
  • silnice
  • vyskopis
  • chr_uzemi / based on AOPK data, but 2020-09 is not exactly fresh data

Version v0.1.4 with seperate sp files

I don't know if it's just me, but v0.1.4 has only a couple of objects (LAU 1-2). I tried subseting the SpatialPolygonsDf to only include NUTS 3 region but I couldn't manage. After going to v1.5.0, files are sf. Would it be possible to have a version with kraje only in sp?

encoding issue of NAZ_STAT in RCzechia::republika()

The name of the country in the low res polygon seems to be encoded in rozsypaný čaj.

> RCzechia::republika()$NAZ_STAT
RCzechia: using temporary local dataset.
[1] "Česká republika"

> RCzechia::republika("low")$NAZ_STAT
[1] "\xc8esk\xe1 republika"

Install dev version: JOSS Review

I'm not sure if this is a me problem or a code problem.

When I try to install the dev version:

remotes::install_github("jlacko/RCzechia")

I get this message:

Downloading GitHub repo jlacko/RCzechia@HEAD
then it downloads a bit.
Then:
Error in utils::download.file(url, path, method = method, quiet = quiet, : download from 'https://api.github.com/repos/jlacko/RCzechia/tarball/HEAD' failed

Anyone else have this issue?

openjournals/joss-reviews#5082

Části

A solution to the části problem (not a recognized RUIAN polygon layer) should be found, e.g. building up from ZSJ (which is a legit RUIAN polygon layer). Possibly Momc? Good ol' ArcČR 500 is getting long in the tooth...

Pre-computed Vignette

Replace current - dynamically generated - vignette with a precomplied, static, one in order to prevent the wrath of the Gods of CRAN.

This is still not complying with the policy.

This is a *final* reminder: Please correct before 2021-11-29 to retain your package on CRAN.

-- 
Brian D. Ripley,                  [email protected]
Emeritus Professor of Applied Statistics, University of Oxford 

R 3.4.0

Unable to install with R version 3.4.0.

Add download links to readme

Thanks a lot for your work! Projects like this are the rescue for many :)

It would be great if you could add the hyperlinks for the datasets directly in the readme so folks like me who are looking for the data but don't have R installed can access them too (e.g. https://rczechia.jla-data.net/zip-high-2021-02.rds etc.).

As a side note: by June 9 2024 all EU states will be forced to open many public data sets, like administrative geometries and more!

image

Data download times: JOSS Review

A small comment. When pulling in various data sets, some of them are bigger than others. Is it possible to add some type of progress measure, particularly for the bigger data sets?

e.g. when I ran relief <- vyskopis("actual", cropped = TRUE)

it said RCzechia: downloading remote dataset.

and then just sat there until it had finished. Fortunately it didn't take too long, but if a new user didn't know this they might think something had gone wrong.

openjournals/joss-reviews#5082

Problems with the development version of tibble

I'm in the process of preparing the release for tibble 2.0.0. The RCzechia package imports or suggests tibble.

I'm seeing errors when testing your package with the dev version of tibble. Unfortunately I can't relate the errors I see to changes we've made to tibble. Also, a first pass of checking all downstream dependencies did not catch this problem.

Could you please install the development version of tibble and run the tests in your package, so that we get a better understanding for the reason of the new test failures?

See https://www.tidyverse.org/articles/2018/11/tibble-2.0.0-pre-announce/ for details on the upcoming release.

Historical shapefiles

Hi,

thanks for your package.
I have a feature request. Some objects such as senatni_obvody, volebni_okrsky and also obce change their boundaries in time. Senate districts due to redistricting, municipalities due to divisions/mergers.
This may cause trouble/inaccuracies when joining a historical data (e.g. electoral results from past elections) and current version of these shapefiles or when doing an analysis of electoral districts over time.
Therefore, it would be great if historical versions of these object were available. (Although I am not sure if ČÚZK or any other entity has such data available).

Reconsider return value of `geocode()` when no match

When using geocode() via {purrr}, working with the no-match values can get difficult. It might be more straightforward to always return a tibble, of length zero if no match is returned by the API. This is the approach taken by {tidygeocoder} and I find it a bit easier to use.

Don't pass NA to geocoding API

If passed NA, geocode() returns a whole lot of places containing "na". I suppose it should return the same value as when the geocoder cannot resolve the address.

RCzechia::geocode(NA)
#> Simple feature collection with 15 features and 3 fields
#> Attribute-geometry relationship: 3 constant, 0 aggregate, 0 identity
#> geometry type:  POINT
#> dimension:      XY
#> bbox:           xmin: 14.03854 ymin: 49.19021 xmax: 17.58948 ymax: 50.73654
#> geographic CRS: WGS 84
#> First 10 features:
#>    target                       typ             address
#> 1      NA                     Okres              Náchod
#> 2      NA                     Okres      Ústí nad Labem
#> 3      NA                     Okres     Ústí nad Orlicí
#> 4      NA                     Okres    Žďár nad Sázavou
#> 5      NA                     Okres Rychnov nad Kněžnou
#> 6      NA                     Okres  Jablonec nad Nisou
#> 7      NA ObecSRozsirenouPusobnosti  Náměšť nad Oslavou
#> 8      NA ObecSRozsirenouPusobnosti              Náchod
#> 9      NA ObecSRozsirenouPusobnosti     Týn nad Vltavou
#> 10     NA ObecSRozsirenouPusobnosti      Lysá nad Labem
#>                     geometry
#> 1  POINT (16.14594 50.47397)
#> 2  POINT (14.03854 50.68511)
#> 3  POINT (16.47523 49.99403)
#> 4   POINT (16.0744 49.49913)
#> 5  POINT (16.26267 50.20638)
#> 6  POINT (15.25925 50.73654)
#> 7  POINT (16.16105 49.19021)
#> 8  POINT (16.14594 50.46277)
#> 9   POINT (14.4418 49.21263)
#> 10  POINT (14.8514 50.19134)

Created on 2021-03-02 by the reprex package (v0.3.0)

upcoming sf / s2 breaks RCzechia

While rev dep checking, I see this:

Package: RCzechia
Check: tests
Old result: OK
    Running ‘testthat.R’
New result: ERROR
    Running ‘testthat.R’
  Running the tests in ‘tests/testthat.R’ failed.
  Last 13 lines of output:
    Loading required package: sf
    Linking to GEOS 3.9.0, GDAL 3.2.1, PROJ 7.2.1
    ══ Skipped tests ═══════════════════════════════════════════════════════════════
    • On CRAN (8)
    
    ══ Failed tests ════════════════════════════════════════════════════════════════
    ── Failure (test-1-data-structures.R:238:3): městské části ─────────────────────
    all(st_is_valid(casti())) is not TRUE
    
    `actual`:   FALSE
    `expected`: TRUE 
    
    [ FAIL 1 | WARN 0 | SKIP 8 | PASS 191 ]
    Error: Test failures
    Execution halted

indicating that you may have geometries that are not valid on the sphere. st_make_valid may help (for testing, use sf from github, branch sf_1_0 and s2 1.0.5 from CRAN). Let me know if we can help; also do visit r-spatial/sf#1649

URL encoding of czech characters in geocode() function

Hello,

I would suggest different way of URL encoding for geocode() function to deal with special czech characters - recode adress to ASCII. Current approach seems to fail a lot as URLencode function (and others in R) works differently compared to Chrome/Edge url encoding... See example below.

Example adress:
address <- c("Dr. Stejskala 426/15, České Budějovice 1, České Budějovice")

Suggestion:
cil <- gsub(" ", "+", address) %>%
iconv(to = 'ASCII//TRANSLIT') %>% # get rid of funny Czech characters
utils::URLencode()

Current approach:
cil <- gsub(" ", "+", address) %>% # spaces to pluses (for url use)
utils::URLencode() # get rid of funny Czech characters

Generated URL:
By chrome (after pasing original adress):
http://ags.cuzk.cz/arcgis/rest/services/RUIAN/Vyhledavaci_sluzba_nad_daty_RUIAN/MapServer/exts/GeocodeSOE/find?text=Dr.%20Stejskala%20426/15,%20%C4%8Cesk%C3%A9%20Bud%C4%9Bjovice%201,%20%C4%8Cesk%C3%A9%20Bud%C4%9Bjovice&outSR=4326&maxLocations50=&f=pjson
Suggestion:
http://ags.cuzk.cz/arcgis/rest/services/RUIAN/Vyhledavaci_sluzba_nad_daty_RUIAN/MapServer/exts/GeocodeSOE/find?text=Dr.+Stejskala+426/15,+Ceske+Budejovice+1,+Ceske+Budejovice&outSR=4326&maxLocations50=&f=pjson
Current approach:
http://ags.cuzk.cz/arcgis/rest/services/RUIAN/Vyhledavaci_sluzba_nad_daty_RUIAN/MapServer/exts/GeocodeSOE/find?text=Dr.+Stejskala+426/15,+%C8esk%E9+Bud%ECjovice+1,+%C8esk%E9+Bud%ECjovice&outSR=4326&maxLocations50=&f=pjson

Otherwise, thanks for the great package!

Data returned by `chr_uzemi()` seems to be out of date

Compare to output from {CzechData} i.e. direct from CUZK datasets

chu_rcz <- RCzechia::chr_uzemi() #preprocessed data
chu_cd <- CzechData::load_Data50("ChraneneUzemi") # direct from CUZK
setdiff(chu_cd$NAZEV, chu_rcz$NAZEV)

One is an obsolete name, another is a newly created protected area (2016).

I have not checked but suspect this may also be the case for other datasets served by {RCzechia}?

Data origin: JOSS Review

Just adding things as I go through!

You have a lot of data in here, do you have a comprehensive list of the data, it's source and related information? I think this would we really useful. There is a nice summary in the readme, but you only mention the source for the admin areas.

A table, with name, source, last updated and a link to the source would be really nice. This would a) help people understand where the data come from and b) highlight the usefulness of the package more.

Thanks :-)

openjournals/joss-reviews#5082

test failure on terra::expanse() output change

sometime in April the structure of terra::expanse() output chaged to a data frame of 2 columns: area (as before) and layer

tis necessary to update unit tests to compare terra::expanse()$area (with the column specification spelled out)

st_make_valid to move from lwgeom to sf

Please change your package to import from sf in order to avoid the CRAN check ERRORs e.g.

Package: RCzechia
Check: tests
New result: ERROR
    Running ‘testthat.R’ [13s/16s]
  Running the tests in ‘tests/testthat.R’ failed.
  Complete output:
    > library(testthat)
    > 
    > test_check("RCzechia")
    Loading required package: RCzechia
    Loading required package: sf
    Linking to GEOS 3.8.1, GDAL 3.0.4, PROJ 7.0.0
    ── 1. Error: (unknown) (@test-2-code.R#20)  ────────────────────────────────────
    'st_make_valid' is not an exported object from 'namespace:lwgeom'
    Backtrace:
      1. RCzechia::casti()
      9. RCzechia::union_sf(., "NAZ_OBEC")
      3. data[vec, ]
     10. lwgeom::st_make_valid(.)
     18. base::getExportedValue(pkg, name)

and resubmit to CRAN.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.