I would like to use R to:
- Read in an MrSID raster (.sid format)
- Clip the extent using a shapefile
- Save the new clipped raster as a geotiff
I am fine with steps #2 and 3, but I can't find any information about reading an MrSID file to R. Here is an example of what my workflow would look like if the raster was a .tif instead of a .sid:
# 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")
I know this could be done relatively easily in something like QGIS, but I have a large number of shapefiles I would like to use as clipping extents and then do some follow-up data analysis, so I would like to use R to automate it.
I've found other questions regarding GDAL and MrSID (e.g. here), but none related to R, and I'm kind of a GDAL newbie so I haven't been able to successfully translate the knowledge.