lattice, xyplot, sp, spplot: is it possible to fix maximum and minimum values in the key ?

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

lattice, xyplot, sp, spplot: is it possible to fix maximum and minimum values in the key ?

Patrick Giraudoux
Hi,

Does anybody knows if it is possible to fix user defined maximum and
minimum values in the key of a xyplot (or spplot) graphics ? I have a
set of seperate drawings and I would like to keep the same color scheme
between fixed values for all of them (which looks like being not
possible, autokey normally adapting the range of colors to the
particular range of values in each plot.

Patrick

_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Reply | Threaded
Open this post in threaded view
|

Re: lattice, xyplot, sp, spplot: is it possible to fix maximum and minimum values in the key ?

edzer


On 01/22/2011 11:18 AM, Patrick Giraudoux wrote:
> Hi,
>
> Does anybody knows if it is possible to fix user defined maximum and
> minimum values in the key of a xyplot (or spplot) graphics ? I have a
> set of seperate drawings and I would like to keep the same color scheme
> between fixed values for all of them (which looks like being not
> possible, autokey normally adapting the range of colors to the
> particular range of values in each plot.

If your object is of class SpatialPointsDataFrame, it may suffice to
pass the argument "cuts" with the vector of cuts. If it is
grid/polygons/lines, use the "at" component of the "colorkey" argument
to specify breaks; see ?levelplot in package lattice.

>
> Patrick
>
> _______________________________________________
> R-sig-Geo mailing list
> [hidden email]
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo

--
Edzer Pebesma
Institute for Geoinformatics (ifgi), University of Münster
Weseler Straße 253, 48151 Münster, Germany. Phone: +49 251
8333081, Fax: +49 251 8339763  http://ifgi.uni-muenster.de
http://www.52north.org/geostatistics      [hidden email]

_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Reply | Threaded
Open this post in threaded view
|

Problem with Kriging with in strata

zia207
Hi,
I am trying to do kriging with in strata. I  use the example in book "Applied Spatial Data Analysis with R" page:217. It works fine with "meuse" data. But when I am  trying to use my data it shows some error massage.
Do I missing something here?
Thanks in advance
Zia

 Note: I am using following codes:


coordinates(tala) <- ~ x + y
gridded(tala.grid) = ~x+y
> names(tala.grid)
[1] "lt.a"      "lt.b"      "elev"      "FDID"      "wfe_was"   "was"       "was.lt"    "elev.sqrt"
# lt.a= flooding land type 1 and lt.b=flooding land type 2

tala$lt.a <- tala.grid$lt.a[overlay(tala.grid, tala)]
> names(tala)

[1] "YID"  "FDID" "elev" "was"  "sas"  "lt.a" "lt.b"



x1 <- krige(sas ~ 1, tala[tala$lt.a == 0, ],tala.grid[tala.grid$lt.a == 0, ], model = vgm(35,"Sph", 2000, 15), nmin = 8, nmax = 40, maxdist = 1000)

Error in tala[tala$lt.a == 0, ] : NAs not permitted in row index Error in krige(sas ~ 1, tala[tala$lt.a == 0, ], tala.grid[tala.grid$lt.a ==  :
  error in evaluating the argument 'locations' in selecting a method for function 'krige'


x2<- krige(sas~1, tala[tala$lt.a == 1, ],tala.grid[tala.grid$lt.a == 1, ], model = vgm(30,"Sph", 2000), nmin = 8, nmax = 40, maxdist = 1000)

Error in tala[tala$lt.a == 1, ] : NAs not permitted in row index Error in krige(sas ~ 1, tala[tala$lt.a == 1, ], tala.grid[tala.grid$lt.a ==  :
  error in evaluating the argument 'locations' in selecting a method for function 'krige'



On 1/22/2011 4:51 PM, Edzer Pebesma wrote:

On 01/22/2011 11:18 AM, Patrick Giraudoux wrote:
Hi,

Does anybody knows if it is possible to fix user defined maximum and
minimum values in the key of a xyplot (or spplot) graphics ? I have a
set of seperate drawings and I would like to keep the same color scheme
between fixed values for all of them (which looks like being not
possible, autokey normally adapting the range of colors to the
particular range of values in each plot.
If your object is of class SpatialPointsDataFrame, it may suffice to
pass the argument "cuts" with the vector of cuts. If it is
grid/polygons/lines, use the "at" component of the "colorkey" argument
to specify breaks; see ?levelplot in package lattice.

Patrick

_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo

    

_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo

zua3.vcf (294 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Problem with Kriging with in strata

edzer
It seems your lt.a contains missing values. Try

x1 <- krige(sas ~ 1, tala[tala$lt.a == 0 & !is.na(tala$lt.a), ], etc.

On 01/26/2011 06:07 PM, Zia Ahmed wrote:

>  Hi,
> I am trying to do kriging with in strata. I  use the example in book
> "Applied Spatial Data Analysis with R" page:217. It works fine with
> "meuse" data. But when I am  trying to use my data it shows some error
> massage.
> Do I missing something here?
> Thanks in advance
> Zia
>
>  Note: I am using following codes:
>
>
> coordinates(tala) <- ~ x + y
> gridded(tala.grid) = ~x+y
>> names(tala.grid)
> [1] "lt.a"      "lt.b"      "elev"      "FDID"      "wfe_was"  
> "was"       "was.lt"    "elev.sqrt"
> # lt.a= flooding land type 1 and lt.b=flooding land type 2
>
> tala$lt.a <- tala.grid$lt.a[overlay(tala.grid, tala)]
>> names(tala)
>
> [1] "YID"  "FDID" "elev" "was"  "sas"  "lt.a" "lt.b"
>
>
> x1 <- krige(sas ~ 1, tala[tala$lt.a == 0, ],tala.grid[tala.grid$lt.a ==
> 0, ], model = vgm(35,"Sph", 2000, 15), nmin = 8, nmax = 40, maxdist = 1000)
>
> Error in tala[tala$lt.a == 0, ] : NAs not permitted in row index Error
> in krige(sas ~ 1, tala[tala$lt.a == 0, ], tala.grid[tala.grid$lt.a ==  :
>   error in evaluating the argument 'locations' in selecting a method for
> function 'krige'
>
> x2<- krige(sas~1, tala[tala$lt.a == 1, ],tala.grid[tala.grid$lt.a == 1,
> ], model = vgm(30,"Sph", 2000), nmin = 8, nmax = 40, maxdist = 1000)
>
> Error in tala[tala$lt.a == 1, ] : NAs not permitted in row index Error
> in krige(sas ~ 1, tala[tala$lt.a == 1, ], tala.grid[tala.grid$lt.a ==  :
>   error in evaluating the argument 'locations' in selecting a method for
> function 'krige'
>
>
> On 1/22/2011 4:51 PM, Edzer Pebesma wrote:
>>
>> On 01/22/2011 11:18 AM, Patrick Giraudoux wrote:
>>> Hi,
>>>
>>> Does anybody knows if it is possible to fix user defined maximum and
>>> minimum values in the key of a xyplot (or spplot) graphics ? I have a
>>> set of seperate drawings and I would like to keep the same color scheme
>>> between fixed values for all of them (which looks like being not
>>> possible, autokey normally adapting the range of colors to the
>>> particular range of values in each plot.
>> If your object is of class SpatialPointsDataFrame, it may suffice to
>> pass the argument "cuts" with the vector of cuts. If it is
>> grid/polygons/lines, use the "at" component of the "colorkey" argument
>> to specify breaks; see ?levelplot in package lattice.
>>
>>> Patrick
>>>
>>> _______________________________________________
>>> R-sig-Geo mailing list
>>> [hidden email]
>>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>

--
Edzer Pebesma
Institute for Geoinformatics (ifgi), University of Münster
Weseler Straße 253, 48151 Münster, Germany. Phone: +49 251
8333081, Fax: +49 251 8339763  http://ifgi.uni-muenster.de
http://www.52north.org/geostatistics      [hidden email]

_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo