distmap
I've tried (among other things):
> limit1 <- read.shape("limit_PNSN2000.shp")
Shapefile type: Polygon, (5), # of Shapes: 2
> limit1poly <- Map2poly(limit1)
> limit1owin <- as(limit1poly,"owin")
Error in .classEnv(thisClass) : unable to find an environment containing
class "polylist"
> limit2 <- readOGR("limit_PNSN2000.shp",layer="limit_PNSN2000")
OGR data source with driver: ESRI Shapefile
Source: "limit_PNSN2000.shp", layer: "limit_PNSN2000"
with 2 rows and 1 columns
> limit2poly <- Map2poly(limit1)
> limit1owin <- as(limit2poly,"owin")
Error in .classEnv(thisClass) : unable to find an environment containing
class "polylist"
> limit1owin <- as(limit2,"owin")
Error in as.owin.SpatialPolygons(from) : W must be a SpatialPolygons object
I guess all I need is to convert my shapefile (read into R via
read.shape or readOGR?) into an object like letterR:
> data(letterR)
> str(letterR)
List of 4
$ type : chr "polygonal"
$ xrange: num [1:2] 2.02 3.93
$ yrange: num [1:2] 0.645 3.278
$ bdry :List of 2
..$ :List of 2
.. ..$ x: num [1:24] 2.03 2.02 2.02 2.66 2.66 ...
.. ..$ y: num [1:24] 3.278 3.248 0.653 0.653 1.695 ...
..$ :List of 2
.. ..$ x: num [1:10] 2.65 2.64 3.04 3.12 3.16 ...
.. ..$ y: num [1:10] 2.23 2.70 2.71 2.63 2.50 ...
- attr(*, "class")= chr "owin"
but how can I do it?
Also, I'm so confused with so many spatial objects, is there a guide?
Agus
Roger Bivand escribi?:
On Fri, 22 Jun 2007, Agustin Lobo wrote:
Dear sig-geos, I have to calculate a distmap (that is, a map in which the value of each cell is the distance from the cell to a given object) for a set of polygons. It seems to me that distmap.owin in spatstat would do it fine, but distmap.owin does not accept objects imported from shp vectors via readOGR. distmap.owin requires type "polygonal" and readOGR yields class 'SpatialPolygonsDataFrame' Is there any way to cast or convert from 'SpatialPolygonsDataFrame' to "polygonal" or an alternative function to calculate the distances to the boundaries of the polygons?
Have you tried coercing with as(x, "owin") in maptools? Roger
Thanks Agus
Dr. Agustin Lobo Institut de Ciencies de la Terra "Jaume Almera" (CSIC) LLuis Sole Sabaris s/n 08028 Barcelona Spain Tel. 34 934095410 Fax. 34 934110012 email: Agustin.Lobo at ija.csic.es http://www.ija.csic.es/gt/obster