How to make algorithm using raster file?

3 次查看(过去 30 天)
Hello every one, I have a problem regarding raster file in Matlab. My task is import the raster file about temperature to Matlab, then create a formula to calculate a parameter using data from that temperature raster file. Could you explain me how to import raster file and write the formular? The formula is in below, all of data are constant, I just need to put GDDakt (the value of temperature raster file) in. Thank you a lot.
  3 个评论
Image Analyst
Image Analyst 2020-7-9
What do you mean by raster? To me, I only think of it in regards to an image, like the image is produced by a raster scan where the electron beam goes from left to right and top to bottom. Do you simply mean that GDD is a matrix? If so, the "raster" adjective is not even needed - it just confuses things.
Son Thanh Tran
Son Thanh Tran 2020-7-9
Hello, sorry for making you confuse. My supervisor has a data source about temperature, water... in the .tif format (they are all raster). What he wants me to do is trying to import those raster data in Matlab to calculate the suitable index for the tree. So in the formular, E is the suitable index for the tree. GDD max and GDD min are set by myself as threshold, the only thing to do is puting the raster data in the formula to calculate the suitable index E for each pixcel, and from that I can have suitable index to for tree species. The code is a bit similar to this SAS code. Im trying to find the way to create the same code in matlab

请先登录,再进行评论。

采纳的回答

KSSV
KSSV 2020-7-9
To load the data read about load, importdata, textscan.
If your raster data matrix is A, to get your formula use:
GDDmax = max(A(:)) ; % this gives max of A
GDDmin = min(A(:)) ; % this gives min of A
E = 4*(GDDmax-A).*(A-GDDmin)/(GDDmax-GDDmin)^2 ;
  2 个评论
Son Thanh Tran
Son Thanh Tran 2020-7-9
Hello, thank you for your help. If i want to set many thresholds for GDD max and GDD min with different species, how can i write it in the form of If...then?. For example, I have 2 species: Fi and La. My raster data matrix is A. I will set GDDmax=2510, GDD min=150
E = 4*(2510-A).*(A-150)/(2510-150)^2
I want to set: If A>2510, then FiGDD = 0 (FiGDD is the E of species Fi)
If A<1200 then LaGDD = 4*(2290-A).*(A-110)/(2290-110)^2
If A>=1200 and GDD<=1500 then LaGDD = 1
Could you help me to write this formula in Matlab? Sorry, im totally new with matlab so im trying to ask. Thank you
Son Thanh Tran
Son Thanh Tran 2020-7-9
When i write the code, all of value equal to 0. Could you check it for me?

请先登录,再进行评论。

更多回答(1 个)

Image Analyst
Image Analyst 2020-7-9
Since you say your GDD data is in a TIFF file, you can try to use imread() to read in the tif image. If that doesn't work, there is a TIFF class with more functionality.
  1 个评论
Son Thanh Tran
Son Thanh Tran 2020-7-9
Yes, it has already worked. Do you know how to write the formula? Im trying to write as advise of KSSV
So my formula is E = 4*(2510-A).*(A-150)/(2510-150)^2
A is data of GDD. However, all of results are 0. Does matlab automatically change the small number like 0.005 to 0? and if it is like that, how to change the number back to 0.005?

请先登录,再进行评论。

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by