Skip to content

Commit

Permalink
changing from sf_as_sf to sf_sf where possible to help resolve issue #39
Browse files Browse the repository at this point in the history
  • Loading branch information
jflowernet committed Jan 22, 2024
1 parent 676135d commit 8944a6c
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions R/sf_to_planning_grid.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ sf_to_planning_grid <- function(dat, planning_grid, matching_crs, name, sf_col_l
if(is.null(sf_col_layer_names)){
dat <- dat %>%
sf::st_geometry() %>%
sf::st_as_sf() %>%
sf::st_sf() %>%
dplyr::mutate(sf_col_layer_names = 1, .before = 1)
} else {
dat <- dat %>%
Expand All @@ -45,7 +45,7 @@ sf_to_planning_grid <- function(dat, planning_grid, matching_crs, name, sf_col_l
} else .} %>%
sf::st_crop(p_grid) %>%
sf::st_transform(sf::st_crs(planning_grid)) %>%
{if(antimeridian) sf::st_union(.) %>% sf::st_as_sf() else .}
{if(antimeridian) sf::st_union(.) %>% sf::st_sf() else .}
}
dat_cropped %>%
terra::rasterize(planning_grid, field = 1, by = sf_col_layer_names) %>%
Expand All @@ -65,7 +65,7 @@ sf_to_planning_grid <- function(dat, planning_grid, matching_crs, name, sf_col_l
sf::st_crop(p_grid) %>%
sf::st_transform(sf::st_crs(planning_grid)) %>%
sf::st_union() %>%
sf::st_as_sf()
sf::st_sf()
}else{
dat_cropped <- if(matching_crs) dat %>% sf::st_crop(planning_grid) else{planning_grid %>%
sf::st_transform(sf::st_crs(dat)) %>%
Expand Down

0 comments on commit 8944a6c

Please sign in to comment.