
%
% High-resolution worlwide coastlines, rivers and borders for MatLab 
%
%
% MatLab software contains a built-in dataset of the world coastline coordinates; 
% namely, a file with the latitudes and longitudes (expressed in decimal degrees)
% of about 10000 points on the world shorelines. In particular, the file is named
% "coastlines.mat", and contains two series: "coastlon" and "coastlat" that can be 
% simply displayed with the command plot(coastlon,coastlat,'-b') for identifyng the 
% position of spatial points in vectors (x,y) without using geographical shapefiles 
%
% Unfortunately, the "coastlines" dataset has low resolution and does not provide 
% relevant natural and social features, such as rivers and political boundaries. 
% As an alternative, the CIA World DataBank II (created by the US gov in the '80s) 
% has not such limitations, but is not ready for MatLab and its ASCII translation
% contain some numerical errors (coordinates out of range)
%
% In this contribution we provide a cleaned and ready-to-use version of the WDB2, 
% of coastlines and related features, divided by 5 continents: 
% - Africa, 
% - Asia, 
% - Europe,
% - Noth America, 
% - South America, 
% in *.mat format. Each file contains 3 bivariate arrays X, Y, Z :
% - X, coastlines, 
% - Y, land rivers, 
% - Z, political boundaries, 
% - W, federal boundaries (only for NorthAme ...)  
% with variables [latitudes, longitudes] of each array, respectively.
%

help Coast_demo

disp(' ')
disp('press Enter to continue ...')
pause 

load NorthAme
load coastlines 

figure 
plot(coastlon,coastlat,'-k')
title('World Coastlines in Low Resolution')
hold on

disp(' ')
disp('press Enter to continue ...')
pause 

plot(X(:,2),X(:,1),'.b','markersize',2)
title('North America Coastlines in High Resolution')

disp(' ')
disp('press Enter to continue ...')
pause 

plot(Y(:,2),Y(:,1),'.g','markersize',2)
title('North America Rivers')

disp(' ')
disp('press Enter to continue ...')
pause 

plot(Z(:,2),Z(:,1),'.r','markersize',3)
title('North America National Borders')

disp(' ')
disp('press Enter to continue ...')
pause 

plot(W(:,2),W(:,1),'.m','markersize',2)
title('Coastlines (Blue),  Rivers (Green),  Boarders (Red, Magenta)')

disp(' ')
disp('press Enter to continue ...')
pause 

Ix=find( (X(:,2)>-78 & X(:,2)<-75) & (X(:,1)>36 & X(:,1)<40) );
Iy=find( (Y(:,2)>-78 & Y(:,2)<-75) & (Y(:,1)>36 & Y(:,1)<40) );
Iw=find( (W(:,2)>-78 & W(:,2)<-75) & (W(:,1)>36 & W(:,1)<40) );

figure
plot(X(Ix,2),X(Ix,1),'.b','markersize',2); hold on
plot(Y(Iy,2),Y(Iy,1),'.g','markersize',2)
plot(W(Iw,2),W(Iw,1),'.m','markersize',2)
plot(-77.0364,38.8951,'Ok','markersize',9,'markerfacecolor','r') 
title('Washington District Columbia'); axis image; grid


