Freddy,

You can also try the getpoly() function from the splancs package as a more
flexible way to do it.

library(sp)
library(splancs)

plot(meuse$x,meuse$y,type='p',pch='+')
bound <- getpoly()
bound <- rbind(bound,bound[1,]) # Closes the polygon coordinates
bound.bis.poly <- Polygon(bound.bis) # Creates a spatial polygon
class(bound.bis.poly)

In case anybody would be interested, I've slightly modified the getpoly()
function to have the choice of the width and colour of the polygon lines
when drawing the border, as I didn't get how to pass those options to the
getpoly() function:

my.getpoly <- function(
quiet = FALSE, # Verbose option
col='red', # Colour of the lines
lwd=2 # Width of the lines
){
  require(splancs)
  if (!quiet) {
    cat(" - Enter field boundary points with mouse button 1\n")
    cat(" - Finish with mouse button 2\n")
    cat(" - Don't try to join the polygon up, it is done for you.\n\n")
  }
  raw <- locator(type='l',col=col,lwd=lwd)
  resloc <- cbind(raw$x,raw$y)
  lines(c(raw$x[1], raw$x[length(raw$x)]), c(raw$y[1],
raw$y[length(raw$y)]))
  resloc
}

Hope it helps,

Pierre

2009/10/2 Henrique Dallazuanna <www...@gmail.com>

> Try the chull function to create a border.
>
>
> On Thu, Oct 1, 2009 at 12:39 AM, Freddy López <freddy.vat...@gmail.com>
> wrote:
> > Hello folks,
> >
> > I'm working with geostatistics data and I'm using mainly geoR library.
> > Now, in some examples, is useful to use the 'borders' to delimitate
> > our kriging process, e.g., in the krige.conv() function. To steal a
> > Ribeiro & Diggle's example
> > (http://leg.ufpr.br/geoR/tutorials/aula050819.R), we have some lines
> > such as
> >
> >
> >>Ksat.in <- krige.conv(Ksat, loc=grid0, borders=Ksat$borders,krige=
> > krige.control(obj=Ksat.ef))
> >>image(Ksat.in, col=gray(seq(1, 0.1, l=21)))
> >
> >
> > in which is nice to have Ksat$borders because we can have our
> > prediction inside of these borders (and it looks better).
> >
> > Now, suppose we have an object of the class geodata but it has not got
> > borders.
> >
> > We can visualisate I'm saying with a little modification of latter
> example
> >
> >
> >> Ksat.in <- krige.conv(coords=Ksat$coords,data=Ksat$data,
> > loc=grid0,krige=krige.control(obj=Ksat.ef))
> >> image(Ksat.in, col=gray(seq(1, 0.1, l=21)))
> >
> >
> > which looks as an rectangle with no reference to something.
> >
> > That's my problem: I have an object of the class geodata (indeed, is a
> > worked shapefile, because I'm treating with counties) and I have done
> > all good up to the kriging stage because I don't know how to extract
> > or create borders. I mean, I can get a rectangular kriging, but it is
> > not the aim.
> >
> > Again, excuse my clumsy english.
> >
> > Thanks.
> >
> >
> > --
> > 'qué importa la tristeza si hubo en el tiempo
> > alguien que se dijo feliz,'
> >
> > JL Borges
> >
> >        [[alternative HTML version deleted]]
> >
> >
> > _______________________________________________
> > R-sig-Geo mailing list
> > R-sig-Geo@stat.math.ethz.ch
> > https://stat.ethz.ch/mailman/listinfo/r-sig-geo
> >
> >
>
>
>
> --
> Henrique Dallazuanna
> Curitiba-Paraná-Brasil
> 25° 25' 40" S 49° 16' 22" O
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo@stat.math.ethz.ch
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>

        [[alternative HTML version deleted]]

_______________________________________________
R-sig-Geo mailing list
R-sig-Geo@stat.math.ethz.ch
https://stat.ethz.ch/mailman/listinfo/r-sig-geo

Reply via email to