Why does geodensityplot create a line rather than a full-cover colormap?

6 views (last 30 days)
I am creating a geoaxes plot inside a panel in AppDesigner (not an issue w/ AppDesigner or panel). My code is as follows:
gx = geoaxes(app.MapPlotPanel);
geobasemap(gx,'topographic')
geodensityplot(gx,lats,lons,weights)
where lats, lons, weights are all of size 1xN.
I am creating these arrays as
% (webscrape not included but I can assure you the data's fine)
weights = double(weights); % cast webscraped data as double for correct format
lats = -90:2.5:90;
lons = -180:5:180;
transpose(weights);
transpose(lats);
transpose(lons); % with or without transpose doesn't fix
in an external function and passing back in a ButtonPushedCallback. The weights are in the correct order and everything to be plotted this way. When I plot this, I get the following line:
I have tested many many times to see if my arrays were the right size, same shape, etc.
Within my external function I plotted the data just to see what was up, and it looks like this 3D plot is actually projecting this way on my geodensityplot as well, instead of in a "meshed" way... from the top/2D view, it's just a straight line. It is curved on the map above because MATLAB takes into account the spherical distortion of the line.
plot3(lats,lons,weights)
Why is my densityplot not plotting the density? I mean this to be like a colormap where the whole -90 - 90, -180 - 180 surface is colored based on the value of weights(i) at lat(i) and lon(i). I have tried plotting in other ways instead of geodensityplot, but no matter what plotting function I use, they all end up in a warped line.
Plotting data that DOESNT cover the full surface creates a plot that makes sense... arrays that I'm plotting are the same format (all are 1xn).
w/ the little blobs being where the example data is. The points are also webscraped so I know it's not an issue w/ the data pulls/format.
I do not fully understand the meshgrid function but I believe it may be useful in some way. If anyone could point me in the right direction to project my data correctly I would appreciate it greatly. Thank you!
Using R2023A and Mapping Toolkit (not sure if required but shouldn't be).
  2 Comments
Caroline
Caroline on 4 Jul 2023
using contourf I am able to get the map I need, but when using contourfm (for a map), I get the error
Error using adjustPolarVertices>adjustPV
4 polar vertices: Too many.
How can I avoid this error?
VBBV
VBBV on 4 Jul 2023
Edited: VBBV on 4 Jul 2023
Can you share the code snippet and data you use for plotting ?

Sign in to comment.

Answers (1)

VBBV
VBBV on 4 Jul 2023

Use geoplot3 or geoglobe functions if you want 3D plots. They are able to handle the data well than other 2D/3D plot functions.

Check also if the lats lons data are in WGS84 coordinate reference system since geoaxes function uses the same type of coordinate system.

  1 Comment
Caroline
Caroline on 4 Jul 2023
geoglobe plots the same curved line rather than the entire surface, and the lats/lons are in WGS84.

Sign in to comment.

Categories

Find more on Image Processing Toolbox in Help Center and File Exchange

Products


Release

R2023a

Community Treasure Hunt

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

Start Hunting!