Skip to content

Instantly share code, notes, and snippets.

@hakimabdi
Created October 23, 2015 16:13
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save hakimabdi/d9cb36ee4f3ef3e1ed29 to your computer and use it in GitHub Desktop.
Save hakimabdi/d9cb36ee4f3ef3e1ed29 to your computer and use it in GitHub Desktop.
##############################################################################
# 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