logo       

Re: GSTAT: msg#00050

lang.r.geo

Subject: Re: GSTAT

karl.sommer@xxxxxxxxxxxxxx wrote:
> Hello list
>
> In the gstat R package tutorial that accompanies the latest version of
> GSTAT 0.9-29 it is pointed out that the function coordinates, when assigned
> (on the left-hand side of an = or <- sign) promotes the data.frame meuse
> into a SpatialPointsDataFrame. Is there a function that does the opposite
> ie. demote the same data set from SpatialPointsDataFrame back to a
> data.frame?
>
The inverse is to use as.data.frame, which has a methods for
SpatialPointsDataFrame, and restores the coordinates as they were
originally stored, and returns a normal data.frame:

data(meuse)
coordinates(meuse) <- c("x", "y")
## coordinates(meuse) <- ~x+y ## another way

names(meuse) ## x, y now treated as intrinsic data, rather than attributes

## now replace meuse with data.frame version

meuse <- as.data.frame(meuse)

names(meuse)


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise