[R-sig-Geo] kernels, contours, points?

Ashton Shortridge ashton at msu.edu
Thu Jul 17 15:48:09 CEST 2008


I think creative use of the overlay() function would accomplish what you want.
Some example code that is a bit like what you propose (uses the sp library):

# I have a polydataframe object:
my.poly.data <- SpatialPolygonsDataFrame(my.poly, area.lu.table)

# I have a set of point objects (derived, in this case, from spsample):
samgrid <- spsample(us.spPolys, 500, 'regular')  

# I'd like to know which poly in my.poly.data each point in samgrid falls in:
sample.area <- overlay(my.poly.data, samgrid)$name

For this to work, you would need to figure out how to turn contours into 
polys, which might be tricky, especially if they aren't closed and/or have 
holes (pits) within them.

I admit that I am not very comfortable working with the sp objects, and I 
would generally advise someone doing GIS-type work to use a GIS. Hawth's 
(not "Hawk's") Analysis Tools are very useful in an ESRI environment, as are 
built in commands and extensions in many GIS.

yours,

Ashton
-- 
Ashton Shortridge
Associate Professor			ashton at msu.edu
Dept of Geography			http://www.msu.edu/~ashton
235 Geography Building		ph (517) 432-3561
Michigan State University		fx (517) 432-1671

On Wednesday 16 July 2008, Jeebz wrote:
> Hi
>
> I'm new to the R spatial packages, but I have a spatial-oriented task
> I would like to accomplish.
>
> I have a 2d grid of points and each point has a class (13 classes
> total in the dataset).  The grid is small-ish, only 256x256.  I have
> run a 2d kernel density estimation (using kde2d) and can create a
> contour plot easily (per class).
>
> What I would like to do is use a contour line to extract all the
> points from the original grid that are bounded by that contour.
> Ultimately, I wish to calculate a sort of "purity" measure, so given a
> particular contour (e.g. a contour level that encloses 95% of the
> classes points), how many points from other classes fall in with the
> classes that were used to define the contour.
>
> I know there has to be a way to do this with R... right?  A colleague
> of mine showed my how it could be done using ArcGIS and "Hawkes
> tools", by calculating percent volume contours, but I don't know where
> to begin in R.
>
> Anyone have any thoughts or examples on this?
>
> Much thanks in advance,
>
> bct
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at stat.math.ethz.ch
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo




More information about the R-sig-Geo mailing list