Accelerating the pace of engineering and science

# Documentation Center

• Trial Software

# flatearthpoly

Insert points along date line to pole

## Syntax

[latf,lonf] = flatearthpoly(lat,lon)
[latf,lonf] = flatearthpoly(lat,lon,longitudeOrigin)

## Description

[latf,lonf] = flatearthpoly(lat,lon) trims NaN-separated polygons specified by the latitude and longitude vectors lat and lon to the limits [-180 180] in longitude and [-90 90] in latitude, inserting straight segments along the +/- 180-degree meridians and at the poles. Inputs and outputs are in degrees.

[latf,lonf] = flatearthpoly(lat,lon,longitudeOrigin) centers the longitude limits on the longitude specified by the scalar longitude longitudeOrigin.

## Examples

Vector data for geographic objects that encompass a pole will inevitably encounter or cross the date line. While the toolbox properly displays such polygons, they can cause problems for functions like the polygon intersection and Boolean operations that work with Cartesian coordinates. When these polygons are treated as Cartesian coordinates, the date line crossing results in a spurious line segment, and the polygon displayed as a patch does not have the interior filled correctly.

```antarctica = shaperead('landareas', 'UseGeoCoords', true,...
'Selector', {@(name) strcmp(name,'Antarctica'), 'Name'});
figure; plot(antarctica.Lon, antarctica.Lat); ylim([-100 -60])```

The polygons can be reformatted more appropriately for Cartesian coordinates using the flatearthpoly function. The result resembles a map display on a cylindrical projection. The polygon meets the date line, drops down to the pole, sweeps across the longitudes at the pole, and follows the date line up to the other side of the date line crossing.

```[latf, lonf] = flatearthpoly(antarctica.Lat', antarctica.Lon');
figure; mapshow(lonf, latf, 'DisplayType', 'polygon')
ylim([-100 -60])
xlim([-200 200])
axis square ```