An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-sig-geo/attachments/20131217/e8478f30/attachment.pl>
Create unusual data set with ppp object
2 messages · ASANTOS, Rolf Turner
2 days later
What are you actually ***trying to do***? It is completely opaque to me.
You have created a polygonal window --- "W"; that's fine.
You have create a set of 13 points. All of these points lie outside the
window W that
you have just created. (So why work with these points and this window
Makes no
sense to me.)
You wind up with an empty ppp object with an attribute of 13 rejected
(illegal)
points.
What do you want to do now?
What (on earth!) do you mean by "presence" and "absence"? Presence and
absence where?
Get your thoughts together and come back with a coherently expressed
question.
cheers,
Rolf Turner
P. S. It seems to me that your use of the coordinates() function from
"sp" is completely
spurious. Not only is it ludicrously unnecessary but it also creates an
error.
R. T.
On 18/12/13 00:13, ASANTOS wrote:
Dear Members,
I want to make a data set with 1 for presence in point location
(in xpoint and ypoint coordinates), 0 for absence of point location
(inside of window W) and NA for points outside the window for each
coordinate in my syn.ppp object of spatstat package.//I try to create a
geotif for this//, but I have some problems that involves ppp objects
and writeGDAL() function in rgdal package and I need members ideas for
make this, in my example:
require(spatstat)
require(sp)
# Two polygons
coordinates------------------------------------------------------
#Polygon 1
x.coords1<-c(371299.9, 371266.4, 371205.6, 371111.8,
371047.6, 371018.2, 371014.0,
371009.3, 370983.1, 370919.7, 370853.6,
370785.6, 370748.8, 370711.8,
370687.8, 370696.4, 370785.9, 370885.5,
371035.8, 371148.1, 371205.2,
371231.7, 371236.5, 371240.3, 371285.8,
371326.5, 371397.2, 371417.1,
371432.9, 371445.0, 371455.7, 371466.4,
371476.6, 371502.6, 371536.0,
371550.0, 371546.8, 371528.3, 371470.0,
371393.3, 371299.9, 371299.9)
y.coords1<-c(8246589, 8246560, 8246508, 8246428, 8246373,
8246349, 8246348,
8246352, 8246385, 8246465, 8246551, 8246638,
8246685, 8246732,
8246764, 8246771, 8246846, 8246932, 8247062,
8247160, 8247209,
8247230, 8247224, 8247221, 8247160, 8247107,
8247016, 8246991,
8246967, 8246939, 8246914, 8246892, 8246875,
8246846, 8246821,
8246809, 8246802, 8246785, 8246735, 8246669,
8246589, 8246589)
#Polygon 2
x.coords2<-c(368382.9, 368399.4, 368394.1, 368464.7,
368652.2, 368683.7, 368699.7,
368714.9, 368714.9, 368714.9, 368860.9,
368932.1, 368994.8, 368994.8,
369015.7, 369014.5, 369014.5, 369026.8,
369045.2, 369020.0, 368952.9,
368951.4, 368952.9, 368951.4, 368936.8,
368923.4, 368804.1, 368676.0,
368178.1, 368182.4, 368202.2, 368216.2,
368233.4, 368251.3, 368270.3,
368281.7, 368300.6, 368323.8, 368344.8,
368364.6, 368374.2, 368382.9)
y.coords2<-c(8249120, 8249150, 8249153, 8249244, 8249173,
8249167, 8249154,
8249145, 8249145, 8249145, 8249048,
8249026, 8249003, 8249003,
8248993, 8248991, 8248991, 8248984, 8248970,
8248889, 8248833,
8248829, 8248833, 8248829, 8248790, 8248765,
8248626, 8248526,
8248774, 8248780, 8248815, 8248843, 8248871,
8248903, 8248934,
8248952, 8248978, 8249013, 8249049, 8249086,
8249103, 8249120)
# Window creation
D1 <- unique(data.frame(x=rev(x.coords1),y=rev(y.coords1)))
W1 <- owin(poly=D1)
D2 <- unique(data.frame(x=rev(x.coords2),y=rev(y.coords2)))
W2 <- owin(poly=D2)
W <- union.owin(W1,W2)
plot(W)
# Create plot points inside the windows
xpoint<-c(517291.6, 517290.3, 517287.3, 517286.9, 517289.5, 517290.4,
517892.6,
517892.5, 517892.0, 517893.7, 517893.2,
517892.1, 517892.2)
ypoint<-c(7970141, 7970139, 7970141, 7970145, 7970147,
7970146, 7970641,
7970641, 7970641, 7970643, 7970643, 7970643, 7970643)
syn.ppp<-ppp(x=coordinates(xpoint),y=coordinates(ypoint),window=W)
plot(syn.ppp, main=" ")
# END