On 16/08/14 02:51, Bob O'Hara wrote:
I've been struggling for half a day on what should be a simple problem...
I have a data frame of lat/long coordinates that describe a region, and I
want to draw a polygon around them so I can use that as a boundary (to be
thrown at INLA, but those details aren't important). The coordinates are
almost on a regular grid: there is some variation in latitude (because
we're on a globe).
If the coordinates were on a regular grid, I could use as.owin() to create
a mask, and go on from there (I have code that will work). But as.owin()
doesn't like unevenly spaced points.
Can anyone suggest a way to sort this out? Preferable without having to
mess around transforming the coordinates.
You need to be able to tell owin() the vertices of the polygon that you
want to use as your window. It is possible that alphahull, as someone
suggested, might give what you want; I don't know, I am not familiar
with this function. OTOH R is still lacking a mind_read() function so
it probably would NOT give you *exactly* what you want.
If you want to get "exactly the right polygon" you probably will have to
select out the vertices of the polygon (in the appropriate order) in
some "by hand" manner. It's possible that clickpoly() might be of help
to you.
cheers,
Rolf Turner
--
Rolf Turner
Technical Editor ANZJS
______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.