mat to txt conversion

865 views
Skip to first unread message

Gebremichael

unread,
Mar 17, 2015, 6:14:56 PM3/17/15
to mai...@googlegroups.com
Hello Karsten and all,

At the end of the stamps processing in matlab, I created a mat file using ps_plot('v-do',-1) that can give me a more or less realistic ground velocity result after excluding possible sources of error; can you please tell me how I can export (regenerate) this file in txt format so that I can use it in a GIS environment (I tried several matlab scripts but I seem to be failing; here is the error message that I'm getting:
   Warning: Attempt to write an unsupported data type to an ASCII file.
    Variable 'Conten' not written to file.

Thank you.

Regards,

Gebremichael

David Bekaert

unread,
Mar 17, 2015, 6:21:53 PM3/17/15
to mai...@googlegroups.com
hi,

Try to load the data in matlab first then write out as a matrix using dlmwrite function.
You can use something like the following to make it tab delimited.
dlmwrite('filename',matrix,'\t')
You could also load the lon lat information first from ps2.mat variable and combine it all together in the matrix.

Hope it helps,

David


--
You received this message because you are subscribed to the Google Groups "MAINSAR" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mainsar+u...@googlegroups.com.
To post to this group, send email to mai...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Gebremichael

unread,
Mar 18, 2015, 2:38:52 PM3/18/15
to mai...@googlegroups.com
Thanks so much!! I'm working on your suggestion and I will let you know the outcome. Thank you!
Message has been deleted

Gebremichael

unread,
Oct 16, 2015, 1:49:33 PM10/16/15
to MAINSAR
Hi all,

For problem of loading ps_mean.xy (generated by ps_output command) in one excel file so that it can be used in Arcmap (especially if you have too many ps-points that cannot fit in one single excel file), the following python code (developed by our colleague Kyle Chouinard) will transform the txt file (.xy) into csv format and it can directly be imported (added) on arcmap.


import csv

inputs = []
with open('ps_mean_v.xy', 'rb') as csvfile:
    reader = csv.reader(csvfile, delimiter=' ')
    for line in reader:
        temp = []
        for val in line:
            if val:
                temp.append(val)
        inputs.append(temp)
with open('ps_mean_v.csv', 'wb') as csvfile:
    spamwriter = csv.writer(csvfile, delimiter=',')
    spamwriter.writerow(["x"  ,"y","val"])
    for row in range(len(inputs)):    
        spamwriter.writerow(inputs[row])


I hope this helps.

Regards,
Reply all
Reply to author
Forward
0 new messages