[R-sig-Geo] Newbie question: Reclassifying raster (ndvi) using fisher method

Agustin Lobo Agustin.Lobo at ija.csic.es
Sat Nov 1 12:48:32 CET 2008


I think that you should avoid importing to R the whole
raster, which is not required for classIntervals(). Just
make an stats table with r.stats -c, export the resulting table (DN,freq 
for each DN)
to R, and then either (i) make an small (subsampled) version
of the object "var" required by classIntervals (statistically,
the intervals will be the same) or
(ii) make an slight modification to the classIntervals code in
which the function would accept the stats table instead of var.

Agus

> Message: 5
> Date: Sat, 1 Nov 2008 11:47:55 +1100
> From: "Edward Tomlinson" <e.j.tommo at gmail.com>
> Subject: [R-sig-Geo] Newbie question: Reclassifying raster (ndvi)
> 	using	fisher method
> To: grass-user at lists.osgeo.org,	"r-sig-geo at stat.math.ethz.ch"
> 	<r-sig-geo at stat.math.ethz.ch>
> Message-ID:
> 	<285eec980810311747y3cb8d6a7t399b9da2a283d0af at mail.gmail.com>
> Content-Type: text/plain
> 
> Hi all,
> 
> I am not sure as to which list this best fits (Grass or R-sig-geo).
> 
> I am trying to reclass a raster map (ndvi) into 5 different zones using the
> fisher method, ultimatley i am trying to reclass as natural breaks.
> 
> The point of this exercise is for precision agriculture. I want to determine
> management zones according to the current crop, so i can use this
> information for inputs for next years crop. Therefore i have no use for a
> range of ndvi values -1 thru 1. I need to split this into a number of zones
> (5 or 7 is good number, unless i can get an algorithm to determine the exact
> number of groups it needs). Each zone then in turn needs to be ground
> truthed (hence need for classifying into 5 or 7 zones).
> 
> My problem at the moment is that the way i am doing it takes a while... I
> would sure love it if anyone has any suggestions to speed up the process...
> Is it possible to do the reclass bit in R and export the raster
> (SpatialDataFrame) back into grass? I have read a post from Roger Bivand on
> how to do the whole classinterval thing (thank you Roger) however i am
> unsure of how then to create a new image from those values. I have looked
> through the sp package breifly but I dont very well understand the R system.
> 
> 
> Current method (this has to be done for each paddock, or paddocks can be
> grouped if they have similar management history).
> 
> create ndvi
> r.mapcalc 'ndvi=1.0*(nir-red)/(nir+red)'
> move ndvi raster to R
> -R-R-R-----------------
> library(spgrass6)
> G <- gmeta6()
> ndvi <- readRAST6(ndvi at mapset)
> library(classInt)
> t1 <- classIntervals(ndvi$ndvi.mapset, n=5, style="fisher")
> print(t1)
> --------------------------------
> create text document for reclass rules, multiply everything by 10,000,000
> (as reclass will round my numbers)
> -----------------------------
> back in grass
> r.mapcalc ndvi_10M = ndvi * 10000000
> r.reclass input=ndvi_10M output=ndvi.reclass rules="rules created in text
> doc" title="title"
> 
> 
> I hope this all makes sense. Thank you for your time and reading through my
> problem. If you have any suggestions i sure would be greatful.
> 
> Kind regards,
> Ed

-- 
Dr. Agustin Lobo
Institut de Ciencies de la Terra "Jaume Almera" (CSIC)
LLuis Sole Sabaris s/n
08028 Barcelona
Spain
Tel. 34 934095410
Fax. 34 934110012
email: Agustin.Lobo at ija.csic.es
http://www.ija.csic.es/gt/obster




More information about the R-sig-Geo mailing list