[R-sig-Geo] kernel2D to shape

Michael Sumner mdsumner at utas.edu.au
Mon Aug 11 23:42:59 CEST 2008


Hello,

The spatial support in R gives you many options, one I know is to use 
contourLines() with an image() grid, and then converting that to a 
SpatialLinesDataFrame with ContourLines2SLDF() in the maptools package.

The SLDF can then be written to shapefile with writeOGR() in rgdal 
package. For example:

library(splancs)
library(rgdal)
library(maptools)
data(bodmin)
img <- kernel2d(as.points(bodmin), bodmin$poly, h0=2, nx=100, ny=100)
img.contours <- ContourLines2SLDF(contourLines(img))
writeOGR(img.contours, "contours.shp", "contours", "ESRI Shapefile")

# check the result
tst <- readOGR("contours.shp", "contours")
image(img)
plot(tst, add = TRUE)

HTH

Cheers, Mike.


Daniel Rainham wrote:
> Hello,
>
> I have collected GPS data on individuals (humans) at one second intervals for
> approximately seven days. The file is read into R and the coordinates are
> converted from decimal degrees to UTM. I then calculate two measures: 1.
> Minimum convex polygon (using the ASPACE packge) 2. Kernel density estimate
> (using SPLANCS, kernel2d function)
>
> The first measure, MCP, can be output to a shapefile using makeshapes in the
> ASPACE package for further analysis in a GIS package.
>
> I would like to be able to do the same with the KDE, either as a raster (grid if
> using ArcGIS), or would also be happy with polyline contours if possible in
> .shp format. Why? Because I would like to extract information from other layers
> in the GIS that correspond to the boundaries and intensities of the KDE
> surface.
>
> Is this currently possible from within R? If so, can anyone share with me the
> process or code to achieve the conversion?
>
> Thanks in advance for your help. I can send my full R code if required.
>
> Daniel Rainham
> Dalhousie University
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at stat.math.ethz.ch
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>
>
> No virus found in this incoming message.
> Checked by AVG - http://www.avg.com 
> Version: 8.0.138 / Virus Database: 270.6.0/1604 - Release Date: 8/11/2008 5:50 AM
>
>
>
>




More information about the R-sig-Geo mailing list