Skip to content

Grass and raster package

8 messages · Martin, Javier Garcia-Pintado, Roger Bivand +2 more

1 day later
#
On Mon, 25 Oct 2010, Martin wrote:

            
Indeed, using GRASS itself often helps! You can simplify to:

k <- execGRASS("g.mlist", parameters=list(type="rast",
   pattern="'elev*'"), intern=TRUE)

(example tried in spearfish, also works in Linux with pattern="elev*")

Roger

  
    
#
Dear all,
I am wondering if there is a direct function (I cannot find any) in R, to
obtain, a "factor" vector to identify which points could be grouped in a
set, using a specific threshold distance as clustering criterion.

#e.g, with 7 points with coordinates:

x <- c(1.01,0.95,1.05,1.03,3.03,2.99,3.04)
y <- c(3.01,3.02,3.04,5.23,2.01,2.02,1.98)

# and, let's say, distance threshold 0.5, the answer would be:
(1,1,1,2,3,3,3)

# where the threshold is the maximum distance between any two points for
each cluster

A better approach would be that threshold could be specified as the
distance between any point in each cluster, and its corresponding center
of mass for that cluster, but I guess this would require some loops. Isn't
it? S, I would be happy enough with the abovementioned approach.

If there isn't a direct function, don't worry. I'll try to find a solution
computing distances...

Thanks,
Javier
---
#
On Tue, 26 Oct 2010, jgarcia at ija.csic.es wrote:

            
library(spdep)
dnb <- dnearneigh(cbind(x, y), 0, 0.5)
n.comp.nb(dnb)$comp.id
# [1] 1 1 1 2 3 3 3
I think that this might need hierarchical clustering and custom cut-offs 
and # clusters.

Hope this helps,

Roger

  
    
#
Thank you, Marcelino, Roger and Alexander,
I didn't know any of these.
Cheers,
Javier
...