-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathREADME.Rmd
206 lines (154 loc) · 7.6 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r include=FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# rgugik <img src="man/figures/logo.png" align="right" width="150"/>
<!-- badges: start -->
[![CRAN](https://www.r-pkg.org/badges/version/rgugik)](https://cran.r-project.org/package=rgugik)
[![R build status](https://github.com/kadyb/rgugik/workflows/rcmdcheck/badge.svg)](https://github.com/kadyb/rgugik/actions)
[![codecov](https://codecov.io/gh/kadyb/rgugik/branch/master/graph/badge.svg)](https://app.codecov.io/gh/kadyb/rgugik)
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/license/mit)
[![DOI](https://joss.theoj.org/papers/10.21105/joss.02948/status.svg)](https://doi.org/10.21105/joss.02948)
<!-- badges: end -->
**rgugik** is an R package for downloading open data from resources of [Polish Head Office of Geodesy and Cartography](https://www.gov.pl/web/gugik) including:
- [Orthophotomaps](https://www.geoportal.gov.pl/pl/dane/ortofotomapa-orto/)
- [General Geographic Database](https://www.geoportal.gov.pl/pl/dane/baza-danych-obiektow-ogolnogeograficznych-bdoo/)
- [Topographic Database](https://www.geoportal.gov.pl/pl/dane/baza-danych-obiektow-topograficznych-bdot10k/)
- [Register of Towns, Streets and Addresses](https://emuia.gugik.gov.pl)
- [State Register of Geographical Names](https://www.geoportal.gov.pl/pl/dane/panstwowy-rejestr-nazw-geograficznych-prng/)
- [State Register of Borders](https://www.geoportal.gov.pl/pl/dane/panstwowy-rejestr-granic-prg/)
- [Land and Building Registers](https://www.geoportal.gov.pl/pl/dane/ewidencja-gruntow-i-budynkow-egib/)
- Location (geometry) of cadastral parcels using TERYT (parcel ID) or coordinates
- 3D models of buildings (LOD1, LOD2)
- Various digital elevation models as:
- [Digital terrain model](https://www.geoportal.gov.pl/pl/dane/numeryczny-model-terenu-nmt/)
- [Digital surface model](https://www.geoportal.gov.pl/pl/dane/numeryczny-model-pokrycia-terenu-nmpt/)
- [Point cloud](https://www.geoportal.gov.pl/pl/dane/dane-pomiarowe-lidar-lidar/)
It is also possible to geocode addresses or objects using the `geocodePL_get()` function.
**Corresponding functions**
```{r echo=FALSE}
ds_pl = c("Ortofotomapa",
"Baza Danych Obiektów Ogólnogeograficznych",
"Baza Danych Obiektów Topograficznych",
"Ewidencja Miejscowości, Ulic i Adresów",
"Ewidencja Gruntów i Budynków",
"Państwowy Rejestr Nazw Geograficznych",
"Państwowy Rejestr Granic",
"Lokalizacja działek katastralnych",
"Modele 3D budynków",
"Cyfrowe modele wysokościowe")
ds_en = c("Orthophotomap",
"General Geographic Database",
"Topographic Database",
"Register of Towns, Streets and Addresses",
"Land and Building Register",
"State Register of Geographical Names",
"State Register of Borders",
"Location of cadastral parcels",
"3D models of buildings",
"Digital elevation models")
fun = c("`ortho_request()`, `tile_download()`",
"`geodb_download()`",
"`topodb_download()`",
"`emuia_download()`",
"`egib_download()`",
"`geonames_download()`",
"`borders_get()`, `borders_download()`",
"`parcel_get()`",
"`models3D_download()`",
"`DEM_request()`, `tile_download()`")
input = c("geometry",
"voivodeship",
"county",
"commune",
"county",
"type",
"type",
"parcel ID, coordinates",
"county",
"geometry")
df = data.frame(fun, input, ds_en, ds_pl)
colnames(df) = c("Function", "Input", "Dastaset EN", "Dataset PL")
knitr::kable(df)
```
There are the additional functions for obtaining digital terrain model:
- `pointDTM_get()` for small areas (high resolution grid)
- `pointDTM100_download()` for voivodeships areas (low resolution grid)
- `minmaxDTM_get()` to find the minimum and maximum elevation (small areas)
The names of administrative units and their IDs are included in these objects:
- `voivodeship_names` (16)
- `county_names` (380)
- `commune_names` (2476)
## Installation
You can install the released version from [CRAN](https://cran.r-project.org/) with:
```{r eval=FALSE}
install.packages("rgugik")
```
You can install the development version from [GitHub](https://github.com) with:
```{r message=FALSE, warning=FALSE, eval=FALSE}
# install.packages("remotes")
remotes::install_github("kadyb/rgugik")
```
## Usage
### Orthophotomap
- `ortho_request()` - returns a data frame with metadata and links to the orthoimages for a given geometry (point, line or polygon)
- `tile_download()` - downloads orthoimages based on the data frame obtained using the `ortho_request()` function
```{r f1, message=FALSE, warning=FALSE}
library(rgugik)
library(sf)
library(stars)
polygon_path = system.file("datasets/search_area.gpkg", package = "rgugik")
polygon = read_sf(polygon_path)
req_df = ortho_request(polygon)
# select the oldest image
req_df = req_df[req_df$year == 2001, ]
# print metadata
t(req_df)
# download image
tile_download(req_df)
img = read_stars("41_3756_N-33-130-D-b-2-3.tif")
plot(st_rgb(img), main = NULL)
```
```{r echo=FALSE, message=FALSE}
invisible(file.remove("41_3756_N-33-130-D-b-2-3.tif"))
```
### Administrative boundaries
```{r f2}
library(rgugik)
library(sf)
# get counties from opolskie voivodeship (TERYT 16)
counties = county_names
counties = counties[substr(counties$TERYT, 1, 2) == "16", "TERYT"]
counties_geom = borders_get(TERYT = counties)
plot(st_geometry(counties_geom), main = "Opolskie")
```
### Vignettes
More advanced examples of the practical (step by step) use of this package can be found in the vignettes:
- [Orthophotomap](https://kadyb.github.io/rgugik/articles/orthophotomap.html)
- [Digital elevation model](https://kadyb.github.io/rgugik/articles/DEM.html)
- [Topographic Database](https://kadyb.github.io/rgugik/articles/topodb.html)
## Acknowledgment
[Head Office of Geodesy and Cartography in Poland](https://www.gov.pl/web/gugik) is the main source of the provided data. The data is made available in accordance with the [Act of May 17, 1989 Geodetic and Cartographic Law](http://isap.sejm.gov.pl/isap.nsf/DocDetails.xsp?id=WDU19890300163) (amended on 16 April 2020).
All datasets can be explored interactively using the [Geoportal](https://mapy.geoportal.gov.pl).
## Contribution
Contributions to this package are welcome.
The preferred method of contribution is through a GitHub pull request.
Feel also free to contact us by creating [an issue](https://github.com/kadyb/rgugik/issues).
More detailed information can be found in the [CONTRIBUTING](https://github.com/kadyb/rgugik/blob/master/CONTRIBUTING.md) document.
Maintainers and contributors must follow this repository’s [CODE OF CONDUCT](https://github.com/kadyb/rgugik/blob/master/CODE_OF_CONDUCT.md).
## Citation
To cite **rgugik** in publications, please use the following [article](https://doi.org/10.21105/joss.02948):
```
Dyba, K. and Nowosad, J. (2021). rgugik: Search and Retrieve Spatial Data from the Polish Head Office of Geodesy and Cartography in R. Journal of Open Source Software, 6(59), 2948, https://doi.org/10.21105/joss.02948
```
BibTeX version can be obtained with `citation("rgugik")`.
## Related projects
If you don't feel familiar with R, there is a similar [QGIS](https://www.qgis.org/) tool in the [EnviroSolutions](https://github.com/envirosolutionspl) repository.