Accelerating the pace of engineering and science

• Trials

# reducem

Reduce density of points in vector data

## Syntax

[latout,lonout] = reducem(latin,lonin)
[latout,lonout] = reducem(latin,lonin,tol)
[latout,lonout,cerr] = reducem(...)
[latout,lonout,cerr,tol] = reducem(...)

## Description

[latout,lonout] = reducem(latin,lonin) reduces the number of points in vector map data. In this case the tolerance is computed automatically.

[latout,lonout] = reducem(latin,lonin,tol) uses the provided tolerance. The units of the tolerance are degrees of arc on the surface of a sphere.

[latout,lonout,cerr] = reducem(...) in addition returns a measure of the error introduced by the simplification. The output cerr is the difference in the arc length of the original and reduced data, normalized by the original length.

[latout,lonout,cerr,tol] = reducem(...) also returns the tolerance used in the reduction, which is useful when the tolerance is computed automatically.

## Examples

Compare the original and reduced outlines of the District of Columbia from the usastatehi state outline data:

```dc = shaperead('usastatehi',...
'UseGeoCoords', true,...
'Selector',{@(name) ...
strcmpi(name,'district of columbia'), 'Name'});
lat = extractfield(dc, 'Lat')';
lon = extractfield(dc, 'Lon')';
[latreduced, lonreduced] = reducem(lat, lon);

lonlim = dc.BoundingBox(:,1)' + [-0.02 0.02];
latlim = dc.BoundingBox(:,2)' + [-0.02 0.02];

subplot(1,2,1)
usamap(latlim, lonlim); axis off
geoshow(lat, lon,...
'DisplayType', 'polygon', 'FaceColor', 'blue')

subplot(1,2,2)
usamap(latlim, lonlim); axis off
geoshow(latreduced, lonreduced,...
'DisplayType', 'polygon', 'FaceColor', 'yellow')```