Creating a map with Longitude, Latitude, Concentration (vector of values over time)

7 vues (au cours des 30 derniers jours)
Ilay Green
Ilay Green le 31 Juil 2023
Hey,
Im trying to create a map with longitude and latitude, different variables (e.g conecntration, temperature, etc).
I read a little bit about imagesc(x,y,C) and I decided i'll try to use it, The longitude and latitude (x,y) work well, but my values (C) gives me an error.
let's say my grid is 3x3 matrix.
I get this error:
Error using newplot (line 86)
Adding Cartesian plot to geoaxes is not supported.
Error in matlab.graphics.internal.newplotimagewrapper (line 7)
axReturn = newplot(varargin{:});
Error in imagesc (line 52)
hh = image(varargin{:}, 'CDataMapping', 'scaled');
Error in test (line 2)
imagesc(Longitude(24:26),Latitude(114:116),grid)
Any solutions?
*And another small question: im trying to add geobasemap satellite and it doesnt seem to work. is it impossible with imagesc()?
Thanks

Réponses (1)

Daniel Bengtson
Daniel Bengtson le 31 Juil 2023
This is an admittedly hackish workaround that I used to navigate the same issue you are having. No promises that it will work for your exact application, but might be a starting point.
You can cheat and overlay a second set of axes on top of or below the geoaxes if you are visualizing a sufficiently small area that is far enough from the poles where you can ignore the impact of how equal units of longitude result in different distances across the earths surface. (If you are visualizing very large areas or are near the poles there will be dilation in the X direction on the upper or lower edge, whichever is closest to the pole, and this is not likely to work.)
Here is an old question I asked that had some sample code and examples of what it looked like.
I had found a state GIS server that allowed for programmatic download of satelite image tiles. By using the corner GPS coordinates and the actual pixel size of the figure that the initial geoscatter created, I could build a URL for the GIS server to query the background image that I knew perfectly matched the figure.
h = figure('units','pixels','outerposition',[-1927,873,1936,1056],'visible','on'); %change the pixel locations to work for your figure size and monitor layout
ax1 = geoaxes;
geoscatter()%geoplot something
pos = getpixelposition(ax1); %corner locations of ax1 in pixels
[lat,lon] = geolimits(ax1); %corner positions of ax1 in lat, long
[utmLat,utmLong,~] = deg2utm(lat,lon); %convert to UTM using function from file exchange
% range of pos in pixels
pixelsHigh = (pos(4) - pos(2));
pixelsWide = (pos(3) - pos(1));
% build URL
url_img = strcat('https://ortho.gis.iastate.edu/arcgis/services/ortho/naip_2019_nc/ImageServer/WMSServer?service=WMS&request=GetMap&version=1.1.1&layers=naip_2019_nc&styles=&format=image/png&transparent=true&height=',...
string(round(pixelsHigh)),...
'&width=',...
string(round(pixelsWide)),...
'&srs=EPSG:32615&bbox=',string(utmLat(1)),',',string(utmLong(1)),',',string(utmLat(2)),',',string(utmLong(2)));
% query image
urlwrite(url_img, 'tempbg.png');
% define cart axes of identical pizel size and position as ax1
ax2 = axes('Units', ax1.Units, 'ActivePositionProperty', 'outerposition', 'OuterPosition', ax1.OuterPosition);
% place image on axes
im = imread([logFolder.path,'tempbg.png']);
imshow(im);
uistack(ax1,'top'); %bring ax1 to the front
ax1.Visible = 'off'; %set the background of ax1 to invisible
The same mechanism could be used to overlay any of the cartesian plots over top of a geo axes. Just need to use the pixel relationship of ax1 to ax2 as a method of scaling and converting latitude and longitude to the cartesian coordinates of the image.

Catégories

En savoir plus sur Geodesy and Mapping 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!

Translated by