Skip to content

Instantly share code, notes, and snippets.

@petermllrr
Created June 9, 2020 21:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save petermllrr/cc5041047f59c08b4d12ce6d0fe8f44c to your computer and use it in GitHub Desktop.
Save petermllrr/cc5041047f59c08b4d12ce6d0fe8f44c to your computer and use it in GitHub Desktop.
GeoTiff R
# Libraries ===================
library("raster")
library("rgdal")
# Load data ===================
# all_files <- list.files(path = "./data", pattern='.tif$', all.files=TRUE, full.names=FALSE)
# Process data ================
raster_data <- raster("./data/LC08_L1TP_196025_20150821_20170406_01_T1_°C_corr.tif")
shape_data <- readOGR("./data", layer = "Cologne", stringsAsFactors = FALSE)
cropped_data <- crop(raster_data, shape_data)
# Write data ===================
writeRaster(cropped_data, filename = "./out/out.tif", driver = "GeoTiff", overwrite = TRUE)
# /| __
# / | ,-~ /
# Y :| // /
# | jj /( .^
# >-"~"-v"
# / Y
# jo o |
# ( ~T~ j
# >._-' _./
# / "~" |
# Y _, |
# /| ;-"~ _ l
# / l/ ,-"~ \
# \//\/ .- \
# Y / Y -Row
# l I !
# ]\ _\ /"\
# (" ~----( ~ Y. )
#~~~~~~~~~~~~~~~~~~~~~~~~~~
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment