[R-sig-Geo] Clustering 3D point

marcelino.delacruz at upm.es marcelino.delacruz at upm.es
Fri Sep 9 10:12:07 CEST 2011


Maybe I didn't undestand your question on my first answer.

If you want to cluster your points you may use standard functions in R.
For example:

#compute a spatial distance between points:
dspatial <- dist (cbind(utm_x,utm_y))

# compute a temporal distance between points:

dtemporal <- wathever function to compute temporal distances (I don't
work with temporal data so I don't know yet!)

# truncate spatial distance matrix to work with distnaces less than 3 Km

dspatial.l.3 <-dspatial
dspatial.l.3[dspatial.l.3 > 3] <- 99999 # or wathever other big number
plot(hclust(dspatial.l.3, method = "single"))

# these are the clusters of points within 3 km from each other:
cutree(hclust(dspatial.l.3, method = "single"),h=3)

# truncate temporal distance matrix to work with distances less than 14
days

dtemporal.l.14 <- dtemporal
dtemporal.l.14[dtemporal.l.14 >14] <- 99999
dtemporal.l.14[dtemporal.l.14 <=14] <- 0


# sum spatial and teporal distances:
dspatiotemporal <- dspatial.l.3 + dtemporal.l.14

# compute clusters that include points within 3 Km and which had
earthquakes within 14 days
plot(hclust(dspatiotemporal,"single"))
cutree(hclust(dspatiotemporal,"single"),h=3)



HTH,

MArcelino





Con fecha 8/9/2011, "Riccardo Gaeta" <riccardog79 at gmail.com> escribió:

>I've a look at spatstat, I've found the new object "ppx" but no idea to how
>manipulate it. Also in the guide on CRAN they don't speak about cluster or
>grouping data in 3D, there is just a function that calculate the distance in
>3D, but I have as result a matrix like a "dist" object, and the problem
>remains the same.
>
>Thanks anyway!
>
>
>
>2011/9/8 Marcelino de la Cruz <marcelino.delacruz at upm.es>
>
>>  Hi,
>>
>> you may consider using package spatstat, that has some functions to deal
>> with  multi-dimensional space-time point pattern objects
>>
>>
>> Cheers,
>>
>> Marcelino
>>
>>
>> At 15:15 08/09/2011, Riccardo Gaeta wrote:
>>
>> Hi all,
>> it's my first time I write on this list.
>> I expose my problem quickly and (hope) clearly.
>>
>> 1) FIRST APPROACH:
>> I have some spatial points that are related to each other by some
>> spatial&temporal conditions. I have a dataframe that contains the couple of
>> points in relation. For example:
>>
>> col1 ; col2
>> A       B
>> B       C
>> B       D
>> E       D
>>
>> I've obtained this list of couples by creating some "dist" object and
>> searching correspondence between them.
>> This list of couples means that: A is relate to B, B is relate to C and to
>> D, E is relate to D.
>> I would like to write a script that create a vector in which I have: A B C
>> D
>> E recognized as a unique group.
>> I've tried some "for loop" but I'm wondering if maybe there is a more
>> conventional function.
>>
>> 2) SECOND APPROACH:
>> In particularly I'm working on seismological data, and I'm studying a way
>> to
>> recognize seismic sequences, so to elaborate space-time cluster on my data.
>> I have 2D spatial points with indication of time of occurrence of the
>> seism,
>> and I would like to clusterize them with concern about these "3
>> dimensions":
>> coordinates x-y and time. I've successful used DBSCAN for space-clustering,
>> but it supports (I suppose) only 2 dimensions.
>>
>> I give you at the end of the mail more details in case you would like to
>> help me.
>>
>>
>> Thanks very much for any help,
>> Riccardo
>>
>>
>> ********************
>>
>> My "3D" spatial-temporal points:
>>
>>     utm_x  utm_y  date
>> 1  100000 4200 <callto:000 4200>000 "2008-06-17 04:12:27 CEST"
>> 2  155000 4250 <callto:000 4250>000 "2008-10-15 09:06:43 CEST"
>> 3  277000 4750 <callto:000 4750>000 "2010-10-25 22:50:42 CEST"
>>
>> ...(5600 points)
>>
>> My criterion to build cluster:
>> a- points within 3km of distance from each other
>> b- earthquakes happened within 14 days (2 weeks) from each other
>>
>> **
>>         ** [[alternative HTML version deleted]]
>>
>> _______________________________________________
>> R-sig-Geo mailing list
>> R-sig-Geo at r-project.org
>>  https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>>
>> **
>>
>> ** ____________________________________
>>
>> Marcelino de la Cruz Rot
>> Depto. Biologia Vegetal
>> EUIT Agricola
>> Universidad Politecnica de Madrid
>>
>> tel: 34 + 913365435
>> ____________________________________
>>



More information about the R-sig-Geo mailing list