lssub: Subset a geotiff image.

View source: R/lssub.R

lssubR Documentation

Subset a geotiff image.

Description

Uses GDAL tools to reproject (optional) and subset a geotiff given the center point and the desired size.

Usage

lssub(filename, outname, centerx, centery, centerepsg, widthx, widthy)

Arguments

filename

Filename (and path) to a geotiff image.

outname

Filename (and path) for subset image.

centerx

x coordinate of new center point.

centery

y coordinate of new center point.

centerepsg

Projection of the center point coordinates as 5-digit EPSG code. If missing, assume that point and geotiff have the same projection.

widthx

Desired width of subset image.

widthy

Desired height of subset image.

Details

The new image will be a subset of size (widthx, widthy) with center point (centerx, centery), with the same pixel size. If the center point coordinates are in a different projection than the original image, they will be reprojected.

Value

The new image is exported as a geotiff. Nothing is returned within R.

Note

Requires gdalinfo and gdaltransform to be available to the operating system. Only known to work on linux. This function was written to speed processing of multiple files for a specific project, and may be dropped in future releases of the landsat package. On my computer, lssub() is over an order of magnitude faster than reading the image into R, subsetting it, and writing out the result.

Author(s)

Sarah Goslee

Examples

	## Not run: lssub("/data/gis/testimage.tif", "/data/gis/subimage.tif", centerx = 260485, 
	centery = 4527220, centerepsg = 26918, widthx = 50, widthy = 50)
## End(Not run)

landsat documentation built on Aug. 25, 2023, 1:07 a.m.