Main Content

isShapeMultipart

True if polygon or line has multiple parts

Syntax

tf = isShapeMultipart(xdata, ydata)

Description

tf = isShapeMultipart(xdata, ydata) returns 1 (true) if the polygon or line shape specified by xdata and ydata consists of multiple NaN-separated parts (i.e. has inner or multiple polygon rings or multiple line segments). The coordinate arrays xdata and ydata must match in size and have identical NaN locations.

Examples

collapse all

Create a simple data set and check if it's multipart. If a data set contains NaN separators, isShapeMultipart returns 1 , otherwise 0.

sample_xdata = [0 0 1];
sample_ydata = [0 1 0];
isShapeMultipart(sample_xdata,sample_ydata)
ans = logical
   0

Create simple multipart data sets.

multi_xdata = [0 0 1 NaN 2 2 3 3];
multi_ydata = [0 1 0 NaN 2 3 3 2];
isShapeMultipart(multi_xdata,multi_ydata)
ans = logical
   1

Check a real data set.

load coastlines
isShapeMultipart(coastlat,coastlon)
ans = logical
   1

Check the data in a shapefile.

S = shaperead('concord_hydro_area.shp');
isShapeMultipart(S(1).X, S(1).Y)
ans = logical
   0

Check another dataset in the shapefile.

isShapeMultipart(S(14).X, S(14).Y)
ans = logical
   1

Version History

Introduced in R2006a