Ocean Color Forum - Not logged in
Forum Ocean Color Home Help Search Login
Previous Next Up Topic SeaDAS / Non-SeaDAS Packages (e.g. MATLAB, ENVI, GIS, etc) / How to add fancy map frame on PNG image files (locked) (13566 hits)
By ajis Date 2010-03-24 22:25
Hi,

I have a large number of daily Aqua MODIS Chl-a images in PNG files created/maped by using SeaDAS.
The file name is something like A2000nnn....chlor_a.png, where nnn is julian day.
What I need is just to add them a map frame with fancy style as attached and latitude longitude labels as well,
with lat range of 32.25 - 34.25 N and long range of 130.75 - 132.75 E.
SeaDAS can not create the fancy style map frame.
I will very much appreciate if anyone create a simple matlab file or script for me to do the above processing for multiple files?
I am really new in Matlab.
Thank you in advance.

Ajis

By Lachie Date 2010-04-13 01:09 Edited 2010-04-13 01:12
Hi Ajis,

Just a couple of questions first:
1.) Are you using m_map or the matlab mapping toolbox?  Whichever you are using doesn't particularly matter, however the matlab scripts will be slightly different. 
2.) Is the L2 file you are using download or did you derive it using SeaDAS l2gen from L1A -> L2?  I ask this because the L2 files from OceanColor web typically have a reduced number of lat/lon control points and you have to do some interpolations before mapping.  If you processed the data using l2gen in SeaDAS yourself then the lat/lon matrices should be the same dimensions as the Chl-a matrix.

I would suggest loading the MODIS L2 Chl-a product and the latitude-longitude data into matlab using the hdfread function directly from the L2 files.  You can run a routine which reads in each file, re-maps them with the fancy borders and then saves the output as an image file.  If you want the SeaDAS Chl-a colormap I have that also. 

I'm not sure if you can load the .png image and add a fancy border though, maybe someone out there does.  I know the above sounds like a bit of work but it is pretty handy once it is set up.

Cheers, Lachie

Below, I have attached an example of a SST product I processed using SeaDAS and then mapped using Matlab:

By rexshan Date 2010-04-13 05:31
Hi Lachie

I am using m_map to map the MODIS L2 chl-a product and I had already load the latitude and longitude data into matlab.
What can I do with the lat/lon control points and before mapping.

Thanks,
Rex
By ajis Date 2010-04-13 06:18 Edited 2010-04-13 08:15
Hi Lachie,

It is so nice image. I actually want to do the same mapping but for ocean color variables.
I have had L2 files processed by using l2gen on seadas6.1, but I prefer to map on matlab with fancy frame.
Would you please kindly share your routine matlab code you used for maping SST?
I have map toolbox, but I will use m_map.
Thank you so much in advance.

Regards,
Ajis
By Lachie Date 2010-04-14 01:28
Hi Ajis,

I'll put some Matlab code up here that may be useful.  I have also converted the Seadas (IDL) Chlorophyll colour map so that it can be recognised by matlab, that way your Chl maps will look quite similar to those derived in Seadas.  Please find attached the file: chl_colormap.dat.  Put the chl_colormap.dat file in the same directory as the L2 files you wish to map. 

Ordinarily L2 products have some sort of linear scaling factors (ie a slope and intercept) that have to be applied once you have read your L2 product in from the HDF file.  However, for Chl I'm pretty sure that it has a slope of 1 and 0 intercept (ie no linear scaling needed).  You may want to check this though using the hdftool in Matlab which allows you to browse within the HDF file.  Just type "hdftool" into the Matlab command prompt.

If you don't have it already, I suggest that you install the gshhs high resolution coastline for the m_map mapping toolbox.  This will make things look very tidy when plotting coastlines.  You can find further info regarding how to install the gshhs data here: http://www.eos.ubc.ca/~rich/private/mapug.html#p9.5

I shall post some code to plot up a CHL map shortly.

Cheers, Lachie
By Lachie Date 2010-04-14 01:35
Find attached the file "chl_colormap.dat"

Cheers, Lachie

Attachment: chl_colormap.dat (3.3k)
By Lachie Date 2010-04-14 07:05
Hi Ajis,

Please find attached a sample matlab code that may be suitable for mapping your Chl.  Once you get it working then you can go ahead and set up a loop routine for generating multiple maps.  Let me know if you get stuck.

Cheers, Lachie

Attachment: CHL_MAP.m (2.6k)
By ajis Date 2010-04-14 22:00 Edited 2010-04-14 23:43
Hi Lachie,

Thank you so much for the code.
It worked just fine for my L2 chl data.
Here I attached the generated image.

I changed line 53 to
m_pcolor(LON,LAT,log10(CHL));
to get color in log scale, but I dont know how to manipulate color bar in log sclae.

I added in line 74 as
caxis([log10(0.01) log10(65)]);
but sure it is just to log transformed the Chl-a value in color bar.
What I need is the color scale bar with labels such as 0.01, 0.1, 1, 10, 64, operationaly gerenated by seadas.

I tried to add
set(cbar1,'ytick',log10([0.01 0.1 1 10 65]),'yticklabel',...
    [0.01 0.1 1 10 65],'tckdir','out');

also could not work. I still got the color bar with lables starting from -2.

What do I have to add to generate images and its color scale bar in log scale?

Thanks.

Ajis

Attachment: A2008209043500_CHL.png (103.3k)
By ajis Date 2010-04-15 00:15
Lachie,

the color bar scale problem is solved by adding
set(cbar1,'ytick',log10([0.01 0.1 1 10 65]),'yticklabel',...
    [0.01 0.1 1 10 65],'tickdir','out');

but why the start (0.01) and end (65) labels are not printed out.

I am now try to find a way how to do looping for multiple L2 files.
I think it is a simple thing for you. So, please let me know if you already have such a code.

I will back if I have a problem with looping.

Thank you.

Ajis
By Lachie Date 2010-04-15 02:05 Edited 2010-04-15 03:25
Hi Ajis,

That's great news! Glad to see you are getting some maps out.  Now to loop the process you just have to add a little more code.  I'll attach an example for you.  I recommend to save the outputs to a sub-directory so that code doesn't get confused between the output .png files and the input hdf file.  Good to hear you solved the problem with the log scaling on the colorbar, from memory I had a similar issue. 

Cheers, Lachie
By ajis Date 2011-09-26 22:20 Edited 2011-09-26 22:37
Hi Lachie,

After one and half year I am coming again to have your advises.
I am writing matlab code with m_map to create Chl-a map. The code is attached.
Now the chl-a data is in ascii with 3 column (lat lon data) as attached.
Lat Lon limits are 1 - 7 N, 100 - 105 E.
But when I run the code several error messages returned such as;

Insufficient memory

Error ==> mu_util>m_clip at 92
  [i,j]=find(diff(indx)==1);

Error ==> mu_util at 27
    [varargout{1},varargout{2}]=m_clip(varargin{:});

Error ==> mp_cyl at 100
        [lat,long]=mu_util('clip',varargin{4},lat,MAP_VAR_LIST.lats(1),lat<MAP_VAR_LIST.lats(1),long);
       
Error ==> m_ll2xy at 36
     [X,Y,I]=feval(MAP_PROJECTION.routine,'ll2xy',varargin{:},'clip','on');

Error ==> m_pcolor at 50
if any(i(:-)), [X,Y]=m_ll2xy(long,lat,'clip','patch'); end;

Error ==> Chl_map_ascii at 10
m_pcolor(lon,lat,log10(chl));

Why this time I could not use m_pcolor for mapping. I successfuly did from MODIS level 2 data.
Plz give me some advises to correct my code.
Thank you so much.

Cheers, Ajis

Attachment: Chl_data (160.9k)
Attachment: Chl_map_ascii.m (0.7k)
Previous Next Up Topic SeaDAS / Non-SeaDAS Packages (e.g. MATLAB, ENVI, GIS, etc) / How to add fancy map frame on PNG image files (locked) (13566 hits)



Responsible NASA Official: Gene C. Feldman
Curator: OceanColor Webmaster
Authorized by: Gene C. Feldman
Updated: 27 November 2007
Privacy Policy and Important Notices NASA logo