-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME.Rmd
97 lines (64 loc) · 3.57 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
---
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%"
)
```
# filearchy
<!-- badges: start -->
[![R-CMD-check](https://github.com/hypertidy/filearchy/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/hypertidy/filearchy/actions/workflows/R-CMD-check.yaml)
<!-- badges: end -->
The goal of filearchy is to generate pyramid tiled image directories. Like [gdal2tiles.py](https://gdal.org/programs/gdal2tiles.html).
## TODO
* (*somehow*) detect the case when warp is not needed (3857->3857 or 4326->4326) and use RasterIO (translate) instead, it should be a bit faster - but how to encode that in the scheme vs. the run?
* driver and file extension options, we have png and jpeg
* make it clear that byte-scaling is not mandatory, perfectly valid to have tiles of data like [tiles-prod](https://registry.opendata.aws/terrain-tiles/) and see [sds::wms_amazon_elevation()](https://hypertidy.github.io/sds/)
* add palette-handling example (or point to one, probably a gdalraster vignette on byte-scaling and attach palette and expand)
* VRT creation for tiles (at zoom), or conversion to GTI etc
* add resampling option
* discuss parallel write, how to enable
* exclude transparent tiles (not sure how, do we detect zero-png/jpg?)
* DONE add arbitrary zoom levels not just a max
* DONE 'update' arg - resume (don't rewrite non-missing)
* DONE profile mercator/geodetic/raster
* DONE - see `grout::tile_spec()` we have `dry_run` in gdal_tiles() but I think it should be a separate function to render from the scheme
* DONE implement xyz vs tms mode
* DONE generate leaflet.html index
## Installation
You can install the development version of filearchy from [GitHub](https://github.com/) with:
``` r
# install.packages("devtools")
devtools::install_github("hypertidy/filearchy")
```
## Example
'gebco_ovr5.vrt' is a pre-prepared version of GEBCO 2023 elevation COG that has been Byte-scaled and reduced to a manageable subset.
Here we use that as input, it will read data from the internet (a COG of GEBCO), and write tiles from zoom level 0 to zoom level 3, detected as the scope of resolution that includes the highest level of detail available.
We can specify `zoom` to only generate one or more levels, and the `output_dir` param can be used to specify where the tiles are written. By default we also get an html index.
```{r example}
library(filearchy)
#options(parallelly.fork.enable = TRUE, future.rng.onMisuse = "ignore")
#library(furrr); plan(multicore)
dsn <- system.file("extdata/gebco_ovr5.vrt", package = "filearchy", mustWork = TRUE)
tiles <- gdal_tiles(dsn, dry_run = FALSE)
#plan(sequential)
fs::dir_ls(dirname(dirname(dirname(tiles$path[1]))), recurse = TRUE, type = "f")
```
Now open the html index ** "leaflet.html" ** from that directory.
Or, just do a dry_run:
```{r scheme-only}
(scheme <- gdal_tiles(dsn, zoom = 0:5))
ex <- c(min(scheme$xmin), max(scheme$xmax), min(scheme$ymin), max(scheme$ymax))
plot(ex[1:2], ex[3:4], asp = 1)
md <- dplyr::filter(scheme, zoom == round(mean(unique(zoom)) ))
with(md, rect(xmin, ymin, xmax, ymax, border = "red", lwd = 3))
mx <- dplyr::filter(scheme, zoom == max(zoom) )
with(mx, rect(xmin, ymin, xmax, ymax))
```
## Code of Conduct
Please note that the filearchy project is released with a [Contributor Code of Conduct](https://contributor-covenant.org/version/2/1/CODE_OF_CONDUCT.html). By contributing to this project, you agree to abide by its terms.