[R-sig-Geo] subset() for spatialPointsDataFrame

Tom Gottfried tom.gottfried at tum.de
Tue Mar 6 17:21:19 CET 2012


Am 06.03.2012 16:53, schrieb Samuel Turgeon:
> Hi Johannes,
>
> did you transform your SpatialPointsDataFrame to a regular data.frame?
>
> point.df=data.frame(point.spdf)
> subset(points.df, points.df[,"value"]>  0 , select = c(1, 2))

Indexing with the correct number of dimensions as done here (in contrast 
to Johannes' original command) should work well also with a 
SpatialPointsDataFrame.

And Johannes: Might I remind you that you asked almost the same question 
a few weeks ago 
(https://stat.ethz.ch/pipermail/r-sig-geo/2012-February/014111.html)? 
You might read this (and I would like to emphasize the second paragraph 
here):
http://www.r-project.org/posting-guide.html

Regards,
Tom

> coordinates(points.df) = ~X + Y ##You should keep those columns (X,Y) in
> the subset command in order to backtransform the dataframe in a
> SpatialPointsDataFrame
> points.spdf=point.df
>
> hope this helps
>
> Sam
>
> On Tue, Mar 6, 2012 at 10:09 AM, Johannes Radinger<JRadinger at gmx.at>  wrote:
>
>> Hi,
>>
>> I just wanted to know how I have to use the
>> subset() command for a SpatialPointsDataFrame correctly.
>>
>> I'd like to get all records of the SpatialPointsDataFrame where the column
>> "value" is>  0. Furthermore I want to select only two columns of that
>> dataframe with these records. The subset command would be:
>>
>> subset(points.df, value>  0 , select = c(column1, column2))
>>
>> When I do that I get following error:
>>
>> Error in subset.SpatialPointsDataFrame(points.df, value>  0, select =
>> c(column1,  :
>>   Object 'value' not found
>>
>> I also tried:
>> subset(points.df, points.df["value"]>  0 , select = c(column1, column2))
>>
>> Error in points.df["value"]>  0 :
>>   Vergleich (6) ist nur f"ur atomare und Listentypen m"oglich (sorry is in
>> German)...
>>
>> Best regards,
>> Johannes
>>
>> --
>>
>> Jetzt informieren: http://mobile.1und1.de/?ac=OM.PW.PW003K20328T7073a
>>
>> _______________________________________________
>> R-sig-Geo mailing list
>> R-sig-Geo at r-project.org
>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>>
>
> 	[[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

-- 
Technische Universität München
Department für Pflanzenwissenschaften
Lehrstuhl für Grünlandlehre
Alte Akademie 12
85350 Freising / Germany
Phone: ++49 (0)8161 715324
Fax:   ++49 (0)8161 713243
email: tom.gottfried at wzw.tum.de
http://www.wzw.tum.de/gruenland



More information about the R-sig-Geo mailing list