Skip to content

importing shapefiles into spatstat

2 messages · Mulholland, Tom, Roger Bivand

#
You might also consider looking at the R-sig-Geo list which has lots of discussion about issues relating to file formats and the best ways to get data in and out the various packages that are used.

Tom
#
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