Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/program--/tidygdal


https://github.com/program--/tidygdal

Last synced: 24 days ago
JSON representation

Awesome Lists containing this project

README

        

---
output: github_document
---

```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```

# tidygdal

## Installation

You can install the development version of tidygdal like so:

``` r
pak::pkg_install("program--/tidygdal")
```

## Example

### Opening a vector file
```{r example_open}
path <- system.file("testdata", "nc.gpkg", package = "tidygdal")

ds <- tidygdal::gdal_vector(path)
ds

# Similar to `sf::st_layers`
tidygdal::gdal_vector_layers(ds)
```

### Vector Translate (ogr2ogr)

```{r example_ogr2ogr}
library(tidygdal)

testdata <- system.file("testdata", package = "tidygdal")

# Convert the test GPKG to a FlatGeoBuf file
# Note: order of these steps does not matter
# Additionally, omitting `gdal_vto_set_output` returns the transformed
# data to an in-memory dataset.
gdal_vto() |>
gdal_vto_set_input_fmt("GPKG") |>
gdal_vto_set_output_fmt("FlatGeoBuf") |>
gdal_vto_set_target_srs("EPSG:5070") |>
gdal_vto_set_make_valid() |>
gdal_vto_set_new_layer_name("nc") |>
gdal_vto_set_input(file.path(testdata, "nc.gpkg")) |>
gdal_vto_set_output(file.path(testdata, "nc.fgb")) |>
gdal_vector_translate()
```