Skip to content
Prev 83367 / 398513 Next

importing shapefiles into spatstat

On Fri, 30 Dec 2005, Mulholland, Tom wrote:

            
Yes, there are examples there. The current advice is to:

rSpatial <- "http://r-spatial.sourceforge.net/R"
install.packages("spspatstat", repos=rSpatial)
library(spspatstat)
library(maptools)
your_sp <- readShapePoly("your.shp")
your_sp1 <- as(your_sp, "SpatialPolygons")
your_owin <- as(your_sp1, "owin")
plot(your_owin)
pp <- runifpoint(500, your_owin)

On occasion shapefiles are not well-behaved, so if you have lakes in 
islands in lakes, you may need to clean the shapefile first, but usually 
things go OK. If you need to follow this up, please move your reply to the 
R-sig-geo list - see the Spatial Task View on CRAN for easy access.

Roger