How to get geoshow to fill inside a polygon rather than outside?

조회 수: 20 (최근 30일)
Darcy Cordell
Darcy Cordell 2020년 5월 13일
편집: Darcy Cordell 2020년 5월 13일
I am using geoshow to plot filled polygons on a map. The polygons represent lakes. I have latitude and longitude coordinates saved as vectors. This is the command I use:
geoshow(lat,lon,'DisplayType','polygon');
When I use geoshow, MATLAB fills everything outside the polygon (e.g. the whole world from [-180 180] longitude and [-90 90] latitude). Everything except the lake is filled. The first picture shows the whole world:
The second picture shows the same MATLAB figure but zoomed in to the lake. So the lake is being plotted, its just the fill is the wrong way round.
When I use the "fill" command in MATLAB using the same latitude and longitude vectors, the lake polygon is filled correctly as shown below
fill(lon,lat,'y')
Even more bizarre is that I am plotting 4 lakes in total, and two of them work fine using both "fill" and "geoshow". But two of them result in the wrong polygon fill. Two sets of coordinates are attached (lat_lon_correct_fill.mat and lat_lon_wrong_fill.mat).
Any help with this is appreciated. The latitude and longitude vectors are attached.
Note: This has been tested on both 2020a and 2016b and the same problem occurs for both. So I don't think it is a version issue.

답변 (1개)

Darcy Cordell
Darcy Cordell 2020년 5월 13일
편집: Darcy Cordell 2020년 5월 13일
Fix found here:
Coordinates must be clockwise.
It is strange that "fill" works. Why wouldn't MATLAB just make a check for CW vs. CCW?

제품


릴리스

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by