comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » k-mean clustering idl
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
k-mean clustering idl [message #94170] Sun, 12 February 2017 15:13 Go to previous message
smnadoum is currently offline  smnadoum
Messages: 24
Registered: June 2016
Junior Member
I was wondering if I could get some help on clustering in IDL. I found a good example on Harris Geospatial that explains the method, however, I am confused on how to run the clustering on my own data (ASCII) to perform the K-mean analysis. How can I use my data instead of the 'random' function that generates random numbers
Below is the code I found on Harris:

n = 50
c1 = RANDOMN(seed, 3, n)
c1[0:1,*] -= 3
c2 = RANDOMN(seed, 3, n)
c2[0,*] += 3
c2[1,*] -= 3
c3 = RANDOMN(seed, 3, n)
c3[1:2,*] += 3
array = [[c1], [c2], [c3]]
; Compute cluster weights, using three clusters:
weights = CLUST_WTS(array, N_CLUSTERS = 3)
; Compute the classification of each sample:
result = CLUSTER(array, weights, N_CLUSTERS = 3)

My data is in ASCII format and I have already wrote a code that opens and read ascii (below) but not sure how to run the k-mean clustering analysis on my data. I can't find good IDL resources that explains the clustering.

pro read_text, file, dir

dir='path'
file= 'path*file'

n = file_lines(file)
gv= fltarr(n)
npv= fltarr(n)
soil= fltarr(n)
gv0= 0.0
npv0= 0.0
soil0=0.0


openr, iunit, file, /get_lun
for i= 0, n-1 do begin

readf, iunit, gv0, npv0, soil0

gv[i]= gv0
npv[i]= npv0
soil[i]=soil0

endfor


free_lun, iunit

for i = 0, n-1 do print, gv[i], npv[i], soil[i]

mwell=gv[0,*,*] ;this doesn't work
mwell=gv[1,*,*]
mwell=gv[2,*,*]

end



Thank you.
[Message index]
 
Read Message
Read Message
Read Message
Previous Topic: Reading h5 dataset by chunks
Next Topic: harrisgeospatial unreachable...

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 11:47:31 PDT 2025

Total time taken to generate the page: 0.00208 seconds