-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathREADME.Rmd
76 lines (58 loc) · 2.26 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
---
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%"
)
```
# sfext <a href="https://elipousson.github.io/sfext/"><img src="man/figures/logo.png" align="right" height="118" /></a>
<!-- badges: start -->
[](https://CRAN.R-project.org/package=sfext)
[](https://lifecycle.r-lib.org/articles/stages.html#experimental)
[](https://opensource.org/licenses/MIT)
[](https://app.codecov.io/gh/elipousson/sfext?branch=main)
[](https://www.repostatus.org/#active)
<!-- badges: end -->
The goal of sfext is to extend existing functions from the {sf} package and offer a range of additional options for working with simple feature objects, bounding boxes, and data frame objects with coordinates or other spatial information.
## Installation
You can install the development version of sfext like so:
``` r
# pak::pkg_install("elipousson/sfext")
```
## Examples
```{r setup}
library(ggplot2)
library(sfext)
theme_set(theme_void())
```
Get data with read_sf_ext and related functions:
```{r}
nc <- read_sf_ext(path = system.file("shape/nc.shp", package = "sf"))
```
Combine data with st_union_ext:
```{r}
random_id <- sample(nrow(nc), size = 8)
nc_union <- st_union_ext(nc[random_id, ], name_col = "NAME")
ggplot() +
geom_sf(data = nc_union, aes(fill = NAME), alpha = 0.2) +
geom_sf_label(data = nc[random_id, ], aes(label = NAME), size = 2) +
theme(legend.position = "bottom")
```
Make grids set rows, columns, and aspect ratios using st_make_grid_ext:
```{r}
# Make a 5 by 5 grid with a 8.5 by 11 aspect ratio filtered to x
plot(
st_make_grid_ext(
x = nc[24, ],
asp = 8.5 / 11,
ncol = 5,
nrow = 5,
filter = TRUE
)
)
```