create grid of squares over map using mapping toolbox
11 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hi,
I am working on a project where i have specific locations (latitude/longitude) and need to create a type of heat-map which represents how populated each region.
I would like to create a grid of squares over the map (which i have created using the mapping toolbox) and color each square based on the number of points registered inside it. I have done a similar thing using circles, where i verify if the point is inside each circle using the "inpoly" function. However, i am finding it challenging to do the same using squares. I guess as long as i know the corner points of each square, i would still be able to follow the same approach.
I have attached a sample image to show you the type of grid i am looking for. Ideally, i would like to be able to specify the size of each of the squares in for example km. The map was produced using the following code (the grids were overlaid in paint):
figure(1);
f=worldmap([33 68],[-15 37]);
geoshow('landareas.shp', 'FaceColor', [1 1 1],'DefaultEdgeColor', 'b')
Thank you very much for you help in advance.
0 comentarios
Respuestas (1)
Jos (10584)
el 1 de Mzo. de 2016
You can add a grid like this:
f=worldmap([33 68],[-15 37]);
geoshow('landareas.shp', 'FaceColor', [1 1 1],'DefaultEdgeColor', 'b')
AxisHandle = gca ;
GridHandle = gridxy(linspace(AxisHandle.XLim(1),AxisHandle.XLim(2),25), ...
linspace(AxisHandle.YLim(1),AxisHandle.YLim(2),25)) ;
set(GridHandle,'color',[.6 .6 .6],'LineWidth',.5) ;
uistack(GridHandle,'top')
My function GRIDXY is available at the Matlab File Exchange and can be downloaded here: http://www.mathworks.com/matlabcentral/fileexchange/9973
4 comentarios
Jos (10584)
el 2 de Mzo. de 2016
I am not sure about the units of the axes, but you can create these points using colon notation (start:step:end) So if the units are kilometers, this would do, I think:
Xpoints = AxisHandle.XLim(1):25:AxisHandle.XLim(2)
Ver también
Categorías
Más información sobre Data Distribution Plots en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!