binning data and mapping

12 views (last 30 days)
akk on 24 Jul 2019
I am trying to bin lat/lon data into 5x5 grids, and then plot the boxes. I have 3 columns: lat, long and temperature.
So far I have:
latidx = 1 + floor((lat_open - minlat) ./ gridspacing);
longidx = 1 + floor((long_open - minlong) ./ gridspacing);
num=accumarray( [latidx(:), longidx(:)], 1) %finds the # measurements in each grid
%Then I create the map
m_proj('lambert','long',[-98 -81],'lat',[18 31])
m_gshhs_i('patch',[.7 .7 .7],'edgecolor','k')
grid on; hold on
But, how do I get the coordinates of the grids and show them as boxes on the map? Thanks for your help!

Answers (1)

Roshni Garnayak
Roshni Garnayak on 5 Aug 2019
You can use the binscatter function to create a binned scatter plot.
binscatter(latidx , longidx ,[5 5]);
A binned scatter plot partitions the data space into rectangular bins and displays the count of data points in each bin using different colors.
For examples and detailed explanation, refer to the following link:
Bishwas Lal Shrestha
Bishwas Lal Shrestha on 23 Jun 2020
I am trying to create a similar type of plot in mollweide projection. But I am not quite sure how we can use "binscatter" in map projection!

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!