

Dear all,
is it possible to load a complete Grass mapset into a raster stack or brick with a single command?


i found a solution, if someone else is interested:
system("g.mlist type=rast pattern='lin*' >tmp")
k=c(scan("tmp", what='string'))
x=readRAST6(k)
b=brick(x)

Administrator

On Mon, 25 Oct 2010, Martin wrote:
>
> i found a solution, if someone else is interested:
>
> system("g.mlist type=rast pattern='lin*' >tmp")
>
> k=c(scan("tmp", what='string'))
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
>
> x=readRAST6(k)
>
> b=brick(x)
>

Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Helleveien 30, N5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43
email: [hidden email]
_______________________________________________
RsigGeo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/rsiggeo
Roger Bivand
Department of Economics
Norwegian School of Economics
Helleveien 30
N5045 Bergen, Norway


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

_______________________________________________
RsigGeo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/rsiggeo

Administrator

On Tue, 26 Oct 2010, [hidden email] wrote:
> 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)
library(spdep)
dnb < dnearneigh(cbind(x, y), 0, 0.5)
n.comp.nb(dnb)$comp.id
# [1] 1 1 1 2 3 3 3
>
> # 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.
I think that this might need hierarchical clustering and custom cutoffs
and # clusters.
Hope this helps,
Roger

Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Helleveien 30, N5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43
email: [hidden email]
_______________________________________________
RsigGeo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/rsiggeo
Roger Bivand
Department of Economics
Norwegian School of Economics
Helleveien 30
N5045 Bergen, Norway


This seems a single linkage clustering issue:
> grouping < hclust(dist(data.frame(x,y)),"single")
> cutree(grouping, h=0.5)
[1] 1 1 1 2 3 3 3
Cheers,
Marcelino
At 13:04 26/10/2010, [hidden email] wrote:
>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
>
>
>
>
>
> > is it possible to load a complete Grass mapset into a raster stack or
> > brick
> > with a single command?
> >
> > 
> > View this message in context:
> >
> http://rsiggeo.2731867.n2.nabble.com/Grassandrasterpackagetp5667199p5667199.html> > Sent from the Rsiggeo mailing list archive at Nabble.com.
> >
> > _______________________________________________
> > RsigGeo mailing list
> > [hidden email]
> > https://stat.ethz.ch/mailman/listinfo/rsiggeo> >
>
>_______________________________________________
>RsigGeo mailing list
> [hidden email]
> https://stat.ethz.ch/mailman/listinfo/rsiggeo____________________________________
Marcelino de la Cruz Rot
Depto. Biologia Vegetal
EUIT Agricola
Universidad Politecnica de Madrid
tel: 34 + 913365435
____________________________________
[[alternative HTML version deleted]]
_______________________________________________
RsigGeo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/rsiggeo


Thank you, Marcelino, Roger and Alexander,
I didn't know any of these.
Cheers,
Javier
...
> This seems a single linkage clustering issue:
>
> > grouping < hclust(dist(data.frame(x,y)),"single")
> > cutree(grouping, h=0.5)
> [1] 1 1 1 2 3 3 3
>
> Cheers,
>
> Marcelino
>
>
>
> At 13:04 26/10/2010, [hidden email] wrote:
>>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
>>
>>
>>
>>
>>
>> > is it possible to load a complete Grass mapset into a raster stack or
>> > brick
>> > with a single command?
>> >
>> > 
>> > View this message in context:
>> >
>> http://rsiggeo.2731867.n2.nabble.com/Grassandrasterpackagetp5667199p5667199.html>> > Sent from the Rsiggeo mailing list archive at Nabble.com.
>> >
>> > _______________________________________________
>> > RsigGeo mailing list
>> > [hidden email]
>> > https://stat.ethz.ch/mailman/listinfo/rsiggeo>> >
>>
>>_______________________________________________
>>RsigGeo mailing list
>> [hidden email]
>> https://stat.ethz.ch/mailman/listinfo/rsiggeo>
> ____________________________________
>
> Marcelino de la Cruz Rot
> Depto. Biologia Vegetal
> EUIT Agricola
> Universidad Politecnica de Madrid
>
> tel: 34 + 913365435
> ____________________________________
_______________________________________________
RsigGeo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/rsiggeo


In reply to this post by Marcelino de la Cruz
Dear all,
I'm using the "skater" function in spdep in order to perform a spatial clustering of polygons containing fire regime data. However, I have the following problem. When I compute the cost, some of my polygons are similar to all their neighbors; hence, all edges have 0 cost values for these polygons. When I compute the nb2listw using the neighbors list and the glist as cost, it obviously reports that :
>In nb2listw(ecodist_80_99.nb, lcosts_ecodist_80_99, style = "W", :
zero sum general weights
For those who are familiar with spatial clustering, I'm looking for proposition. Maybe the only issue would be to dissolve these polygons and then rerun the analyses. Morever, is there another spatial clustering technique in R that can cope with such data?
Thanks in advance,
Yan
Yan Boulanger
Dendrolab  Datation de bâtiments patrimoniaux par dendrochronologie
www.dendrolab.ca
[hidden email]
Université du Québec à Rimouski
Département de Biologie
Centre d'études nordiques
300, allée des Ursulines
Rimouski, PQ G5L 3A1
(418) 7231986 poste 1482
[[alternative HTML version deleted]]
_______________________________________________
RsigGeo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/rsiggeo

