Fillm function paints all map instead of area inside polygon on map. How to solve this issue?
1 view (last 30 days)
Show older comments
Fillm function paints all map instead of area inside polygon on map. When I try to plot a polygon and fill it with colour, all map becomes painted instead of area inside polygon.
Here is a script.
clear; clc; % Create points.
map_points = [68.7292615956929 34.0010378790487;... 73.2229449019988 43.9876119331490;... 73.2229256423856 43.9875902580262;... 73.2888418399766 43.9496595487371;... 73.2888264344291 43.9497228221104;... 73.2813009211009 16.0527538972278;... 73.2813179480194 16.0527629280312;... 69.9943355657147 17.6879497908559;... 69.9943335605433 17.6879366808610;... 68.7292495263122 34.0010348649775];
% Create map. figure landareas = shaperead('landareas.shp','UseGeoCoords',true); axesm ('cassini', 'Frame', 'off', 'Grid', 'on'); geoshow(landareas,'FaceColor',[1 1 .5]); hold all
% Plot filled polygon. fillm(map_points(:,1), map_points(:,2), 'r'); alpha(0.5)
How to colour this polygon without painting all map? Thanks in advance.
0 Comments
Answers (1)
ChristianW
on 10 Feb 2013
Your polygon is self-intersecting. You can see it, if you zoom in to the bottom corner. To fix it, define better points, eg:
map_points = [ 68.7292615956929 34.0010378790487
73.2229449019988 43.9876119331490
73.2888418399766 43.9496595487371
73.2813009211009 16.0527538972278
69.9943355657147 17.6879497908559
68.7292495263122 34.0010348649775 ];
0 Comments
See Also
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!