Distinguish land from ocean in harbors
23 views (last 30 days)
Show older comments
I'm trying to distinguish land from ocean in harbors and have tried using the highest resolution maps from gshhs, but it isn't detailed enough. Below are is an example showing that it isn't detailed to the level I want. The one to the left showing th coastline boundaries and the other one showing the geoplot with basemap = 'streets'
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1161743/image.png)
Since the map is able to plot in such detail, shown below, I would imagine that it should be able to distingusih land from ocean, just based on the colors.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1161748/image.png)
Appriciate any help here! Thanks in advance.
0 Comments
Answers (2)
Avni Agrawal
on 17 Nov 2023
Hi,
I understand that you want to distinguish land and ocean in different color. The 'streets' basemap in MATLAB automatically distinguishes land from ocean by using different colors.
For example, you can use the GSHHS dataset or another high-resolution shoreline dataset to add a coastline to your map. You can then use the 'geoplot' function to display the coastline in a contrasting color.
% Define the latitude and longitude limits of the area of interest
latlim = [33.70 33.78]; % limits for Port of Los Angeles
lonlim = [-118.28 -118.22]; % limits for Port of Los Angeles
% Create a geographic axes and set the basemap to 'streets'
ax = geoaxes;
geobasemap(ax, 'streets');
geolimits(latlim, lonlim)
% Load the GSHHS coastline data and display it on the map
load coastlines
% Add some data to the map (replace this with your own data)
geoplot(ax, [33.73 33.75], [-118.25 -118.24], 'k')
In this code, 'geoaxes' is used to create a geographic axes, `geobasemap` is used to set the basemap to 'streets', and `geolimits` is used to set the latitude and longitude limits of the map. The `load` command is used to load the GSHHS coastline data, and `geoplot` is used to display the coastline on the map.
Please note that the `coastlines` data loaded by MATLAB might not be as high resolution as you need. You would need to replace that with your own high-resolution coastline data.
If you want to distinguish land from ocean more clearly, you could consider using a different basemap that provides more contrast, such as 'satellite' or 'topographic'. You can set the basemap using the `geobasemap` function, like this: `geobasemap(ax, 'satellite');`
% Define the latitude and longitude limits of the area of interest
latlim = [33.70 33.78]; % limits for Port of Los Angeles
lonlim = [-118.28 -118.22]; % limits for Port of Los Angeles
% Create a geographic axes and set the basemap to 'streets'
ax = geoaxes;
geobasemap(ax, 'satellite');
geolimits(latlim, lonlim)
% Load the GSHHS coastline data and display it on the map
load coastlines
% Add some data to the map (replace this with your own data)
geoplot(ax, [33.73 33.75], [-118.25 -118.24], 'k')
Please take a look at this documentation for better understanding:
I hope this helps.
0 Comments
Image Analyst
on 17 Nov 2023
If you want to deal with your picture as a digital image, then you can segment out the water using the Color Thresholder app on the apps tab of the tool ribbon. You can export the function that makes a binary map of the water and then use that to make the water pixels any color that you want. Let me know if you can't figure it out.
0 Comments
See Also
Categories
Find more on Geographic Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!