Instantly share code, notes, and snippets.

Embed
What would you like to do?
##############################################################################
# title : mosaicGTiffs.R
# purpose : Takes in projected GeoTIFF outputs from projHDF2GTiff or
# : other GeoTIFFS and mosaics them into on larger file
# author : Abdulhakim Abdi (@HakimAbdi)
# input : Individual GeoTIFF files
# output : A mosaicked GeoTIFF file with a larger extent
##############################################################################
mosaicGTiffs = function(proj.loc, gtiffs, mosaicName, overwrite){
if("gdalUtils" %in% rownames(installed.packages()) == FALSE){ # checks if gdalutils is installed
install.packages("gdalUtils", repos="http://r-forge.r-project.org")
require(gdalUtils)
}
suppressWarnings(dir.create(paste(proj.loc,"Mosaicked",sep="/"))) # creates a directory to store mosaicked file
gdalwarp(gtiffs, paste(proj.loc,"/","Mosaicked","/",mosaicName,".tif",sep=""),overwrite = overwrite)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment