Learn R Programming

fields (version 5.02)

image2lz: Some simple functions for subsetting images

Description

These function help in subsetting a image or reducing it size by averaging adjecent cells.

Usage

crop.image(obj, loc=NULL,...)
half.image(obj)
get.rectangle()

Arguments

Details

If loc has more than 2 rows then the largest rectangle containing the locations is used.

See Also

drape.plot, image.plot

Examples

Run this code
data(RMelevation)


loc<- rbind( c(-106.5, 40.8),
             c(-103.9, 37.5))

# extract elevations for just CO frontrange.
FR<- crop.image(RMelevation, loc)
#  check:   image.plot( FR)

# average cells  4 to 1 by doing this twice!
 half.image( RMelevation)-> temp
 half.image( temp)-> temp

# extract the this averaged image
 FR2<- crop.image(temp, loc)
 zr<- range( FR$z)
 set.panel( 1,2)
 image.plot( FR, zlim =zr, horizontal=TRUE)
 image( FR2, zlim =zr, col=tim.colors())

Run the code above in your browser using DataLab