[R-sig-Geo] spRbind for spplot

Klaus Vormoor kvormoor at uni-bonn.de
Wed Aug 18 11:03:46 CEST 2010


Dear Paul,

thanks for your answer. I guess, your second advice is 
pricipially that what I want. But so far it did not work. 
I try a more precise explaination:

For an area I have in total 2200 catchments (nor = 
readOGR(shp)). 100 of them have observations for five days 
(rtopObj3$observations). I am only interested in the 
attributes for one day ("QNORM_12_4"). 
rtopObj3$observations holds spatial information only for 
these 100 catchments. rtopObj3$predicions holds spatial 
information only for the remaining 2100 catchments with 
predictions (rtopObj3$predictions$var1.pred).

When I try
> plot_poly = rtopObj3$observations
> plot_poly$predictions = rtopObj3$predictions$var1.pred
> spplot(plot_poly, c("observations", "predictions"))
it does not work since the replacement has 2100 rows and 
the data has 100.

I would like to create a new object (e.g. plot_poly) which 
holds the spatial information of all catchment-polygons 
(nor) as well as the attributes of both 
observations$QNORM_12_4 and predictions$var1.pred to the 
corresponding areas. Therefore, I thought spRbind might be 
a propper solution.

I hope this is more specific and not even more 
cryptical...

Best regards,
Klaus




On Tue, 17 Aug 2010 20:21:43 +0200
  Paul Hiemstra <p.hiemstra at geo.uu.nl> wrote:
> Dear Klaus,
> 
> You need to be more specific as to what you want 
>exactly. From what I understand both your runoff and 
>predictions are attributes that you want to use to fill 
>the polygons. My first idea would be to make to plots 
>next to each other, which is quite simple in spplot:
> 
> spplot(data, c("attribute1", "attribute2"))
> 
> If your attributes are not part of the same polygons set 
>you can add one as a new attribute to the other:
> 
> plot_poly = rtopObj3$observations
> plot_poly$predictions = rtopObj3$predictions$var1.pred
> spplot(plot_poly, c("observations", "predictions"))
> 
> Is this satisfactory for you, and what do you mean by 
>one map showing both? To show the results in one figure a 
>scatterplot of observerd vs modeled is also a good idea.
> 
> regards,
> Paul
> 
> On 08/17/2010 03:06 PM, Klaus Vormoor wrote:
>> Dear all,
>>
>> I have an object (rtopObj3) including the 
>>SpatialPolygonDataFrames with
>> runoff observations ($observations, "QNORM_12_4") for 
>>100 gauged catchments
>> and with predictions ($predictions, "var1.pred") for 
>>more than ungauged
>> 2,000 catchments. So far, I only can plot either the 
>>observations or the
>> predictions individually:
>>
>>    
>>> spplot(rtopObj3$observations, "QNORM_12_4", col.regions 
>>>= bpy.colors())
>>> spplot(rtopObj3$predictions, "var1.pred", col.regions = 
>>>bpy.colors())
>>>      
>> I want to create one map showing both. I tried the 
>>sp.layout argument
>> without success. But since I also want to have both 
>>information combined for
>> writing a shp-file, it may be more reasonable to use 
>>spRbind and do the plot
>> later on. I unsuccessfully tried:
>>
>>    
>>> observation = rtopObj3$observations
>>> prediction = rtopObj3$predictions
>>> rtopObj4<- spRbind(observation, prediction)
>>>      
>> Error in rbind(deparse.level, ...) :
>>    numbers of columns of arguments do not match
>>
>> Does anyone know a way out?
>> Thanks for every advice,
>>
>> Klaus
>>    
> 
> 
> -- 
> Drs. Paul Hiemstra
> Department of Physical Geography
>Faculty of Geosciences
> University of Utrecht
> Heidelberglaan 2
> P.O. Box 80.115
> 3508 TC Utrecht
> Phone:  +3130 253 5773
> http://intamap.geo.uu.nl/~paul
> http://nl.linkedin.com/pub/paul-hiemstra/20/30b/770



More information about the R-sig-Geo mailing list