Error bars on a geoplot

3 次查看(过去 30 天)
Sam Hone
Sam Hone 2020-10-25
回答: Ayush 2025-6-25
Hello everyone,
My question is this: I have some local geographic coordinate data (lat lon) that I can plot using geoplot with a nice basemap in the background. That data has some error associated with it currently in the form of plus or minus some number of kilometers in the x and y directions of the plot. How can I add this error to the geoplot?
My current idea would be to plot the data and errorbars as utm coordinates using plot, and then somehow overlay that onto a geoplot of the same size with just the basemap. The problem is that apparently you cannot overlay a Cartesian axis on a geographic axis. Is there a better way to do this? Any help is appreciated.
Thanks
Sam
figure
plot(rutmx,rutmy,'b-','markersize',10,'linewidth',2) % plot instrument position in utms
hold on
errorbar(utmx,utmy,yerro,yerro,xerro,xerro,'ro') % plot data position and x and y errorbars in utm
xlim([2.466512276745778e+02 2.682540178252844e+02]) % limits (km)
ylim([4.513115121644600e+03 4.527966643304951e+03])
gx=geoaxes; % create axes
geolimits([40.73,40.87],[-78,-77.75]) % equivalent size to utm limits
% overlay plot on geoaxes?
  1 个评论
Abhishek
Abhishek 2025-6-23
Hi @Sam Hone, could you please post the coordinates defined in 'rutmx' and 'rutmy' ?

请先登录,再进行评论。

回答(1 个)

Ayush
Ayush 2025-6-25
Hi Sam,
I understand you need to plot errors on the graph and you are correct that MATLAB doesn't directly support overlaying Cartesian (plot) and geographic (geoplot) axes in the same figure. However, there are better ways to represent positional uncertainty/error on a geographic plot.
You can use geoplot with geoscatter and size/color coding. Also, you can represent the error bounds around geographic points using either:
  1. Error Circles via geoplot + manually computed lat/lon offsets: if your error is symmetric and relatively small.
  2. Ellipses or Asymmetric Bounds: Manually compute geodetic offsets in lat/lon: if you have large error.
You can plot positional uncertainity as circles on geoplot using following agorithm:
  1. Approximate conversion from km to degrees:
At mid-latitudes:
  • 1 km in latitude ≈ 0.009 degrees
  • 1 km in longitude ≈ 0.009 / cos(latitude)
2. Compute circle offsets for each point
Here is a code snippet depicting the above algorithm on one point:
% take any sample point (in degrees)
lat = 37.7749;
lon = -122.4194;
% Error radius, remember to take it in km
err_km = 1;
% Converting km to degrees
r_lat = err_km / 111; % 1 deg ≈ 111 km
r_lon = err_km / (111 * cosd(lat));
% Create a circle
theta = linspace(0, 2*pi, 100);
lat_circ = lat + r_lat * sin(theta);
lon_circ = lon + r_lon * cos(theta);
figure
geoplot(lat, lon, 'ro'); hold on
geoplot(lat_circ, lon_circ, 'r-')
geobasemap streets
You can repeat this for each point.
You can refer to the following official documentation links for more information:
Hope it helps!

类别

Help CenterFile Exchange 中查找有关 Geographic Plots 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by