inbo / n2khab

R package with preprocessing functions and standard reference data for Flemish Natura 2000 (N2K) habitat (HAB) analyses
https://inbo.github.io/n2khab
GNU General Public License v3.0
2 stars 1 forks source link

New function read_habitatquarries() #83

Closed florisvdh closed 4 years ago

florisvdh commented 4 years ago

Returns the raw data source habitatquarries as an sf polygon layer in the Belgian Lambert 72 CRS (EPSG-code 31370). Optionally, associated bibliographic references can be returned (arguments references or bibtex).

Fixes #81

ElsLommelen commented 4 years ago

The function works fine and it is well documented, good work!

Just a small remark: I tried running the function from the prospective of a user that has its own folder names different from the typical n2khab structure. In this case some small improvements are possible, I think. Certainly a solution to make the second item below return the sf object, would make life easier in my opinion.

# this should not work without n2khab_data folder,
# but the error message could be more informative:
n2khab::read_habitatquarries()
#> Error: assert_that: length of assertion is not 1

# It would be very nice if this would work (e.g. when using package rprojroot),
# but unfortunately it doesn't
n2khab::read_habitatquarries(file = "c:/caves/habitatquarries.gpkg")
#> Error: assert_that: length of assertion is not 1

# Also when using the argument path, there is no possibility to run the function:
n2khab::read_habitatquarries(path = "c:/caves")
#> Error: Path 'c:/caves/10_raw/habitatquarries/habitatquarries.gpkg' does not exist
n2khab::read_habitatquarries(path = "c:/caves/habitatquarries.gpkg")
#> Error: Path 'c:/caves/habitatquarries.gpkg/10_raw/habitatquarries/habitatquarries.gpkg' does not exist

# It only works like this, so I need to use 2 arguments:
n2khab::read_habitatquarries(path = "c:/caves", file = "habitatquarries.gpkg")
#> Simple feature collection with 33 features and 6 fields
#> geometry type:  POLYGON
#> dimension:      XY
#> bbox:           xmin: 221427.3 ymin: 160393.5 xmax: 243236.8 ymax: 168965.1
#> projected CRS:  Belge 1972 / Belgian Lambert 72
#> Warning: `...` is not empty.
#> 
#> We detected these problematic arguments:
#> * `needs_dots`
#> 
#> These dots only exist to allow future extensions and should be empty.
#> Did you misspecify an argument?
#> # A tibble: 33 x 7
#>                         geom polygon_id unit_id name  code_orig type 
#>                <POLYGON [m]>      <int>   <int> <chr> <chr>     <fct>
#>  1 ((236535.6 164740.9, 236~          1       1 Kuil~ gh        <NA> 
#>  2 ((236548.1 164513.4, 236~          2       1 Kuil~ gh        <NA> 
#>  3 ((236590.6 164320.9, 236~          3       1 Kuil~ gh        <NA> 
#>  4 ((241632.5 167303.6, 241~          4       2 Aver~ gh        <NA> 
#>  5 ((241197.8 167174, 24124~          5       2 Aver~ gh        <NA> 
#>  6 ((241645.5 167021.6, 241~          6       2 Aver~ 8310      8310 
#>  7 ((242815.9 167720.6, 242~          7       3 Caes~ 8310      8310 
#>  8 ((242917.5 167454.6, 242~          8       3 Caes~ <NA>      <NA> 
#>  9 ((242989.4 167220.6, 242~          9       4 Tern~ 8310      8310 
#> 10 ((242973.5 167088.4, 242~         10       4 Tern~ <NA>      <NA> 
#> # ... with 23 more rows, and 1 more variable: extra_reference <fct>

Created on 2020-09-30 by the reprex package (v0.3.0)

florisvdh commented 4 years ago

Thanks for the fine suggestion @ElsLommelen :+1: , I will have a look into this. It will need a change in most functions but I agree this would be an improvement. Created issue #86 for this.

florisvdh commented 4 years ago

@ElsLommelen can you have another look at read_habitatquarries()? Its path argument has been dropped. The file argument takes an absolute or a relative path, while its default remains the recommended approach.

florisvdh commented 4 years ago

Thanks for verifying @ElsLommelen ! BTW it appears you'll need to update the tibble package in order to get rid of the odd warning about '...'. (issue 798 of https://github.com/tidyverse/tibble/issues)