Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # load packages
- require(raster)
- require(rgdal)
- # Step 1: read in raster from .tif file
- r <- raster("C:/.../raster.tif")
- # Q: how do you do this with a .sid file?
- # read in shapefile used for clip
- shp <- readOGR(dsn="C:/.../folder", layer="shapefile")
- # Step 2: clip raster to shapefile
- r.clip <- crop(r, shp)
- # Step 3: save clipped raster as tiff
- writeRaster(r.clip, "C:/.../raster_clip.tif", format="GTiff")
- library(rgdal)
- r <- readGDAL("C:/.../raster.sid")
- library(gdalUtils)
- gdal_setInstallation(search_path =...) # choose GDAL version with this function
- r <- gdal_translate(src_dataset = "C:/.../raster.sid",
- dst_dataset = "raster.tif",
- output_Raster = TRUE) # create R raster object
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement