function [map,maplegend] = country2mtx(varargin)
%COUNTRY2MTX matrix map for a country in the worldlo database
%
% 
%   [map,maplegend] = COUNTRY2MTX('countryname',scale) constructs a regular 
%   matrix map of a country in the worldlo POpatch database.  The scale 
%   factor represents the number of matrix entries per degree of latitude and 
%   longitude (eg: 10 entries per degree, 100 entries per degree).  The scale 
%   input must be scalar.  The returned matrix has values of 0 in the 
%   interior of the country, 1 on the border and 2 in the exterior.
%  
% 
%   [map,maplegend] = COUNTRY2MTX('countryname',scale,latlim,lonlim) uses the 
%   two element vector latitude and longitude limits to define the extent of 
%   the map.  If omitted, the limits are computed automatically.  
%   COUNTRY2MTX may not fill properly if the vector data extends beyond a 
%   pole.
% 
%   [map,maplegend] = COUNTRY2MTX('countryname',map1,maplegend1) uses the  
%   limits of the provided map.
%    
%   See also VEC2MTX, LTLN2VAL, IMBEDM, ENCODEM, INTERPM

%
%  Copyright 1996-1998 by Systems Planning and Analysis, Inc. and The MathWorks, Inc.
%  Written by: W. Stumpf
%   $Revision: 1.2 $    $Date: 1998/08/10 17:50:38 $


error(nargchk(2,4,nargin))

countryname = varargin{1};
if ~isstr(countryname); error('Country name must be a string'); end

[lat,lon] = extractm(worldlo('POpatch'),countryname);

[map,maplegend] = vec2mtx(lat,lon,varargin{2:end},'filled');


