[R] Geodata object border

Rubén Roa-Ureta rroa at udec.cl
Tue Aug 12 17:52:31 CEST 2008


imicola wrote:
> Sorry, this is probably quite an easy question, but I'm new to R and couldn't
> find the answer anywhere.
>
> I'm using geoR and geoRglm, but can't figure out how to get a border in my
> geodata object.  Does this need to be defined when I'm importing my data, or
> afterwards, and how do I go about doing this?
>
> Thanks
>   
You can define the border previously and import it to R with read.table 
or read.csv or you can define it from your geodata object in R.
In the first case don't forget to close the polygon by repeating the 
first vertex at the end of the file.
In the second case you can use a convex hull function in R, such as 
chull(), to define the polygon with your geodata object. Say your 
geodata object is called my.geo, then my.geo$coords would be the 
coordinates. Then try this,
bor <- chull(my.geo$coords)
bor <- c(bor, bor[1]) # close polygon by appending the first vertex
plot(my.geo$coords)
lines(my.geo$coords[pol,])
HTH
Ruben



More information about the R-help mailing list