Skip to content

marked ppp-object

4 messages · Dorothea Lemke, Edzer Pebesma, Rolf Turner +1 more

#
Hi list,

that's probably an easy question but I couldn't get it right.
I want to coerce a SpatialPointsDataFrame to a marked ppp- object. But I don't
know how to attach the marks to the ppp-object.
str (C67mF_K)
Formal class 'SpatialPointsDataFrame' [package "sp"] with 5 slots
  ..@ data       :'data.frame': 5968 obs. of  4 variables:
  .. ..$ ID     : num [1:5968] 4336 4106 994 325 3145 ...
  .. ..$ POINT_X: num [1:5968] 2576860 2574710 2576790 2575400 2575600 ...
  .. ..$ POINT_Y: num [1:5968] 5706080 5706060 5706230 5706210 5706310 ...
  .. ..$ typ    : Factor w/ 2 levels "F","K": 2 2 2 2 2 2 2 2 2 2 ...
  ..@ coords.nrs : num(0)
  ..@ coords     : num [1:5968, 1:2] 368483 366335 368420 367030 367234 ...
  .. ..- attr(*, "dimnames")=List of 2
  .. .. ..$ : NULL
  .. .. ..$ : chr [1:2] "coords.x1" "coords.x2"
  ..@ bbox       : num [1:2, 1:2] 322028 5705358 451515 5808359
  .. ..- attr(*, "dimnames")=List of 2
  .. .. ..$ : chr [1:2] "coords.x1" "coords.x2"
  .. .. ..$ : chr [1:2] "min" "max"
  ..@ proj4string:Formal class 'CRS' [package "sp"] with 1 slots
  .. .. ..@ projargs: chr " +proj=utm +zone=32 +ellps=GRS80 +units=m +no_defs"

ppC67mF_K<-as(C67mF_K, "ppp", marks = typ)

I get the error message: unused arguments:  (marks = typ)

I would grateful for any hint.

Dorothea
#
On 10/21/2010 03:00 PM, Dorothea Lemke wrote:
Dorothea,

looking at the sources of as.ppp.SpatialPointsDataFrame, my guess is
that the following should work:

ppC67mF_K <- as(C67mF_K["typ"], "ppp")

  
    
#
On 22/10/2010, at 2:00 AM, Dorothea Lemke wrote:

            
<SNIP>

If you have created an object X which is an object of class "ppp", and
you have a vector x which you wish to be the marks of X, just do

	marks(X) <- x

The vector x should be either numeric or a factor, and should be of length
equal to the number of points in the point pattern X.

I your particular case I think that (something like)

	temp <- readOGR(".","C67mF_K)
	C67mF_K <- as(temp,"ppp")
	marks(C67mF_K) <- temp at data$typ

should work.


	cheers,

		Rolf Turner