- 2-D and 3-D grids - MATLAB meshgrid (mathworks.com)
- Project geolocated data grid in h = 0 plane on axesm-based map - MATLAB pcolorm (mathworks.com)
- Add or modify graphic scale on axesm-based map - MATLAB scaleruler (mathworks.com)
- Map Customization - MATLAB & Simulink (mathworks.com)
Creating a map using x/y data
25 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I have X, Y, Z data where X and Y are lon and lat coordinates and Z is value of interest. All variables are 12500*1800 (too large to attach here).
I would like to plot these variables on map axes so I can add shape files with additional info., aswell as a scale bar.
clf
axesm('MapProjection','mercator') %define axis
surfm(y,x,z) % plot X/Y data
S = shaperead('study_site.shp','UseGeoCoords',true); %add shapefile on top of X/Y data
info = shapeinfo('study_site.shp');
crs = info.CoordinateReferenceSystem
geoshow(S,'FaceColor','white');
Apart from needing to adjust the axes limits, this looks good. But, I am struggling to add a scale bar. When I try to do this, the plot is just replaced with a scale bar:
hold on
scaleruler on
How do I do this properly?
Also, how do I add lat and lon information to the frame?
0 commentaires
Réponses (1)
Harshit
le 15 Sep 2023
Hi,
I understand that you want to plot the latitudes and longitudes onto the map axes.
For such large variables of "X", "Y", and "Z", I suggest creating a meshgrid of lon and lat coordinates first. Then, you can use the "pcolorm" function to plot the "Z" variable on the map.
Additionally, you use the "scaleruler" function to add a scale bar to the frame.
Here's an updated version of your code incorporating the above suggestions:
clf
axesm('MapProjection', 'mercator')
% Create a meshgrid of lon and lat coordinates
[lon_grid, lat_grid] = meshgrid(x, y);
% Plot the Z variable using pcolorm
pcolorm(lat_grid, lon_grid, z);
S = shaperead('study_site.shp', 'UseGeoCoords', true);
info = shapeinfo('study_site.shp');
crs = info.CoordinateReferenceSystem;
geoshow(S, 'FaceColor', 'white');
% Adjust axes limits if needed
% xlim([lon_min, lon_max]);
% ylim([lat_min, lat_max]);
% Add scale bar
scaleruler('RulerStyle', 'patches', 'Units', 'km', 'FontSize', 10);
% Add latitude and longitude information to the frame
framem on;
gridm on;
mlabel on;
plabel on;
To find more about the functions used here, kindly refer to the following documentation pages:
Hope the above information resolves your issue.
Regards,
Harshit
0 commentaires
Voir également
Catégories
En savoir plus sur Mapping Toolbox dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!