[R-sig-Geo] Help on extracting min/max from raster object

Jacob van Etten jacobvanetten at yahoo.com
Tue Mar 1 15:28:20 CET 2011


Ideally, extract values using extractor functions only.

In this case:

minValue(r)

Jacob.

--- On Tue, 1/3/11, Roman Luštrik <roman.lustrik at gmail.com> wrote:

> From: Roman Luštrik <roman.lustrik at gmail.com>
> Subject: Re: [R-sig-Geo] Help on extracting min/max from raster object
> To: "Rahul Raj" <rahulosho at gmail.com>
> Cc: r-sig-geo at r-project.org
> Date: Tuesday, 1 March, 2011, 14:18
> Doing it the non-pretty way is
> 
> r at data@min
> r at data@max
> 
> (see str(r))
> 
> Cheers,
> Roman
> 
> 
> 
> On Tue, Mar 1, 2011 at 1:22 PM, Rahul Raj <rahulosho at gmail.com>
> wrote:
> 
> > Dear All
> >
> > I have imported .img file in R using raster package
> as
> >
> >  r <- raster(inputfile)
> >
> > Summary:
> >
> > > r
> > class       : RasterLayer
> > dimensions  : 1131, 1739, 1  (nrow, ncol,
> nlayers)
> > resolution  : 1000, 1000  (x, y)
> > extent      : 535515, 2274515, 2003813,
> 3134813  (xmin, xmax, ymin, ymax)
> > projection  : +proj=aea +lat_1=28 +lat_2=12
> +lat_0=20 +lon_0=78
> > +x_0=2000000
> > +y_0=2000000 +ellps=WGS84 +datum=WGS84 +units=m
> +no_defs +towgs84=0,0,0
> > values      : H:\filename.img
> > min value   :* 0.001407638 *
> > max value   : 0.7978822
> >
> > I wanted to extract the min value and max value from
> the object. How can I
> > do this?
> > I have used the following function for this purpose
> > > cellStats(r,'min')
> > [1] 0
> >
> > But it is returning 0, not "0.001407638"
> >
> > Kindly help me.
> >
> > With regards
> > Rahul Raj
> > Indian Institute of Remote Sensing, India
> >
> >        [[alternative HTML version
> deleted]]
> >
> > _______________________________________________
> > R-sig-Geo mailing list
> > R-sig-Geo at r-project.org
> > https://stat.ethz.ch/mailman/listinfo/r-sig-geo
> >
> 
> 
> 
> -- 
> In God we trust, all others bring data.
> 
>     [[alternative HTML version deleted]]
> 
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
> 






More information about the R-sig-Geo mailing list