[R-sig-Geo] fail to use class of "SpatialPointsDataFrame"
Edzer J. Pebesma
e.pebesma at geo.uu.nl
Thu Apr 13 09:43:49 CEST 2006
zhijie zhang wrote:
> Dear friends,
> I fail to understand and use the class of "SpatialPointsDataFrame", hope
> someone to givems some hints on it.
> For example:
> z<-rnorm(16) # this is attribute data
> coords<-cbind(x=c(1,1,1,2,2,2,3,3,3),y=c(1,2,3,1,2,3,1,2,3)) # this is
> coordinate data
> How should i use SpatialPointsDataFrame to combine them and generate my
> dataset, Thanks a lot!
>
>
>
> --
> Kind Regards,Zhi Jie,Zhang ,PHDDepartment of EpidemiologySchool of Public
> HealthFudan UniversityTel:86-21-54237149
>
> [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at stat.math.ethz.ch
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>
Try:
SpatialPointsDataFrame(coords, data.frame(z=z[1:9]))
Note that SpatialPointsDataFrame joins the spatial points (coords) and a
data.frame with attributes. The number of rows in the attribute table should
equal the number of spatial points, hence 1:9.
--
Edzer
More information about the R-sig-Geo
mailing list