import matrix into mapping toolbox? or just draw coastlines in fig

2 views (last 30 days)

Hi y'all,

I'm a longtime user of matlab but new to the mapping toolbox, and I've read through teh documentation but see little to no reference to regular matrices. I have the following data:

 >> whos cummDose
  Name            Size                 Bytes  Class     Attributes
cummDose      900x2159            15544800  double              
 >> whos lat
  Name      Size              Bytes  Class     Attributes
lat       1x1079             8632  double              
 >> whos lon
  Name      Size              Bytes  Class     Attributes
lon       1x2159            17272  double  

*note I've trimmed lat to only be relevant for my anaylsis This results in the following figure:

I would really like to draw coastlines with something line the mapping toolbox, but does it deal with plain old matrices? Is there a relatively painless way to import this data given lat/lon and draw those coastlines? Is there a simpler or more logical way to do this? My sincerest apologies for the novice question, and thanks in advance for your input.

All the best, Kate

Answers (2)

Chad Greene
Chad Greene on 12 Sep 2017
Edited: Chad Greene on 13 Sep 2017
Hi Kate,
There are a couple of ways you can skin this cat. An easy and computationally efficient way to do it without the Mapping Toolbox is just treat longitudes like x values and latitudes like y values. Then use my borders function to draw national boundaries:
imagesc(lon,lat,cummDose)
borders('countries','nomappingtoolbox')
axis xy
will plot everything you want to plot in plain unprojected coordinates. Since you seem to have some missing data, you may wish to make it transparent with imagesc by
h = imagesc(lon,lat,cummDose);
set(h,'alphadata',isfinite(cummDose))
If you prefer to do this with the Mapping Toolbox, you'll lose some computational efficiency and it'll be harder to share your scripts with anyone who does not have the Mapping Toolbox, but you'll gain the nice map projections available via worldmap.
Your dataset is not huge, so computational efficiency won't be a big issue, but if you ever experience figure sluggishness, try doing it with imagesc instead of worldmap. The difference is imagesc plots an easy, predictable grid, whereas projecting to map coordinates or using pcolor lets the grid squeeze and stretch. That said, to do this with the Mapping Toolbox, start by initializing a map with worldmap, then use pcolorm, then add the landareas as follows:
worldmap('world')
pcolorm(lat,lon,cummDose)
geoshow('landareas.shp')

Cedric
Cedric on 11 Sep 2017
Edited: Cedric on 11 Sep 2017
Hi Kate,
You will find an easy way to achieve what you want here: https://www.mathworks.com/help/map/create-a-world-map.html
Note that if you don't want to cope with PLOTM at this stage (*), you can just:
plot( coastlon, coastlat ) ;
Best,
Cedric
(*) There is a whole set of map-oriented tools and resources that comes with the Mapping toolbox. PLOTM, for example, needs an AXESM object to be present. You may have used gca to access the current AXES object previously, and in the "Mapping world" it is gcm. If you are interested in working with the Mapping toolbox, I'd say that it takes a full day full time (a bit painful in the beginning) for getting used to the main logic and resources.

Community Treasure Hunt

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

Start Hunting!