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

Johannes Radinger JRadinger at gmx.at
Tue Mar 6 17:04:46 CET 2012


Hi,

-------- Original-Nachricht --------
> Datum: Tue, 6 Mar 2012 10:53:11 -0500
> Von: Samuel Turgeon <sturgeon09 at gmail.com>
> An: Johannes Radinger <JRadinger at gmx.at>
> CC: r-sig-geo at r-project.org
> Betreff: Re: [R-sig-Geo] subset() for spatialPointsDataFrame

> 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))
> 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

thank you.. thats what I also came up so far... I was just wondering
if there is a more direct way with a spdf as I have to do several subsets and it would be nice if I don't have to do the retransformation each time.


/johannes


> 
> 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
> >

-- 

Jetzt informieren: http://mobile.1und1.de/?ac=OM.PW.PW003K20328T7073a



More information about the R-sig-Geo mailing list