Extract the coordinates of shorelines and plot them
    조회 수: 7 (최근 30일)
  
       이전 댓글 표시
    
Hi guys,
I am drawing a world map, and I would like to plot the outline of the coastlines on a specific portion of the map that I desire (e.g. north sea & the baltic).
In order to do this, I am using the INPOLYGON function, to draw a polygon that includes the desired coastlines, such that I can then extract their coordinates and plot them separately. However, this function seems to be removing the NaN values that are present in the original coordinate set, therefore the end result is that the islands become connected by a a line to the shorelines.
Therefore, is there any way to prevent this from happening?
(the code is below)
 %Load Data
 load coastlines 
 %Extract areas
    %Coordinates
    BalticUK_ECA = [-4 62 ; 15 62 ; 20 66 ; 26 66 ; 32.5 57 ; 0 48 ; -5 48 ; -5 50.25 ; -1 52 ;-4 57 ; -5 58 ; 
 -4 58 ; -4 62] ;
    %Indices
    [BalticUK_in, BalticUK_on] = inpolygon(coastlon, coastlat, BalticUK_ECA(:,1), BalticUK_ECA(:,2)) ;
    %Extraction
    BalticUK_lon = coastlon(BalticUK_in) ;
    BalticUK_lat = coastlat(BalticUK_in) ;
 %Figure
 fig = figure ; 
 fig.Position = [ 100 100 1100 500 ] ;
 %Plot
 plot(coastlon, coastlat)
 hold on
 plot(BalticUK_ECA(:,1), BalticUK_ECA(:,2)) 
 hold on
 plot(coastlon(BalticUK_in), coastlat(BalticUK_in))
 %Formatting
 grid on
 grid minor
 ax = gca ;
 ax.XLim = [-6 33] ;
 ax.YLim = [47 67] ;
I have tried to edit the INPOLYGON function but it seems to be too difficult and dangerous in my opinion so I have left it as is. Any other ideas?
Thanks in advance for your help,
KMT.
댓글 수: 0
답변 (0개)
참고 항목
카테고리
				Help Center 및 File Exchange에서 Creating, Deleting, and Querying Graphics Objects에 대해 자세히 알아보기
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
