Skip to content

Instantly share code, notes, and snippets.

@cbrown5
Created May 18, 2020 12:18
Show Gist options
  • Select an option

  • Save cbrown5/65ac150cb71de8cc6c7923313a2b72f5 to your computer and use it in GitHub Desktop.

Select an option

Save cbrown5/65ac150cb71de8cc6c7923313a2b72f5 to your computer and use it in GitHub Desktop.

Revisions

  1. cbrown5 created this gist May 18, 2020.
    9 changes: 9 additions & 0 deletions st_as_raster
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,9 @@
    #Takes as an input a stars raster layer
    #CJ Brown 2020-05-18

    st_as_raster <- function(rstars){
    rext <- st_bbox(rstars)
    raster(t(rstars[[1]]), xmn = rext[1], xmx = rext[3],
    ymn = rext[2], ymx=rext[4],
    crs = st_crs(rstars)$proj4string)
    }