Skip to content

Commit

Permalink
version 0.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
kadyb authored and cran-robot committed Feb 27, 2023
1 parent 30e40b4 commit e2e55ea
Show file tree
Hide file tree
Showing 27 changed files with 1,959 additions and 1,973 deletions.
10 changes: 5 additions & 5 deletions DESCRIPTION
@@ -1,7 +1,7 @@
Package: rgugik
Type: Package
Title: Search and Retrieve Spatial Data from 'GUGiK'
Version: 0.3.3
Version: 0.4.0
Authors@R: c(person(given = "Krzysztof",
family = "Dyba",
role = c("aut", "cre"),
Expand Down Expand Up @@ -31,20 +31,20 @@ Description: Automatic open data acquisition from resources of Polish Head Offic
function.
License: MIT + file LICENSE
Depends: R (>= 3.5)
Imports: sf, jsonlite, openssl
Imports: sf, jsonlite
Suggests: curl, knitr, rmarkdown, testthat, stars, terra
Encoding: UTF-8
LazyData: true
RoxygenNote: 7.2.1
RoxygenNote: 7.2.3
URL: https://kadyb.github.io/rgugik/, https://github.com/kadyb/rgugik
BugReports: https://github.com/kadyb/rgugik/issues
VignetteBuilder: knitr
NeedsCompilation: no
Packaged: 2022-08-29 20:47:42 UTC; Krzysztof
Packaged: 2023-02-27 10:27:46 UTC; krzdyb
Author: Krzysztof Dyba [aut, cre] (<https://orcid.org/0000-0002-8614-3816>),
Jakub Nowosad [aut] (<https://orcid.org/0000-0002-1057-3721>),
Maciej Beręsewicz [ctb] (<https://orcid.org/0000-0002-8281-4301>),
GUGiK [ctb] (source of the data)
Maintainer: Krzysztof Dyba <adres7@gmail.com>
Repository: CRAN
Date/Publication: 2022-08-29 21:10:02 UTC
Date/Publication: 2023-02-27 11:12:30 UTC
51 changes: 26 additions & 25 deletions MD5
@@ -1,40 +1,41 @@
b51e2bcfcee7e8dd8438bbcfd1279e3b *DESCRIPTION
54a7ccfe047186c89f211a219c858566 *DESCRIPTION
41ac9f8e91d5e48aa2ec2d9f5669346e *LICENSE
aa7cc99303fdd454908fc12aa740c5f2 *NAMESPACE
3dae0797ef39ecb351191edc410b95a9 *R/DEM_request.R
f781e4fa0f09bf0c1192d3f9a115f2c6 *NEWS.md
d818c12f0fa53ee2796b000e12584df9 *R/DEM_request.R
40135b2fc35da79219362b8a97556d72 *R/borders_download.R
966b961553236b991270543fd7f248bf *R/borders_get.R
ac696e912898ce69a77bede065bc5aca *R/commune_names.R
febc226cbc0aa1a0e2730b7ce5370ec5 *R/county_names.R
a025a01f1d4be17fca97585fa8873d9b *R/emuia_download.R
10f0f94b3d98c0444ca1af3b30ff896d *R/geocodePL_get.R
831fa271300657d0634b28f683e1156a *R/geodb_download.R
82515ba251db7622a1339df277369129 *R/geocodePL_get.R
9138b7d687c6c139ca830d0d35e66f05 *R/geodb_download.R
906834ce5df21bccb00eec187eee9475 *R/geonames_download.R
f3f0f8d6d664cf6384722474a691913e *R/minmaxDTM_get.R
e1d0335c0ca601f2b4b930f887f0bdf9 *R/minmaxDTM_get.R
0671f44c36e59ed6a0382b6f877299b8 *R/models3D_download.R
8c0d56fbd70d5c7b4477462aa71fda37 *R/ortho_request.R
22d1c0b931f8fac9e77e6ade25753f8b *R/parcel_get.R
023155c4d5990c21ccc8285905163745 *R/pointDTM100_download.R
b3530de2fc33be7f7078ff05f647e616 *R/pointDTM_get.R
efdf8ab704801e45a58a1a92e4af8463 *R/ortho_request.R
5accc3ae508ed50a0731db4531b7347f *R/parcel_get.R
4c392b95c220369364856fd4b5be6420 *R/pointDTM100_download.R
d5528df4cb864914fd403fc3edadcbb6 *R/pointDTM_get.R
e0ef681901465d24f47f9139cb2c086a *R/rgugik-package.R
e5c88faadd7249fcbc89efafa539506b *R/tile_download.R
590cb9d6412480adf35d805f2088af3f *R/tile_download.R
11bcb7b750e263637afcf96943b38c82 *R/topodb_download.R
850cc6cc2d187c81531b6d4a06df0bfa *R/utils.R
72caaf014bd6913997583897d2ef227e *R/utils.R
615a5998ad097908e9c92c38612f8e13 *R/voivodeship_names.R
719b394ae95833f672e525442a453c37 *README.md
f70b4bb96ce62da6bedff28c0cfaa8d4 *build/vignette.rds
020c413a8ac33b6f8746acd25dbe04b9 *README.md
326f32335d7efac86182c73c30b92d08 *build/vignette.rds
0c35d4561e86d09d247d95e387ae10d9 *data/commune_names.rda
990bedce7bfbaf9a3c7070db26b1b579 *data/county_names.rda
55719acdb7ec1b964727ce2ed271e03d *data/voivodeship_names.rda
9f280194f7c4703af1678352e2795f63 *inst/CITATION
72b13c47571748e6781ae135f501f762 *inst/CITATION
2d97f091b0f84f81ac52f2e64bd24876 *inst/datasets/search_area.gpkg
0251195be0a121348027844389f9e182 *inst/doc/DEM.Rmd
bec615c2d801d9df15b244d85c625e38 *inst/doc/DEM.html
7c86464568c4a8ec865b72037abb2854 *inst/doc/DEM.html
2c7fdb29e5355fe2f9926b960a319fa6 *inst/doc/orthophotomap.Rmd
efe655f6ed3c98af26be3f93786c0fd6 *inst/doc/orthophotomap.html
05249790ddc98deccf83091829b631a4 *inst/doc/orthophotomap.html
98015b16b1ed4af5d0aab3a6bda56e9b *inst/doc/topodb.Rmd
3bda8a4de4b4dacee5946c959b889a37 *inst/doc/topodb.html
7673f056bb48db5e9dd09db2b47940a2 *man/DEM_request.Rd
8f532aa720cbd2366d54b8acecedd29d *inst/doc/topodb.html
7abc4fbba2e303c7be26a3d6c14ee4fb *man/DEM_request.Rd
2885bdb49a961c4fd2e9810c58d5b13d *man/borders_download.Rd
493c82ef126fda7fe16a8a9fde9d61fc *man/borders_get.Rd
49b257881cb68e2a59b45d8196f318aa *man/commune_names.Rd
Expand All @@ -48,27 +49,27 @@ e939859fdf30c96cdd0eef4bf238c444 *man/geocodePL_get.Rd
06a342d27623ec29acef4f9073f5dd99 *man/geonames_download.Rd
872de6f9a647189c1f64e32a36de1671 *man/minmaxDTM_get.Rd
155caf7edd1a97041a1d4c74cc2dd417 *man/models3D_download.Rd
e424e3cc58bd25a16eff1598d17b02b5 *man/ortho_request.Rd
1461fb4dbea9bb8747df86d43ea300d6 *man/ortho_request.Rd
825d86d214779f137847560318c4be61 *man/parcel_get.Rd
5cd9bc6aa9ca1f7a034b74ff2ede0686 *man/pointDTM100_download.Rd
f30e2895ae2b646822322d48a27f7c08 *man/pointDTM_get.Rd
5dc3f21356618c3832ec9a28577b8086 *man/rgugik-package.Rd
72669553d8d8d5f208d976ef0249a28e *man/tile_download.Rd
226e0fd8cefbeaf49c7195ea92b3225b *man/tile_download.Rd
7337dc73694683d33e742bba43880e46 *man/topodb_download.Rd
85ef538d488dcb9f89af6ba833e3ca25 *man/voivodeship_names.Rd
237df53a8c5963f000d5151e11586fc1 *tests/testthat.R
12ac9b02d467dfe4250f8db5de366072 *tests/testthat/test-DEM_request.R
beb9c8bca4dafde59924981d33f6264c *tests/testthat/test-DEM_request.R
3ab3920177eb43af973fc88957bb6036 *tests/testthat/test-borders_get.R
7c539ab41a9fda9732485bd0357595e2 *tests/testthat/test-emuia_download.R
86bfbea139004ffac0fc21cbfc008d5a *tests/testthat/test-emuia_download.R
4ace34c93607c35a0885d716a4ae391e *tests/testthat/test-geocodePL_get.R
98368ca4c8d38750b3e99dfb07698d68 *tests/testthat/test-geodb_download.R
63007ae84da1bb31407ac274f316d15a *tests/testthat/test-minmaxDTM_get.R
5b1fbd2999efefd4addb87df9a427769 *tests/testthat/test-models3D_download.R
92917d1dbaf03c9fa6439dfe5931dfe4 *tests/testthat/test-ortho_request.R
8cd7bcd4f7f1be080df52c00d5c7052f *tests/testthat/test-models3D_download.R
3b05caf4c0ec91e60af1d9999f403102 *tests/testthat/test-ortho_request.R
0eb41dc5125ddb97cd0ce34a5a8af5e6 *tests/testthat/test-parcel_get.R
45ea7293adda70855959e90cb492e151 *tests/testthat/test-pointDTM100_download.R
0302295590d6e4592e25a0977d7bf433 *tests/testthat/test-pointDTM_get.R
2ad826ef951dfaa1e6849fa475d69cca *tests/testthat/test-tile_download.R
2e146c74558d22b4dfba7c3a9a29d25e *tests/testthat/test-tile_download.R
485b14eabc8169f5185cbfd0488bb27f *tests/testthat/test-topodb_download.R
117003d40b6a7c0469f80a69d7a6b7af *tests/testthat/test-utils.R
08d837265eb25d481898f23d98dc8d20 *vignettes/DEM-GEOMETRY-1.png
Expand Down
10 changes: 10 additions & 0 deletions NEWS.md
@@ -0,0 +1,10 @@
# rgugik development version

# rgugik 0.4.0

* The `ortho_request()` and `DEM_request()` functions have been updated
to the new API version. Now you can download the latest orthophotomaps
and DEM products.

* Due to the lack of information about SHA in the database, the `checkSHA`
argument in the `tile_download()` function has been deprecated.
51 changes: 30 additions & 21 deletions R/DEM_request.R
Expand Up @@ -7,6 +7,8 @@
#' (different formats of digital terrain model, digital surface model and
#' point clouds)
#'
#' @seealso [`tile_download()`]
#'
#' @export
#'
#' @examples
Expand All @@ -31,13 +33,13 @@ DEM_request = function(x) {
epsg = sf::st_crs(x)$epsg
}

selected_cols = c("godlo", "akt_rok", "format", "charPrzest", "bladSrWys",
"ukladXY", "ukladH", "czy_ark_wypelniony", "url_do_pobrania",
"nazwa_pliku", "idSerie", "sha1", "asortyment")
selected_cols = c("godlo", "akt_rok", "asortyment", "format", "char_przestrz",
"blad_sr_wys", "uklad_xy", "uklad_h", "akt_data", "czy_ark_wypelniony",
"url_do_pobrania", "nazwa_pliku", "id_serie", "zr_danych")
selected_cols = paste(selected_cols, collapse = ",")

# hard coded URL and parameters
base_URL = "https://mapy.geoportal.gov.pl/gprest/services/SkorowidzeFOTOMF/MapServer/1/query?"
base_URL = "https://mapy.geoportal.gov.pl/gprest/services/SkorowidzeFOTOMF/MapServer/4/query?"
geometryType = "&geometryType=esriGeometryEnvelope"
spatialRel = "&spatialRel=esriSpatialRelIntersects"
outFields = paste0("&outFields=", selected_cols)
Expand All @@ -47,22 +49,25 @@ DEM_request = function(x) {
# initial empty df (columns must be identical as in 'selected_cols')
empty_df = data.frame(godlo = character(),
akt_rok = integer(),
asortyment = character(),
format = character(),
charPrzest = character(),
bladSrWys = numeric(),
ukladXY = character(),
#modulArch = character(),
ukladH = character(),
#nrZglosz = character(),
char_przestrz = character(),
blad_sr_wys = numeric(),
uklad_xy = character(),
#modul_arch = character(),
uklad_h = character(),
#nr_zglosz = character(),
akt_data = numeric(),
czy_ark_wypelniony = character(),
#daneAktualne = integer(),
#dane_aktualne = integer(),
#lok_nmt = character(),
url_do_pobrania = character(),
nazwa_pliku = character(),
#idNmt = integer(),
idSerie = integer(),
sha1 = character(),
asortyment = character()
#url_zfs = character(),
#id_nmt = integer(),
id_serie = integer(),
zr_danych = character(),
stringsAsFactors = FALSE
)

for (i in seq_along(x)) {
Expand Down Expand Up @@ -102,15 +107,19 @@ DEM_request = function(x) {
empty_df = empty_df[!duplicated(empty_df$nazwa_pliku), ]

# postprocessing
colnames(empty_df) = c("sheetID", "year", "format", "resolution", "avgElevErr",
"CRS", "VRS", "isFilled", "URL", "filename", "seriesID",
"sha1", "product")
empty_df$CRS = as.factor(empty_df$CRS)
empty_df$VRS = as.factor(empty_df$VRS)
empty_df$isFilled = ifelse(empty_df$isFilled == "TAK", TRUE, FALSE)
colnames(empty_df) = c("sheetID", "year", "product", "format", "resolution", "avgElevErr",
"CRS", "VRS", "date", "isFilled", "URL", "filename", "seriesID",
"source")
empty_df$product = factor(empty_df$product,
levels = c("Dane NMPT", "Dane NMT", "Dane pomiarowe NMT"),
labels = c("DSM", "DTM", "PointCloud"))
empty_df$CRS = as.factor(empty_df$CRS)
empty_df$VRS = as.factor(empty_df$VRS)
empty_df$date = as.Date(as.POSIXct(empty_df$date / 1000, origin = "1970-01-01", tz = "CET"))
empty_df$isFilled = ifelse(empty_df$isFilled == "TAK", TRUE, FALSE)
empty_df$source = factor(empty_df$source,
levels = c("Skaning laserowy", "Zdj. lotnicze"),
labels = c("Laser scanning", "Aerial photo"))

return(empty_df)
}
8 changes: 4 additions & 4 deletions R/geocodePL_get.R
Expand Up @@ -32,7 +32,7 @@ geocodePL_get = function(address = NULL, road = NULL, rail_crossing = NULL, geon

base_URL = "https://services.gugik.gov.pl/uug/?request=GetAddress&address="
prepared_URL = paste0(base_URL, address)
prepared_URL = gsub(" ", "%20", prepared_URL)
prepared_URL = gsub(" ", "%20", prepared_URL, fixed = TRUE)
output = tryGet(jsonlite::fromJSON(prepared_URL))

if (any(output %in% c("error", "warning"))) {
Expand Down Expand Up @@ -62,7 +62,7 @@ geocodePL_get = function(address = NULL, road = NULL, rail_crossing = NULL, geon

base_URL = "https://services.gugik.gov.pl/uug?request=GetRoadMarker&location="
prepared_URL = paste0(base_URL, road)
prepared_URL = gsub(" ", "%20", prepared_URL)
prepared_URL = gsub(" ", "%20", prepared_URL, fixed = TRUE)
output = tryGet(jsonlite::fromJSON(prepared_URL))

if (any(output %in% c("error", "warning"))) {
Expand All @@ -87,7 +87,7 @@ geocodePL_get = function(address = NULL, road = NULL, rail_crossing = NULL, geon

base_URL = "https://services.gugik.gov.pl/uug/?request=GetLevelCrossing&location="
prepared_URL = paste0(base_URL, rail_crossing)
prepared_URL = gsub(" ", "%20", prepared_URL)
prepared_URL = gsub(" ", "%20", prepared_URL, fixed = TRUE)
output = tryGet(jsonlite::fromJSON(prepared_URL))

if (any(output %in% c("error", "warning"))) {
Expand All @@ -109,7 +109,7 @@ geocodePL_get = function(address = NULL, road = NULL, rail_crossing = NULL, geon

base_URL = "https://services.gugik.gov.pl/uug/?request=GetLocation&location="
prepared_URL = paste0(base_URL, geoname)
prepared_URL = gsub(" ", "%20", prepared_URL)
prepared_URL = gsub(" ", "%20", prepared_URL, fixed = TRUE)
output = tryGet(jsonlite::fromJSON(prepared_URL))

if (any(output %in% c("error", "warning"))) {
Expand Down
2 changes: 1 addition & 1 deletion R/geodb_download.R
Expand Up @@ -30,7 +30,7 @@
#' }
geodb_download = function(voivodeships, outdir = ".", unzip = TRUE, ...) {

if (!is.character(voivodeships) | length(voivodeships) == 0) {
if (!is.character(voivodeships) || length(voivodeships) == 0) {
stop("enter names or TERC")
}

Expand Down
2 changes: 1 addition & 1 deletion R/minmaxDTM_get.R
Expand Up @@ -30,7 +30,7 @@ minmaxDTM_get = function(polygon) {

# input area unit is [m^2]
if (as.vector(sf::st_area(polygon)) > 100000) {
stop(paste("maximum area is", 10, "ha"))
stop("maximum area is ", 10, " ha")
}

geom = sf::st_coordinates(polygon)[, 1:2]
Expand Down
43 changes: 23 additions & 20 deletions R/ortho_request.R
Expand Up @@ -5,6 +5,8 @@
#'
#' @return a data frame with metadata and links to the orthoimages
#'
#' @seealso [`tile_download()`]
#'
#' @export
#'
#' @examples
Expand All @@ -29,13 +31,13 @@ ortho_request = function(x) {
epsg = sf::st_crs(x)$epsg
}

selected_cols = c("godlo", "akt_rok", "piksel", "kolor", "zrDanych", "ukladXY",
"czy_ark_wypelniony", "url_do_pobrania", "idSerie", "sha1", "akt_data",
"nazwa_pliku")
selected_cols = c("godlo", "akt_rok", "piksel", "kolor", "zr_danych", "uklad_xy",
"akt_data", "czy_ark_wypelniony", "url_do_pobrania",
"nazwa_pliku", "id_serie")
selected_cols = paste(selected_cols, collapse = ",")

# hard coded URL and parameters
base_URL = "https://mapy.geoportal.gov.pl/gprest/services/SkorowidzeFOTOMF/MapServer/0/query?"
base_URL = "https://mapy.geoportal.gov.pl/gprest/services/SkorowidzeFOTOMF/MapServer/3/query?"
geometryType = "&geometryType=esriGeometryEnvelope"
spatialRel = "&spatialRel=esriSpatialRelIntersects"
outFields = paste0("&outFields=", selected_cols)
Expand All @@ -47,21 +49,22 @@ ortho_request = function(x) {
akt_rok = integer(),
piksel = numeric(),
kolor = character(),
zrDanych = character(),
ukladXY = character(),
#modulArch = character(),
#nrZglosz = character(),
zr_danych = character(),
uklad_xy = character(),
#modul_arch = character(),
#nr_zglosz = character(),
akt_data = numeric(),
#akt_dzien = character(),
czy_ark_wypelniony = character(),
#daneAktualne = integer(),
#daneAktDo10cm = integer(),
#dane_aktualne = integer(),
#dane_aktualne_do_10cm = integer(),
#lok_orto = character(),
url_do_pobrania = character(),
idSerie = integer(),
sha1 = character(),
akt_data = numeric(),
#idorto = integer(),
nazwa_pliku = character()
#ESRI_OID = integer()
nazwa_pliku = character(),
#url_zfs = character(),
#id_orto = integer(),
id_serie = integer(),
stringsAsFactors = FALSE
)

for (i in seq_along(x)) {
Expand Down Expand Up @@ -102,15 +105,15 @@ ortho_request = function(x) {

# postprocessing
colnames(empty_df) = c("sheetID", "year", "resolution", "composition",
"sensor", "CRS", "isFilled", "URL", "seriesID",
"sha1", "date", "filename")
"sensor", "CRS", "date", "isFilled", "URL",
"filename", "seriesID")
empty_df$composition = as.factor(empty_df$composition)
empty_df$date = as.Date(as.POSIXct(empty_df$date / 1000, origin = "1970-01-01", tz = "CET"))
empty_df$CRS = as.factor(empty_df$CRS)
empty_df$isFilled = ifelse(empty_df$isFilled == "TAK", TRUE, FALSE)
empty_df$sensor = factor(empty_df$sensor,
levels = c("Scena sat.", "Zdj. analogowe", "Zdj. cyfrowe"),
labels = c("Satellite", "Analog", "Digital"))
levels = c("Scena sat.", "Zdj. analogowe", "Zdj. cyfrowe"),
labels = c("Satellite", "Analog", "Digital"))

return(empty_df)
}
Expand Down
2 changes: 1 addition & 1 deletion R/parcel_get.R
Expand Up @@ -62,7 +62,7 @@ parcel_get = function(TERYT = NULL, X = NULL, Y = NULL) {
}

output = output[2]
output = unlist(strsplit(output, "\\|"))
output = unlist(strsplit(output, "|", fixed = TRUE))
wkb = structure(list(output[1]), class = "WKB")
geom = sf::st_as_sfc(wkb, EWKB = TRUE, crs = 2180)
geom = sf::st_sf(geom, TERYT = output[2])
Expand Down
2 changes: 1 addition & 1 deletion R/pointDTM100_download.R
Expand Up @@ -20,7 +20,7 @@
#' }
pointDTM100_download = function(voivodeships, outdir = ".", unzip = TRUE, ...) {

if (!is.character(voivodeships) | length(voivodeships) == 0) {
if (!is.character(voivodeships) || length(voivodeships) == 0) {
stop("enter names or TERC")
}

Expand Down

0 comments on commit e2e55ea

Please sign in to comment.