Skip to content

Commit

Permalink
change in cropping the grid
Browse files Browse the repository at this point in the history
  • Loading branch information
aleruete committed Jul 23, 2021
1 parent edfeb6e commit 63a48d2
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions R/makeGrid.r
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ makeGrid <- function(poly,
crs = st_crs(getUTMproj(poly)))

## If many polygons instead of a multipolygon

if(length(st_geometry(poly)) > 1) poly <- st_union(poly)

if(is.null(offset)){
Expand Down Expand Up @@ -313,10 +313,16 @@ makeGrid <- function(poly,
offset = offset,
what = "polygons")

### Transform to original
grid <- st_transform(grid, crs = st_crs(4326))


poly <- st_transform(poly,
crs = st_crs(4326))

cells <- st_intersects(poly, grid)[[1]]
grid <- grid[cells]

grid <- st_transform(grid, crs = st_crs(4326))
return(grid)
}

Expand Down

0 comments on commit 63a48d2

Please sign in to comment.