
Maybe this could be a solution (to the "compute 
the distance from each of my points to the nearest "ocean coastline" demand)

First, I understand that except for islands 
"coastline" is a line, so instead of using 
coastline as a window, use the coastline as a line segment pattern.
Then compute the distance from your points to the 
nearest segment with nncross. See this example:


# Example coast
 >library(maps)
 >norway = map("world", "Norway", exact = TRUE)
 >coastx <- norway$x[c(33:48,50:101, 103:158, 160:220, 222:274, 276:334)]
 >coasty <- norway$y[c(33:48,50:101, 103:158, 160:220, 222:274, 276:334)]
 > length(coastx)
[1] 297


# convert the line coast in a psp: set x0 and y0 
as the original coordinates except the last one; 
set x1 and y1 as the original coordinates except the first one
 > norwaycoast.psp <-psp(x0= coastx[-297], y0= coasty[-297],
+     x1= coastx[-1], y1= coasty[-1],
+    window = owin(xrange=norway$range[1:2], yrange=norway$range[3:4]))

 > plot(norwaycoast.psp)

# Example points
 >example.points <- data.frame(x=c(7.6, 8.4, 9.5, 
10.8, 13.5, 23.9, 26.08), y = c(59.5, 61.07, 62.4, 61.8, 65.3, 69.7, 70.1))
 >example.points.ppp <- ppp(example.points$x, 
example.points$y, window=norwaycoast.psp$window)
 >plot(example.points.ppp, add=T)
 > (dpoints=nncross(example.points.ppp, norwaycoast.psp))
        dist which
1 1.1095023   278
2 0.9491848   257
3 0.9836449   206
4 1.6412210   201
5 0.7077807   174
6 0.5584948    56
7 0.5102774    37
 > plot(norwaycoast.psp[dpoints$which], col="red", add=T)
 > plot(norwaycoast.psp[dpoints$which], col="red", add=T,lwd=2)

If you have computational "troubles" because an 
excess of coast segments, you could compute the 
distances in subsets of the psp and ppp patterns


HTH,

Marcelino








At 15:24 04/10/2012, sara martino wrote:
>Content-Type: text/plain
>Content-Disposition: inline
>Content-length: 1903
>
>yes dropping points was my first solution. But 
>there are quite  a number along the cost...
>
>what i want at the end is to compute the 
>distance from each of my points to the nearest "ocean coastline",
>and my solution was to get a simplified coast 
>line and compute the distance from that using bdist.points().
>Maybe someone has a better suggestion on  another way to do this
>
>
>________________________________
>  Da: Barry Rowlingson <b.rowlingson@lancaster.ac.uk>
>A: "r-sig-geo@r-project.org" <r-sig-geo@r-project.org>
>Inviato: Giovedė 4 Ottobre 2012 15:16
>Oggetto: Re: [R-sig-Geo] simplify a polygon window
>
>
> > Hi,
> >
> > I am working with a point pattern whose 
> window is a spatial polygon which describe the cost of Norway.
> >
> > I need to get a smoother version of such 
> polygon which wraps the original one.
>
>You mean 'coast' of Norway? You want to undo all Slartibartfast's good
>[[elided Yahoo spam]]
>
>http://en.wikipedia.org/wiki/Slartibartfast
>
> > I have tried to use the function
> >
> >> simplify.owin(my.owin,80000)
> > but this does not work since some parts of 
> the original polygon will lay outside the simplified one.
> >
> > Does anyone know how to do that?
>
>You could use the buffering functions in rgeos to expand the area
>slightly - but that might end up making the polygon more complex
>again.
>
>You could possibly also use an alpha-shape instead of whatever
>polygon you have:
>
>http://procomun.wordpress.com/2011/04/07/alpha-shapes-with-lattice/
>
>but at that point you are probably throwing away the concept that the
>polygon is the window in which your process occurs. In which case your
>analysis becomes problematic.
>
>Are you losing points after the simplification? You could just drop them.
>
>_______________________________________________
>R-sig-Geo mailing list
>R-sig-Geo@r-project.org
>https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>         [[alternative HTML version deleted]]
>
>
>_______________________________________________
>R-sig-Geo mailing list
>R-sig-Geo@r-project.org
>https://stat.ethz.ch/mailman/listinfo/r-sig-geo

	[[alternative HTML version deleted]]

