moving-window analysis

11 messages Options
Embed this post
Permalink
Carlos Grohmann-2

moving-window analysis

Reply Threaded More More options
Print post
Permalink
Hello. I was thinking what would be the best way to do a moving-window
analysis where the result is the deviation of values about a best-fit
plane?

some modification to r.in.xyz?
r.mapcalc?
R? (which package, function..?)

thanks



--
+-----------------------------------------------------------+
              Carlos Henrique Grohmann - Guano
  Visiting Researcher at Kingston University London - UK
  Geologist M.Sc  - Doctorate Student at IGc-USP - Brazil
Linux User #89721  - carlos dot grohmann at gmail dot com
+-----------------------------------------------------------+
_________________
"Good morning, doctors. I have taken the liberty of removing Windows
95 from my hard drive."
--The winning entry in a "What were HAL's first words" contest judged
by 2001: A SPACE ODYSSEY creator Arthur C. Clarke

_______________________________________________
statsgrass mailing list
[hidden email]
http://grass.itc.it/mailman/listinfo/statsgrass
giohappy

Re: moving-window analysis

Reply Threaded More More options
Print post
Permalink
What kind of data do you have?

2007/6/6, Carlos Guâno Grohmann <[hidden email]>:

> Hello. I was thinking what would be the best way to do a moving-window
> analysis where the result is the deviation of values about a best-fit
> plane?
>
> some modification to r.in.xyz?
> r.mapcalc?
> R? (which package, function..?)
>
> thanks
>
>
>
> --
> +-----------------------------------------------------------+
>               Carlos Henrique Grohmann - Guano
>   Visiting Researcher at Kingston University London - UK
>   Geologist M.Sc  - Doctorate Student at IGc-USP - Brazil
> Linux User #89721  - carlos dot grohmann at gmail dot com
> +-----------------------------------------------------------+
> _________________
> "Good morning, doctors. I have taken the liberty of removing Windows
> 95 from my hard drive."
> --The winning entry in a "What were HAL's first words" contest judged
> by 2001: A SPACE ODYSSEY creator Arthur C. Clarke
>
> _______________________________________________
> statsgrass mailing list
> [hidden email]
> http://grass.itc.it/mailman/listinfo/statsgrass
>

_______________________________________________
statsgrass mailing list
[hidden email]
http://grass.itc.it/mailman/listinfo/statsgrass
Carlos Grohmann-2

Re: moving-window analysis

Reply Threaded More More options
Print post
Permalink
> What kind of data do you have?

DEMs, some LiDAR, maybe




> 2007/6/6, Carlos Guâno Grohmann <[hidden email]>:
> > Hello. I was thinking what would be the best way to do a moving-window
> > analysis where the result is the deviation of values about a best-fit
> > plane?
> >
> > some modification to r.in.xyz?
> > r.mapcalc?
> > R? (which package, function..?)
> >
> > thanks
> >
> >
> >
> > --
> > +-----------------------------------------------------------+
> >               Carlos Henrique Grohmann - Guano
> >   Visiting Researcher at Kingston University London - UK
> >   Geologist M.Sc  - Doctorate Student at IGc-USP - Brazil
> > Linux User #89721  - carlos dot grohmann at gmail dot com
> > +-----------------------------------------------------------+
> > _________________
> > "Good morning, doctors. I have taken the liberty of removing Windows
> > 95 from my hard drive."
> > --The winning entry in a "What were HAL's first words" contest judged
> > by 2001: A SPACE ODYSSEY creator Arthur C. Clarke
> >
> > _______________________________________________
> > statsgrass mailing list
> > [hidden email]
> > http://grass.itc.it/mailman/listinfo/statsgrass
> >
>


--
+-----------------------------------------------------------+
              Carlos Henrique Grohmann - Guano
  Visiting Researcher at Kingston University London - UK
  Geologist M.Sc  - Doctorate Student at IGc-USP - Brazil
Linux User #89721  - carlos dot grohmann at gmail dot com
+-----------------------------------------------------------+
_________________
"Good morning, doctors. I have taken the liberty of removing Windows
95 from my hard drive."
--The winning entry in a "What were HAL's first words" contest judged
by 2001: A SPACE ODYSSEY creator Arthur C. Clarke

_______________________________________________
statsgrass mailing list
[hidden email]
http://grass.itc.it/mailman/listinfo/statsgrass
giohappy

Re: moving-window analysis

Reply Threaded More More options
Print post
Permalink
In my experience the easier way to realize a moving-window analysys
between rasters is to use r.mapcalc. I never did it in R. I knew that
caTools package could do it someway... but I think using r.mapcla is
more straightforward.
Look at this nice article:
http://casoilresource.lawr.ucdavis.edu/drupal/node/221
--
Giovanni

2007/6/6, Carlos Guâno Grohmann <[hidden email]>:

> > What kind of data do you have?
>
> DEMs, some LiDAR, maybe
>
>
>
>
> > 2007/6/6, Carlos Guâno Grohmann <[hidden email]>:
> > > Hello. I was thinking what would be the best way to do a moving-window
> > > analysis where the result is the deviation of values about a best-fit
> > > plane?
> > >
> > > some modification to r.in.xyz?
> > > r.mapcalc?
> > > R? (which package, function..?)
> > >
> > > thanks
> > >
> > >
> > >
> > > --
> > > +-----------------------------------------------------------+
> > >               Carlos Henrique Grohmann - Guano
> > >   Visiting Researcher at Kingston University London - UK
> > >   Geologist M.Sc  - Doctorate Student at IGc-USP - Brazil
> > > Linux User #89721  - carlos dot grohmann at gmail dot com
> > > +-----------------------------------------------------------+
> > > _________________
> > > "Good morning, doctors. I have taken the liberty of removing Windows
> > > 95 from my hard drive."
> > > --The winning entry in a "What were HAL's first words" contest judged
> > > by 2001: A SPACE ODYSSEY creator Arthur C. Clarke
> > >
> > > _______________________________________________
> > > statsgrass mailing list
> > > [hidden email]
> > > http://grass.itc.it/mailman/listinfo/statsgrass
> > >
> >
>
>
> --
> +-----------------------------------------------------------+
>               Carlos Henrique Grohmann - Guano
>   Visiting Researcher at Kingston University London - UK
>   Geologist M.Sc  - Doctorate Student at IGc-USP - Brazil
> Linux User #89721  - carlos dot grohmann at gmail dot com
> +-----------------------------------------------------------+
> _________________
> "Good morning, doctors. I have taken the liberty of removing Windows
> 95 from my hard drive."
> --The winning entry in a "What were HAL's first words" contest judged
> by 2001: A SPACE ODYSSEY creator Arthur C. Clarke
>
> _______________________________________________
> statsgrass mailing list
> [hidden email]
> http://grass.itc.it/mailman/listinfo/statsgrass
>

_______________________________________________
statsgrass mailing list
[hidden email]
http://grass.itc.it/mailman/listinfo/statsgrass
Carlos Grohmann-2

Re: moving-window analysis

Reply Threaded More More options
Print post
Permalink
Basic moving-window (ie, mean, stddev etc) is easy. The tricky
question is how to make a best-fit least squares inside that moving
window? I mean that it has to be a general function, so you can choose
the size of the window.

Carlos



On 6/6/07, G. Allegri <[hidden email]> wrote:

> In my experience the easier way to realize a moving-window analysys
> between rasters is to use r.mapcalc. I never did it in R. I knew that
> caTools package could do it someway... but I think using r.mapcla is
> more straightforward.
> Look at this nice article:
> http://casoilresource.lawr.ucdavis.edu/drupal/node/221
> --
> Giovanni
>
> 2007/6/6, Carlos Guâno Grohmann <[hidden email]>:
> > > What kind of data do you have?
> >
> > DEMs, some LiDAR, maybe
> >
> >
> >
> >
> > > 2007/6/6, Carlos Guâno Grohmann <[hidden email]>:
> > > > Hello. I was thinking what would be the best way to do a moving-window
> > > > analysis where the result is the deviation of values about a best-fit
> > > > plane?
> > > >
> > > > some modification to r.in.xyz?
> > > > r.mapcalc?
> > > > R? (which package, function..?)
> > > >
> > > > thanks
> > > >
> > > >
> > > >
> > > > --
> > > > +-----------------------------------------------------------+
> > > >               Carlos Henrique Grohmann - Guano
> > > >   Visiting Researcher at Kingston University London - UK
> > > >   Geologist M.Sc  - Doctorate Student at IGc-USP - Brazil
> > > > Linux User #89721  - carlos dot grohmann at gmail dot com
> > > > +-----------------------------------------------------------+
> > > > _________________
> > > > "Good morning, doctors. I have taken the liberty of removing Windows
> > > > 95 from my hard drive."
> > > > --The winning entry in a "What were HAL's first words" contest judged
> > > > by 2001: A SPACE ODYSSEY creator Arthur C. Clarke
> > > >
> > > > _______________________________________________
> > > > statsgrass mailing list
> > > > [hidden email]
> > > > http://grass.itc.it/mailman/listinfo/statsgrass
> > > >
> > >
> >
> >
> > --
> > +-----------------------------------------------------------+
> >               Carlos Henrique Grohmann - Guano
> >   Visiting Researcher at Kingston University London - UK
> >   Geologist M.Sc  - Doctorate Student at IGc-USP - Brazil
> > Linux User #89721  - carlos dot grohmann at gmail dot com
> > +-----------------------------------------------------------+
> > _________________
> > "Good morning, doctors. I have taken the liberty of removing Windows
> > 95 from my hard drive."
> > --The winning entry in a "What were HAL's first words" contest judged
> > by 2001: A SPACE ODYSSEY creator Arthur C. Clarke
> >
> > _______________________________________________
> > statsgrass mailing list
> > [hidden email]
> > http://grass.itc.it/mailman/listinfo/statsgrass
> >
>


--
+-----------------------------------------------------------+
              Carlos Henrique Grohmann - Guano
  Visiting Researcher at Kingston University London - UK
  Geologist M.Sc  - Doctorate Student at IGc-USP - Brazil
Linux User #89721  - carlos dot grohmann at gmail dot com
+-----------------------------------------------------------+
_________________
"Good morning, doctors. I have taken the liberty of removing Windows
95 from my hard drive."
--The winning entry in a "What were HAL's first words" contest judged
by 2001: A SPACE ODYSSEY creator Arthur C. Clarke

_______________________________________________
statsgrass mailing list
[hidden email]
http://grass.itc.it/mailman/listinfo/statsgrass
Edzer J. Pebesma-2

Re: moving-window analysis

Reply Threaded More More options
Print post
Permalink
Well, package gstat provides linear regression within a local search
neighbourhood defined either by distance (circular window) or by nr of
nearest neighbours. Is that what you want?

try:

library(gstat)
data(meuse)
data(meuse.grid)
coordinates(meuse)=~x+y
gridded(meuse.grid) = ~x+y
x = krige(log(zinc)~sqrt(dist),meuse,meuse.grid,maxdist=600)
image(x)
--
Edzer

Carlos "Guâno" Grohmann wrote:

> Basic moving-window (ie, mean, stddev etc) is easy. The tricky
> question is how to make a best-fit least squares inside that moving
> window? I mean that it has to be a general function, so you can choose
> the size of the window.
>
> Carlos
>
>
>
> On 6/6/07, G. Allegri <[hidden email]> wrote:
>> In my experience the easier way to realize a moving-window analysys
>> between rasters is to use r.mapcalc. I never did it in R. I knew that
>> caTools package could do it someway... but I think using r.mapcla is
>> more straightforward.
>> Look at this nice article:
>> http://casoilresource.lawr.ucdavis.edu/drupal/node/221
>> --
>> Giovanni
>>
>> 2007/6/6, Carlos Guâno Grohmann <[hidden email]>:
>> > > What kind of data do you have?
>> >
>> > DEMs, some LiDAR, maybe
>> >
>> >
>> >
>> >
>> > > 2007/6/6, Carlos Guâno Grohmann <[hidden email]>:
>> > > > Hello. I was thinking what would be the best way to do a
>> moving-window
>> > > > analysis where the result is the deviation of values about a
>> best-fit
>> > > > plane?
>> > > >
>> > > > some modification to r.in.xyz?
>> > > > r.mapcalc?
>> > > > R? (which package, function..?)
>> > > >
>> > > > thanks
>> > > >
>> > > >
>> > > >
>> > > > --
>> > > > +-----------------------------------------------------------+
>> > > >               Carlos Henrique Grohmann - Guano
>> > > >   Visiting Researcher at Kingston University London - UK
>> > > >   Geologist M.Sc  - Doctorate Student at IGc-USP - Brazil
>> > > > Linux User #89721  - carlos dot grohmann at gmail dot com
>> > > > +-----------------------------------------------------------+
>> > > > _________________
>> > > > "Good morning, doctors. I have taken the liberty of removing
>> Windows
>> > > > 95 from my hard drive."
>> > > > --The winning entry in a "What were HAL's first words" contest
>> judged
>> > > > by 2001: A SPACE ODYSSEY creator Arthur C. Clarke
>> > > >
>> > > > _______________________________________________
>> > > > statsgrass mailing list
>> > > > [hidden email]
>> > > > http://grass.itc.it/mailman/listinfo/statsgrass
>> > > >
>> > >
>> >
>> >
>> > --
>> > +-----------------------------------------------------------+
>> >               Carlos Henrique Grohmann - Guano
>> >   Visiting Researcher at Kingston University London - UK
>> >   Geologist M.Sc  - Doctorate Student at IGc-USP - Brazil
>> > Linux User #89721  - carlos dot grohmann at gmail dot com
>> > +-----------------------------------------------------------+
>> > _________________
>> > "Good morning, doctors. I have taken the liberty of removing Windows
>> > 95 from my hard drive."
>> > --The winning entry in a "What were HAL's first words" contest judged
>> > by 2001: A SPACE ODYSSEY creator Arthur C. Clarke
>> >
>> > _______________________________________________
>> > statsgrass mailing list
>> > [hidden email]
>> > http://grass.itc.it/mailman/listinfo/statsgrass
>> >
>>
>
>

_______________________________________________
statsgrass mailing list
[hidden email]
http://grass.itc.it/mailman/listinfo/statsgrass
giohappy

Re: moving-window analysis

Reply Threaded More More options
Print post
Permalink
Sorry, I misunderstood your question. Maybe Edzer's advice could be a
good choice... if you don't need exactly a square window. In that case
you could use v.surf.idw too, setting recursively (with script) the
region to the size you need and moving it along the whole data region.
A question: you told you have a DEM as base data... what kind of
best-fit do you want to do? With point data against you're base
surface? A sort of interploetion with "trend"?

2007/6/6, Edzer J. Pebesma <[hidden email]>:

> Well, package gstat provides linear regression within a local search
> neighbourhood defined either by distance (circular window) or by nr of
> nearest neighbours. Is that what you want?
>
> try:
>
> library(gstat)
> data(meuse)
> data(meuse.grid)
> coordinates(meuse)=~x+y
> gridded(meuse.grid) = ~x+y
> x = krige(log(zinc)~sqrt(dist),meuse,meuse.grid,maxdist=600)
> image(x)
> --
> Edzer
>
> Carlos "Guâno" Grohmann wrote:
> > Basic moving-window (ie, mean, stddev etc) is easy. The tricky
> > question is how to make a best-fit least squares inside that moving
> > window? I mean that it has to be a general function, so you can choose
> > the size of the window.
> >
> > Carlos
> >
> >
> >
> > On 6/6/07, G. Allegri <[hidden email]> wrote:
> >> In my experience the easier way to realize a moving-window analysys
> >> between rasters is to use r.mapcalc. I never did it in R. I knew that
> >> caTools package could do it someway... but I think using r.mapcla is
> >> more straightforward.
> >> Look at this nice article:
> >> http://casoilresource.lawr.ucdavis.edu/drupal/node/221
> >> --
> >> Giovanni
> >>
> >> 2007/6/6, Carlos Guâno Grohmann <[hidden email]>:
> >> > > What kind of data do you have?
> >> >
> >> > DEMs, some LiDAR, maybe
> >> >
> >> >
> >> >
> >> >
> >> > > 2007/6/6, Carlos Guâno Grohmann <[hidden email]>:
> >> > > > Hello. I was thinking what would be the best way to do a
> >> moving-window
> >> > > > analysis where the result is the deviation of values about a
> >> best-fit
> >> > > > plane?
> >> > > >
> >> > > > some modification to r.in.xyz?
> >> > > > r.mapcalc?
> >> > > > R? (which package, function..?)
> >> > > >
> >> > > > thanks
> >> > > >
> >> > > >
> >> > > >
> >> > > > --
> >> > > > +-----------------------------------------------------------+
> >> > > >               Carlos Henrique Grohmann - Guano
> >> > > >   Visiting Researcher at Kingston University London - UK
> >> > > >   Geologist M.Sc  - Doctorate Student at IGc-USP - Brazil
> >> > > > Linux User #89721  - carlos dot grohmann at gmail dot com
> >> > > > +-----------------------------------------------------------+
> >> > > > _________________
> >> > > > "Good morning, doctors. I have taken the liberty of removing
> >> Windows
> >> > > > 95 from my hard drive."
> >> > > > --The winning entry in a "What were HAL's first words" contest
> >> judged
> >> > > > by 2001: A SPACE ODYSSEY creator Arthur C. Clarke
> >> > > >
> >> > > > _______________________________________________
> >> > > > statsgrass mailing list
> >> > > > [hidden email]
> >> > > > http://grass.itc.it/mailman/listinfo/statsgrass
> >> > > >
> >> > >
> >> >
> >> >
> >> > --
> >> > +-----------------------------------------------------------+
> >> >               Carlos Henrique Grohmann - Guano
> >> >   Visiting Researcher at Kingston University London - UK
> >> >   Geologist M.Sc  - Doctorate Student at IGc-USP - Brazil
> >> > Linux User #89721  - carlos dot grohmann at gmail dot com
> >> > +-----------------------------------------------------------+
> >> > _________________
> >> > "Good morning, doctors. I have taken the liberty of removing Windows
> >> > 95 from my hard drive."
> >> > --The winning entry in a "What were HAL's first words" contest judged
> >> > by 2001: A SPACE ODYSSEY creator Arthur C. Clarke
> >> >
> >> > _______________________________________________
> >> > statsgrass mailing list
> >> > [hidden email]
> >> > http://grass.itc.it/mailman/listinfo/statsgrass
> >> >
> >>
> >
> >
>
> _______________________________________________
> statsgrass mailing list
> [hidden email]
> http://grass.itc.it/mailman/listinfo/statsgrass
>

_______________________________________________
statsgrass mailing list
[hidden email]
http://grass.itc.it/mailman/listinfo/statsgrass
Carlos Grohmann-2

Re: moving-window analysis

Reply Threaded More More options
Print post
Permalink
In reply to this post by Edzer J. Pebesma-2
I guess it's something like that. this is what I did:

after importing a DEM from GRASS, creating a mask etc:

x <- krige(S25W049 ~ 1, locations=srtm, newdata=mask, nmax=24)

> summary(x)
Object of class SpatialPixelsDataFrame
Coordinates:
       min     max
s1  719500  776650
s2 7260800 7300400
Is projected: TRUE
proj4string :
[+proj=utm +south +zone=22 +a=6378160 +rf=298.25 +no_defs
+towgs84=-60.0,-2.0,-41.0 +to_meter=1.0]
Number of points: 279400
Data attributes:
   var1.pred          var1.var
 Min.   :  33.73   Min.   :    NA
 1st Qu.: 236.77   1st Qu.:    NA
 Median : 434.94   Median :    NA
 Mean   : 471.73   Mean   :   NaN
 3rd Qu.: 685.39   3rd Qu.:    NA
 Max.   :1186.84   Max.   :    NA
                   NA's   :279400


So I have the var1.pred, which is basically my original DEM, and
var1.var is all NA's..

What I want, is that the pixel final value to be equal to the
deviation of that pixel original value about the best-fit plane
calculated over the points in the moving window (8, 24..).


thanks



On 6/6/07, Edzer J. Pebesma <[hidden email]> wrote:

> Well, package gstat provides linear regression within a local search
> neighbourhood defined either by distance (circular window) or by nr of
> nearest neighbours. Is that what you want?
>
> try:
>
> library(gstat)
> data(meuse)
> data(meuse.grid)
> coordinates(meuse)=~x+y
> gridded(meuse.grid) = ~x+y
> x = krige(log(zinc)~sqrt(dist),meuse,meuse.grid,maxdist=600)
> image(x)
> --
> Edzer
>
> Carlos "Guâno" Grohmann wrote:
> > Basic moving-window (ie, mean, stddev etc) is easy. The tricky
> > question is how to make a best-fit least squares inside that moving
> > window? I mean that it has to be a general function, so you can choose
> > the size of the window.
> >
> > Carlos
> >
> >
> >
> > On 6/6/07, G. Allegri <[hidden email]> wrote:
> >> In my experience the easier way to realize a moving-window analysys
> >> between rasters is to use r.mapcalc. I never did it in R. I knew that
> >> caTools package could do it someway... but I think using r.mapcla is
> >> more straightforward.
> >> Look at this nice article:
> >> http://casoilresource.lawr.ucdavis.edu/drupal/node/221
> >> --
> >> Giovanni
> >>
> >> 2007/6/6, Carlos Guâno Grohmann <[hidden email]>:
> >> > > What kind of data do you have?
> >> >
> >> > DEMs, some LiDAR, maybe
> >> >
> >> >
> >> >
> >> >
> >> > > 2007/6/6, Carlos Guâno Grohmann <[hidden email]>:
> >> > > > Hello. I was thinking what would be the best way to do a
> >> moving-window
> >> > > > analysis where the result is the deviation of values about a
> >> best-fit
> >> > > > plane?
> >> > > >
> >> > > > some modification to r.in.xyz?
> >> > > > r.mapcalc?
> >> > > > R? (which package, function..?)
> >> > > >
> >> > > > thanks
> >> > > >
> >> > > >
> >> > > >
> >> > > > --
> >> > > > +-----------------------------------------------------------+
> >> > > >               Carlos Henrique Grohmann - Guano
> >> > > >   Visiting Researcher at Kingston University London - UK
> >> > > >   Geologist M.Sc  - Doctorate Student at IGc-USP - Brazil
> >> > > > Linux User #89721  - carlos dot grohmann at gmail dot com
> >> > > > +-----------------------------------------------------------+
> >> > > > _________________
> >> > > > "Good morning, doctors. I have taken the liberty of removing
> >> Windows
> >> > > > 95 from my hard drive."
> >> > > > --The winning entry in a "What were HAL's first words" contest
> >> judged
> >> > > > by 2001: A SPACE ODYSSEY creator Arthur C. Clarke
> >> > > >
> >> > > > _______________________________________________
> >> > > > statsgrass mailing list
> >> > > > [hidden email]
> >> > > > http://grass.itc.it/mailman/listinfo/statsgrass
> >> > > >
> >> > >
> >> >
> >> >
> >> > --
> >> > +-----------------------------------------------------------+
> >> >               Carlos Henrique Grohmann - Guano
> >> >   Visiting Researcher at Kingston University London - UK
> >> >   Geologist M.Sc  - Doctorate Student at IGc-USP - Brazil
> >> > Linux User #89721  - carlos dot grohmann at gmail dot com
> >> > +-----------------------------------------------------------+
> >> > _________________
> >> > "Good morning, doctors. I have taken the liberty of removing Windows
> >> > 95 from my hard drive."
> >> > --The winning entry in a "What were HAL's first words" contest judged
> >> > by 2001: A SPACE ODYSSEY creator Arthur C. Clarke
> >> >
> >> > _______________________________________________
> >> > statsgrass mailing list
> >> > [hidden email]
> >> > http://grass.itc.it/mailman/listinfo/statsgrass
> >> >
> >>
> >
> >
>
>


--
+-----------------------------------------------------------+
              Carlos Henrique Grohmann - Guano
  Visiting Researcher at Kingston University London - UK
  Geologist M.Sc  - Doctorate Student at IGc-USP - Brazil
Linux User #89721  - carlos dot grohmann at gmail dot com
+-----------------------------------------------------------+
_________________
"Good morning, doctors. I have taken the liberty of removing Windows
95 from my hard drive."
--The winning entry in a "What were HAL's first words" contest judged
by 2001: A SPACE ODYSSEY creator Arthur C. Clarke

_______________________________________________
statsgrass mailing list
[hidden email]
http://grass.itc.it/mailman/listinfo/statsgrass
Edzer J. Pebesma-2

Re: moving-window analysis

Reply Threaded More More options
Print post
Permalink
If you mean by plane a first order linear trend surface, you'd have to
use S25W049~s1+s2, or something like that. locations and newdata can be
the same object, if needed.
--
Edzer

Carlos "Guâno" Grohmann wrote:

> I guess it's something like that. this is what I did:
>
> after importing a DEM from GRASS, creating a mask etc:
>
> x <- krige(S25W049 ~ 1, locations=srtm, newdata=mask, nmax=24)
>
>> summary(x)
> Object of class SpatialPixelsDataFrame
> Coordinates:
>       min     max
> s1  719500  776650
> s2 7260800 7300400
> Is projected: TRUE
> proj4string :
> [+proj=utm +south +zone=22 +a=6378160 +rf=298.25 +no_defs
> +towgs84=-60.0,-2.0,-41.0 +to_meter=1.0]
> Number of points: 279400
> Data attributes:
>   var1.pred          var1.var
> Min.   :  33.73   Min.   :    NA
> 1st Qu.: 236.77   1st Qu.:    NA
> Median : 434.94   Median :    NA
> Mean   : 471.73   Mean   :   NaN
> 3rd Qu.: 685.39   3rd Qu.:    NA
> Max.   :1186.84   Max.   :    NA
>                   NA's   :279400
>
>
> So I have the var1.pred, which is basically my original DEM, and
> var1.var is all NA's..
>
> What I want, is that the pixel final value to be equal to the
> deviation of that pixel original value about the best-fit plane
> calculated over the points in the moving window (8, 24..).
>
>
> thanks
>
>
>
> On 6/6/07, Edzer J. Pebesma <[hidden email]> wrote:
>> Well, package gstat provides linear regression within a local search
>> neighbourhood defined either by distance (circular window) or by nr of
>> nearest neighbours. Is that what you want?
>>
>> try:
>>
>> library(gstat)
>> data(meuse)
>> data(meuse.grid)
>> coordinates(meuse)=~x+y
>> gridded(meuse.grid) = ~x+y
>> x = krige(log(zinc)~sqrt(dist),meuse,meuse.grid,maxdist=600)
>> image(x)
>> --
>> Edzer
>>
>> Carlos "Guâno" Grohmann wrote:
>> > Basic moving-window (ie, mean, stddev etc) is easy. The tricky
>> > question is how to make a best-fit least squares inside that moving
>> > window? I mean that it has to be a general function, so you can choose
>> > the size of the window.
>> >
>> > Carlos
>> >
>> >
>> >
>> > On 6/6/07, G. Allegri <[hidden email]> wrote:
>> >> In my experience the easier way to realize a moving-window analysys
>> >> between rasters is to use r.mapcalc. I never did it in R. I knew that
>> >> caTools package could do it someway... but I think using r.mapcla is
>> >> more straightforward.
>> >> Look at this nice article:
>> >> http://casoilresource.lawr.ucdavis.edu/drupal/node/221
>> >> --
>> >> Giovanni
>> >>
>> >> 2007/6/6, Carlos Guâno Grohmann <[hidden email]>:
>> >> > > What kind of data do you have?
>> >> >
>> >> > DEMs, some LiDAR, maybe
>> >> >
>> >> >
>> >> >
>> >> >
>> >> > > 2007/6/6, Carlos Guâno Grohmann <[hidden email]>:
>> >> > > > Hello. I was thinking what would be the best way to do a
>> >> moving-window
>> >> > > > analysis where the result is the deviation of values about a
>> >> best-fit
>> >> > > > plane?
>> >> > > >
>> >> > > > some modification to r.in.xyz?
>> >> > > > r.mapcalc?
>> >> > > > R? (which package, function..?)
>> >> > > >
>> >> > > > thanks
>> >> > > >
>> >> > > >
>> >> > > >
>> >> > > > --
>> >> > > > +-----------------------------------------------------------+
>> >> > > >               Carlos Henrique Grohmann - Guano
>> >> > > >   Visiting Researcher at Kingston University London - UK
>> >> > > >   Geologist M.Sc  - Doctorate Student at IGc-USP - Brazil
>> >> > > > Linux User #89721  - carlos dot grohmann at gmail dot com
>> >> > > > +-----------------------------------------------------------+
>> >> > > > _________________
>> >> > > > "Good morning, doctors. I have taken the liberty of removing
>> >> Windows
>> >> > > > 95 from my hard drive."
>> >> > > > --The winning entry in a "What were HAL's first words" contest
>> >> judged
>> >> > > > by 2001: A SPACE ODYSSEY creator Arthur C. Clarke
>> >> > > >
>> >> > > > _______________________________________________
>> >> > > > statsgrass mailing list
>> >> > > > [hidden email]
>> >> > > > http://grass.itc.it/mailman/listinfo/statsgrass
>> >> > > >
>> >> > >
>> >> >
>> >> >
>> >> > --
>> >> > +-----------------------------------------------------------+
>> >> >               Carlos Henrique Grohmann - Guano
>> >> >   Visiting Researcher at Kingston University London - UK
>> >> >   Geologist M.Sc  - Doctorate Student at IGc-USP - Brazil
>> >> > Linux User #89721  - carlos dot grohmann at gmail dot com
>> >> > +-----------------------------------------------------------+
>> >> > _________________
>> >> > "Good morning, doctors. I have taken the liberty of removing
>> Windows
>> >> > 95 from my hard drive."
>> >> > --The winning entry in a "What were HAL's first words" contest
>> judged
>> >> > by 2001: A SPACE ODYSSEY creator Arthur C. Clarke
>> >> >
>> >> > _______________________________________________
>> >> > statsgrass mailing list
>> >> > [hidden email]
>> >> > http://grass.itc.it/mailman/listinfo/statsgrass
>> >> >
>> >>
>> >
>> >
>>
>>
>
>

_______________________________________________
statsgrass mailing list
[hidden email]
http://grass.itc.it/mailman/listinfo/statsgrass
Carlos Grohmann-2

Re: moving-window analysis

Reply Threaded More More options
Print post
Permalink
Thanks Edzer. I guess that did it
(my problem was with the ~s1+s2, I even tried ~x+y...)

thanks

Carlos

On 6/6/07, Edzer J. Pebesma <[hidden email]> wrote:

> If you mean by plane a first order linear trend surface, you'd have to
> use S25W049~s1+s2, or something like that. locations and newdata can be
> the same object, if needed.
> --
> Edzer
>
> Carlos "Guâno" Grohmann wrote:
> > I guess it's something like that. this is what I did:
> >
> > after importing a DEM from GRASS, creating a mask etc:
> >
> > x <- krige(S25W049 ~ 1, locations=srtm, newdata=mask, nmax=24)
> >
> >> summary(x)
> > Object of class SpatialPixelsDataFrame
> > Coordinates:
> >       min     max
> > s1  719500  776650
> > s2 7260800 7300400
> > Is projected: TRUE
> > proj4string :
> > [+proj=utm +south +zone=22 +a=6378160 +rf=298.25 +no_defs
> > +towgs84=-60.0,-2.0,-41.0 +to_meter=1.0]
> > Number of points: 279400
> > Data attributes:
> >   var1.pred          var1.var
> > Min.   :  33.73   Min.   :    NA
> > 1st Qu.: 236.77   1st Qu.:    NA
> > Median : 434.94   Median :    NA
> > Mean   : 471.73   Mean   :   NaN
> > 3rd Qu.: 685.39   3rd Qu.:    NA
> > Max.   :1186.84   Max.   :    NA
> >                   NA's   :279400
> >
> >
> > So I have the var1.pred, which is basically my original DEM, and
> > var1.var is all NA's..
> >
> > What I want, is that the pixel final value to be equal to the
> > deviation of that pixel original value about the best-fit plane
> > calculated over the points in the moving window (8, 24..).
> >
> >
> > thanks
> >
> >
> >
> > On 6/6/07, Edzer J. Pebesma <[hidden email]> wrote:
> >> Well, package gstat provides linear regression within a local search
> >> neighbourhood defined either by distance (circular window) or by nr of
> >> nearest neighbours. Is that what you want?
> >>
> >> try:
> >>
> >> library(gstat)
> >> data(meuse)
> >> data(meuse.grid)
> >> coordinates(meuse)=~x+y
> >> gridded(meuse.grid) = ~x+y
> >> x = krige(log(zinc)~sqrt(dist),meuse,meuse.grid,maxdist=600)
> >> image(x)
> >> --
> >> Edzer
> >>
> >> Carlos "Guâno" Grohmann wrote:
> >> > Basic moving-window (ie, mean, stddev etc) is easy. The tricky
> >> > question is how to make a best-fit least squares inside that moving
> >> > window? I mean that it has to be a general function, so you can choose
> >> > the size of the window.
> >> >
> >> > Carlos
> >> >
> >> >
> >> >
> >> > On 6/6/07, G. Allegri <[hidden email]> wrote:
> >> >> In my experience the easier way to realize a moving-window analysys
> >> >> between rasters is to use r.mapcalc. I never did it in R. I knew that
> >> >> caTools package could do it someway... but I think using r.mapcla is
> >> >> more straightforward.
> >> >> Look at this nice article:
> >> >> http://casoilresource.lawr.ucdavis.edu/drupal/node/221
> >> >> --
> >> >> Giovanni
> >> >>
> >> >> 2007/6/6, Carlos Guâno Grohmann <[hidden email]>:
> >> >> > > What kind of data do you have?
> >> >> >
> >> >> > DEMs, some LiDAR, maybe
> >> >> >
> >> >> >
> >> >> >
> >> >> >
> >> >> > > 2007/6/6, Carlos Guâno Grohmann <[hidden email]>:
> >> >> > > > Hello. I was thinking what would be the best way to do a
> >> >> moving-window
> >> >> > > > analysis where the result is the deviation of values about a
> >> >> best-fit
> >> >> > > > plane?
> >> >> > > >
> >> >> > > > some modification to r.in.xyz?
> >> >> > > > r.mapcalc?
> >> >> > > > R? (which package, function..?)
> >> >> > > >
> >> >> > > > thanks
> >> >> > > >
> >> >> > > >
> >> >> > > >
> >> >> > > > --
> >> >> > > > +-----------------------------------------------------------+
> >> >> > > >               Carlos Henrique Grohmann - Guano
> >> >> > > >   Visiting Researcher at Kingston University London - UK
> >> >> > > >   Geologist M.Sc  - Doctorate Student at IGc-USP - Brazil
> >> >> > > > Linux User #89721  - carlos dot grohmann at gmail dot com
> >> >> > > > +-----------------------------------------------------------+
> >> >> > > > _________________
> >> >> > > > "Good morning, doctors. I have taken the liberty of removing
> >> >> Windows
> >> >> > > > 95 from my hard drive."
> >> >> > > > --The winning entry in a "What were HAL's first words" contest
> >> >> judged
> >> >> > > > by 2001: A SPACE ODYSSEY creator Arthur C. Clarke
> >> >> > > >
> >> >> > > > _______________________________________________
> >> >> > > > statsgrass mailing list
> >> >> > > > [hidden email]
> >> >> > > > http://grass.itc.it/mailman/listinfo/statsgrass
> >> >> > > >
> >> >> > >
> >> >> >
> >> >> >
> >> >> > --
> >> >> > +-----------------------------------------------------------+
> >> >> >               Carlos Henrique Grohmann - Guano
> >> >> >   Visiting Researcher at Kingston University London - UK
> >> >> >   Geologist M.Sc  - Doctorate Student at IGc-USP - Brazil
> >> >> > Linux User #89721  - carlos dot grohmann at gmail dot com
> >> >> > +-----------------------------------------------------------+
> >> >> > _________________
> >> >> > "Good morning, doctors. I have taken the liberty of removing
> >> Windows
> >> >> > 95 from my hard drive."
> >> >> > --The winning entry in a "What were HAL's first words" contest
> >> judged
> >> >> > by 2001: A SPACE ODYSSEY creator Arthur C. Clarke
> >> >> >
> >> >> > _______________________________________________
> >> >> > statsgrass mailing list
> >> >> > [hidden email]
> >> >> > http://grass.itc.it/mailman/listinfo/statsgrass
> >> >> >
> >> >>
> >> >
> >> >
> >>
> >>
> >
> >
>
>


--
+-----------------------------------------------------------+
              Carlos Henrique Grohmann - Guano
  Visiting Researcher at Kingston University London - UK
  Geologist M.Sc  - Doctorate Student at IGc-USP - Brazil
Linux User #89721  - carlos dot grohmann at gmail dot com
+-----------------------------------------------------------+
_________________
"Good morning, doctors. I have taken the liberty of removing Windows
95 from my hard drive."
--The winning entry in a "What were HAL's first words" contest judged
by 2001: A SPACE ODYSSEY creator Arthur C. Clarke

_______________________________________________
statsgrass mailing list
[hidden email]
http://grass.itc.it/mailman/listinfo/statsgrass
HamishB

Re: moving-window analysis

Reply Threaded More More options
Print post
Permalink
In reply to this post by Carlos Grohmann-2
Carlos wrote:
>
> Basic moving-window (ie, mean, stddev etc) is easy. The tricky
> question is how to make a best-fit least squares inside that moving
> window? I mean that it has to be a general function, so you can choose
> the size of the window.

just for simple stuff, but within GRASS, you could look at r.neighbors
and r.mfilter.

perhaps you could write a new method to use with r.neighbors?


or use r.mapcalc/r.series to create a map containing the difference
between the original and the r.neighbors smoothed version?


Hamish

_______________________________________________
statsgrass mailing list
[hidden email]
http://grass.itc.it/mailman/listinfo/statsgrass