-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathREADME.Rmd
More file actions
107 lines (84 loc) · 3.12 KB
/
Copy pathREADME.Rmd
File metadata and controls
107 lines (84 loc) · 3.12 KB
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
---
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 = "80%"
)
```
# mapiso <img src="man/figures/logo.png" align="right" width="140"/>
<!-- badges: start -->
[](https://www.repostatus.org/#active)
[](https://cran.r-project.org/package=mapiso)
[](https://github.com/riatelab/mapiso/actions/workflows/R-CMD-check.yaml)
[](https://app.codecov.io/gh/riatelab/mapiso?branch=main)
<!-- badges: end -->
The goal of `mapiso` is to ease the transformation of regularly spaced grids containing continuous data into contour polygons.
These grids can be defined by data.frames (x, y, value), `sf` objects or SpatRasters from `terra`.
`mapsio` is a wrapper around [`isoband`](https://isoband.r-lib.org).
## Installation
You can install the released version of `mapiso` from
[CRAN](https://cran.r-project.org/package=mapiso) with:
``` r
install.packages("mapiso")
```
Alternatively, you can install the development version of `mapiso` from
GitHub with:
``` r
remotes::install_github("riatelab/mapiso")
```
## Usage
### Raster
```{r raster}
library(mapiso)
library(terra)
library(mapsf)
r <- rast(system.file("tif/elevation.tif", package = "mapiso"))
isor <- mapiso(x = r)
mf_theme(mar = c(0, 0, 0, 0))
mf_raster(r)
mf_map(isor, col = NA, add = TRUE)
```
### sf regular grid
```{r sf}
library(mapiso)
library(sf)
library(mapsf)
# gridded data
s <- st_read(system.file("gpkg/elevation.gpkg", package = "mapiso"),
layer = "elevation", quiet = TRUE)
# mask
m <- st_read(system.file("gpkg/elevation.gpkg", package = "mapiso"),
layer = "com", quiet = TRUE)
# custom breaks
bks <-c(98,100, 150, 200, 250, 300, 350, 400, 412.6)
isos <- mapiso(x = s, var = "elevation", breaks = bks, mask = m)
mf_map(isos, "isomin", "choro",
breaks = bks, border = NA,
leg_title = "elevation")
mf_map(m, col = NA, add = TRUE)
mf_map(s, cex = 1, pch = ".", col = "grey20", add = TRUE)
```
### data.frame
```{r data.frame}
library(mapiso)
library(mapsf)
d <- read.csv(system.file("csv/elevation.csv", package = "mapiso"))
head(d)
isod <- mapiso(x = d, var = 'elevation', coords = c('x', 'y'), crs = 'epsg:2154')
bks <- unique(c(isod$isomin, isod$isomax))
mf_map(isod, "isomin", "choro", breaks = bks, leg_title = "elevation")
```
## Community Guidelines
One can contribute to the package through [pull
requests](https://github.com/riatelab/mapiso) and report issues or
ask questions [here](https://github.com/riatelab/mapiso/issues).
This project uses [conventional
commits](https://www.conventionalcommits.org/en/v1.0.0-beta.3/) and
[semantic versioning](https://semver.org/).