Skip to content
Prev 17714 / 29559 Next

random spatial distribution code / shapefiles with more than one polygon

Hi Marcelino,

I think what I would like to do is convert the shapefile comprised of multiple polygons into a single object of class owin.
However, when I use the code as(NYCBorough, "owin")
I get the following error:
Error in owin(poly = opls): Polygon data contain overlaps between polygons.

Is there a way to get around this?

Regarding the miles part, I need to convert both to miles for a calculation that comes later on in my code.

Thanks,
Abby

-----Original Message-----
From: Marcelino de la Cruz [mailto:marcelino.delacruz at upm.es] 
Sent: Thursday, March 07, 2013 2:53 AM
To: Abby Rudolph
Cc: r-sig-geo at r-project.org
Subject: Re: [R-sig-Geo] random spatial distribution code / shapefiles with more than one polygon

Hi,
My first advise is to point you to the vignette about "handling shape les in the spatstat package" .Go to section 3.2.5 "Objects of class SpatialPolygons".

In short, you could do something like this:

BaltCity2<-readShapePoly("baltcity_mdsp83m.shp")
play2<-ppp(play$X_m,play$Y_m, window=as.owin(BaltCity2))

...if you want to combine all polygons inside baltcity_mdsp83m.shp in just one window. See the section section 3.2.5 "Objects of class SpatialPolygons" for the other option (having different windows from each indiviual polygon).

As you can see, I also removed the "meter to miles" conversion because it's unnecesary  if both the shapes and the  play$X_m and play$Y_m coordinates are in the same units (metres)


HTH,
Marcelino


El 07/03/2013 4:51, Abby Rudolph escribi?:
--
Marcelino de la Cruz Rot
Depto. de Biolog?a Vegetal
Universidad Polit?cnica de Madrid
Madrid, Espa?a