On Mon, 4 Feb 2008, Milton Cezar Ribeiro wrote:

Dear Roger,

I am not sure if I really need to convert my polygons to psp format.

In fact I have a shapefile with polygons and a pair of points (x0,y0,x1,y1) and what I need is:
  (1) to checkout if the lines defined by (x0,y0,x1,y1) cross or not any
  polygon and (2) to identify which polygons were crossed by this line.

I obtained these (x0,y0,x1,y1) coordinates by computing the shortest
distance between all polygons pairwise. Now I need to eliminate the "lines" which cross over polygons, and keep only those lines that "link" polygons without a overlap relationship betteen lines and polygons.

If a rough-and-ready approximation is OK, start with unrolling the coordinates on the line and overlay them over the polygons:

library(maptools)
xx <- readShapePoly(system.file("shapes/sids.shp", package="maptools")[1],
  IDvar="FIPSNO", proj4string=CRS("+proj=longlat +ellps=clrk66"))
plot(xx, axes=TRUE)
pt0 <- c(-84, 34)
pt1 <- c(-77, 37)
lines(rbind(pt0, pt1))
xl <- seq(pt0[1], pt1[1], length.out=250)
yl <- seq(pt0[2], pt1[2], length.out=250)
lines(xl, yl, col="red")
SP <- SpatialPoints(cbind(xl, yl))
io <- overlay(SP, xx)
iot <- unique(na.omit(io))
plot(xx, add=TRUE, col=c("transparent", "yellow")[(1:100 %in% iot)+1])
lines(xl, yl, col="red")

gets you something, and by increasing length.out, you can get more precision.

xx$NAME[iot]

lists the names too.

Hope this helps,

Roger


I understand that it is a topological question, but I don´t know how to deal it on sp/maptools.

Case you have other ideas, please, let me know.

Regards a lot,

miltinho


----- Mensagem original ----
De: Roger Bivand <[EMAIL PROTECTED]>
Para: Milton Cezar Ribeiro <[EMAIL PROTECTED]>
Cc: r-sig-geo@stat.math.ethz.ch
Enviadas: Segunda-feira, 4 de Fevereiro de 2008 17:03:25
Assunto: Re: [R-sig-Geo] converting shapefile/polygon to psp

On Mon, 4 Feb 2008, Milton Cezar Ribeiro wrote:

Dear all,

I have some shapefiles which contents are polygons and I would like to convert it to psp (spatstat) format, and after run crossdist.psp. I tryed several times without success. Any idea?

Look at the coercion function in maptools from SpatialPolygons to owin; see what needs to be changed to match psp; debug; contribute?

Note that touching polygons fail the topology test in spatstat, as they should. Seeing how a psp works should't be hard, it is effectively as described in:

https://stat.ethz.ch/pipermail/r-sig-geo/2008-January/003075

for making the lll matrix for distppll(), but as a data frame. You could use the marks to record which Polygons/Polygon object the segments belong to.

Roger


Miltinho



para armazenamento!

    [[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


--
Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Helleveien 30, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: [EMAIL PROTECTED]


      Abra sua conta no Yahoo! Mail, o único sem limite de espaço para 
armazenamento!
http://br.mail.yahoo.com/

--
Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Helleveien 30, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: [EMAIL PROTECTED]
_______________________________________________
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