Skip to content

Commit

Permalink
style: adjust white space
Browse files Browse the repository at this point in the history
  • Loading branch information
elipousson committed Aug 16, 2022
1 parent 514f229 commit 639543d
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 22 deletions.
11 changes: 6 additions & 5 deletions R/as_sf.R
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,12 @@ as_bbox <- function(x, crs = NULL, ext = TRUE, ...) {
switch(x_is,
"sf_pt" = sf::st_bbox(st_buffer_ext(x, dist = 0.00000001), ...),
"sf_or_sfc" = sf::st_bbox(x, ...),
"num_bbox" = sf::st_bbox(c(
xmin = x[1], ymin = x[2],
xmax = x[3], ymax = x[4]
),
crs = crs, ...
"num_bbox" = sf::st_bbox(
c(
xmin = x[1], ymin = x[2],
xmax = x[3], ymax = x[4]
),
crs = crs, ...
),
"other" = sf::st_bbox(as_sf(x, ext = ext), ...)
)
Expand Down
1 change: 0 additions & 1 deletion R/sf_to_df.R
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,6 @@ coords_df_to_sf <- function(x, coords = c("lon", "lat"), into = NULL, sep = ",",
#' @export
#' @importFrom janitor make_clean_names
check_coords <- function(x = NULL, coords = NULL, default = c("lon", "lat"), rev = FALSE) {

# If x is a data frame
if (!is.null(x) && is.data.frame(x)) {
if (!has_coords(x, coords = coords, value = FALSE)) {
Expand Down
3 changes: 2 additions & 1 deletion R/st_buffer_ext.R
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@ st_buffer_ext <- function(x,
dist = dist,
dist_limits = dist_limits,
unit = unit,
crs = crs)
crs = crs
)

x <- sf::st_buffer(x = x, dist = dist, singleSide = single_side, ...)

Expand Down
1 change: 0 additions & 1 deletion R/st_clip.R
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ st_clip <- function(x,
dist = NULL,
diag_ratio = NULL,
unit = "meter") {

# If bbox, convert to sf
x <- as_sf(x)

Expand Down
4 changes: 2 additions & 2 deletions R/st_join_ext.R
Original file line number Diff line number Diff line change
Expand Up @@ -105,13 +105,13 @@ set_join_by_geom_type <- function(x, join = NULL) {
all(
is_multipolygon(x, by_geometry = TRUE) |
is_polygon(x, by_geometry = TRUE)
)
)
} else if (is_sf_list(x)) {
x_is_poly <-
all(
sapply(x, is_polygon, by_geometry = TRUE) |
sapply(x, is_multipolygon, by_geometry = TRUE)
)
)
}

if (x_is_poly) {
Expand Down
8 changes: 4 additions & 4 deletions R/write_sf_ext.R
Original file line number Diff line number Diff line change
Expand Up @@ -338,11 +338,11 @@ write_sf_types <- function(data,
if (!(filetype %in% c("rda", "rds", "RData"))) {
ask <-
is_interactive() &&
cli_yeah(
c("{.arg data} is not a simple feature object.",
">" = "Do you want to save {.arg data} as a RDA file?"
cli_yeah(
c("{.arg data} is not a simple feature object.",
">" = "Do you want to save {.arg data} as a RDA file?"
)
)
)

if (!ask) {
invisible(return(NULL))
Expand Down
6 changes: 3 additions & 3 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,12 @@ 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")
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")
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:

Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,12 @@ 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")
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")
geom_sf_label(data = nc[random_id, ], aes(label = NAME), size = 2) +
theme(legend.position = "bottom")
#> Warning in st_point_on_surface.sfc(sf::st_zm(x)): st_point_on_surface may not
#> give correct results for longitude/latitude data
```
Expand Down
4 changes: 2 additions & 2 deletions vignettes/introduction.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -222,15 +222,15 @@ There are also several functions that return information about the geometry of i
The `get_length()` function wraps `sf::st_length` and (for POLYGON geometries only) `lwgeom::st_perimeter`:

```{r}
example_line <- as_line(as_point(nc[1,]), as_point(nc[2,]), crs = 4326)
example_line <- as_line(as_point(nc[1, ]), as_point(nc[2, ]), crs = 4326)
glimpse(get_length(example_line))
```

The `get_area()` function wraps `sf::st_area`:

```{r}
glimpse(get_area(nc[1:3,], unit = "mi^2"))
glimpse(get_area(nc[1:3, ], unit = "mi^2"))
```

`get_dist()` supports a more varied range of options including using the "to" parameter to define a corner or center of the input sf object bounding box.
Expand Down

0 comments on commit 639543d

Please sign in to comment.