Skip to content

Instantly share code, notes, and snippets.

@patchdynamics
Last active August 29, 2015 14:27
Show Gist options
  • Save patchdynamics/141751932b7c3e464b56 to your computer and use it in GitHub Desktop.
Save patchdynamics/141751932b7c3e464b56 to your computer and use it in GitHub Desktop.
Crop high def raster to polygon efficiently
# tried with gdalwarp, but ends up slow with a huge file
gdalwarp -q -cutline /Users/matthewxi/Documents/Projects/NASQAN/clip_columbia_extent_conus.shp -crop_to_cutline -co COMPRESS=LZW -of GTiff /Users/matthewxi/Documents/Projects/NASQAN/nasqan_raster_conus_compressed/b14246900_polygon.shp30.tiff /Users/matthewxi/Documents/Projects/NASQAN/b14246900_nlcd_clipped_3.tif
# gdal_translate seems to be the better option
# using extents to crop
gdal_translate -projwin -2191346 3275471 -1068667 2168385 -co "COMPRESS=LZW" /Users/matthewxi/Documents/Projects/NASQAN/nasqan_raster_conus_compressed/b14246900_polygon.shp30.tiff /Users/matthewxi/Documents/Projects/NASQAN/b14246900_nlcd_clipped_7.tif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment