MATLAB: Do I get an error when using the PATCHM function in Mapping Toolbox 3.0 (R2009b)

Mapping Toolbox

When using PATCHM or PATCHESM of the Mapping Toolbox with my custom coast line dataset:
load('map_data.mat')
axesm(map_gcm)
patchesm(olat, olon, -.1, 'c'); % or patchm
I get the following error:
??? Error using ==> adjustPolarVertices>adjustPV at 74
20 polar vertices: Too many.
Error in ==> adjustPolarVertices at 32
[lat, lon] = adjustPV(lat, lon, poleLat, p, s, e);
Error in ==> preprocessLatLonPolygons at 21
[lat, lon] = adjustPolarVertices(lat, lon, northPoleLat, tolSnap);
Error in ==> trimPolygonToQuadrangle at 42
[lat, lon] = preprocessLatLonPolygons(lat, lon, tolSnap, tolClose);
Error in ==> applyProjection>applyForward at 62
[lat, lon] = trimPolygonToQuadrangle( ...
Error in ==> doApplyProj at 31
[x, y, savepts] = mproj.applyForward(mproj, mstruct, in1, in2,
objectType);
Error in ==> applyProjection at 14
outputs = doApplyProj(mproj, varargin{:});
Error in ==> lambert at 30
varargout = applyProjection(mproj, varargin{:});
Error in ==> projectpatch>projectpatch2D at 60
[x,y] = feval(mstruct.mapprojection, ...
Error in ==> projectpatch at 16
[x, y] = projectpatch2D(mstruct, lat, lon);
Error in ==> patchm at 69
[x, y, zout, userdata] = projectpatch(mstruct, lat, lon, z);

Best Answer

This is expected behavior with the PATCHM and PATCHESM functions in the Mapping Toolbox 3.0 (R2009b). In older version of the toolbox the functions were not as efficient in checking for malformed data. Newer versions of Mapping Toolbox check if the data is not forming consistent polygons.
The vertex arrays in variables 'olat' and 'olon' can be plotted as lines, but not as polygons (patches) because they do not form a clean polygon topology. The error about too many polar vertices suggests this sort of problem. This can be seen by executing the following:
plot(olon, olat)
Note the junctions of 3 or more lines, and the jagged segments that jut out into the oceans without forming closed loops.
This would require a a significant amount of data cleanup to make sure the topology is correct.
As a workaround, try to use data that forms better topology. The GSHHS data set is offered in many resolutions. The following Technical Note explains more about possible places to get access to geospatial data:
<http://www.mathworks.com/support/tech-notes/2100/2101.html>