Note: This page has been translated by MathWorks. Please click here

To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

Geographic shape vector

`s = geoshape()`

s = geoshape(lat,lon)

s = geoshape(lat,lon,Name,Value)

s = geoshape(structArray)

s = geoshape(lat,lon,structArray)

A geoshape vector is an object that represents geographic vector features with either point, line, or polygon topology. The features consist of latitude and longitude coordinates and associated attributes. If these attributes vary spatially they are termed Vertex properties. These elements of the geoshape vector are coupled such that the length of the latitude and longitude coordinate property values are always equal in length to any additional dynamic Vertex properties. Attributes which only pertain to the overall feature (point, line, polygon) are termed Feature properties. Feature properties are not linked to the auto-sizing mechanism of the Vertex properties. Both of the property types can be dynamically added to a geoshape vector using the standard dot notation.

A geoshape vector is always a column vector.

constructs
an empty geoshape vector, `s`

= geoshape()`s`

, with the following
default property settings.

s = 0x1 geoshape vector with properties: Collection properties: Geometry: 'line' Metadata: [1x1 struct] Vertex properties: Latitude: [] Longitude: []

For an additional example see: Construct a Default geoshape Vector

constructs
a geoshape vector and sets the `s`

= geoshape(`lat`

,`lon`

)`Latitude`

and `Longitude`

property
values equal to vectors `lat`

and `lon`

. `lat`

and `lon`

may
be either numeric vectors of class single or double, or cell arrays
containing numeric vectors of class single or double. For an example,
see Construct a geoshape Vector Specifying Latitude and Longitude
Values.

constructs
a geoshape vector from the input `s`

= geoshape(`lat`

,`lon`

,`Name`

,`Value`

)`lat`

and `lon`

vectors,
and then adds dynamic properties to the geoshape vector using the `Name`

, `Value`

argument
pairs.

If

`Value`

is in a cell array containing numeric values, logical or character vectors, then this property is designated as a Vertex property. Otherwise, this property is designated as a Feature property.If the specified

`Name`

is`Metadata`

and the corresponding`Value`

is a scalar structure, then`Value`

is copied to the`Metadata`

property. Otherwise, an error is issued.

For an example, see: Construct a geoshape Vector Specifying a Name-Value Pair.

constructs
a `s`

= geoshape(`structArray`

)`geoshape`

vector from the fields of the structure
array, `structArray`

.

If

`structArray`

contains the field`Lat`

, and does not contain a field`Latitude`

, then the`Latitude`

property values are set equal to the`Lat`

field values. If`structArray`

contains the field,`Lon`

, and does not contain a field`Longitude`

, then the`Longitude`

property values are set equal to the`Lon`

field values.If

`structArray`

contains both`Lat`

and`Latitude`

fields, then the`Latitude`

property values are set equal to the`Latitude`

field values and a`Lat`

dynamic property is created whose values are set equal to the`Lat`

field values. Similar behavior occurs for`Longitude`

and`Lon`

field combinations if present in`structArray`

.If

`structArray`

is a scalar structure which contains the field`Metadata`

and the field value is a scalar structure, then the`Metadata`

field is copied to the`Metadata`

property. If`structArray`

is a scalar structure and the`Metadata`

field is present and is not a scalar structure, then an error is issued. If`structArray`

is not scalar then the`Metadata`

field is ignored.Other fields of

`structArray`

are assigned to`s`

and become dynamic properties. Field values in`structArray`

that are not numeric values, character vectors, logical, or cell arrays of numeric values, logical, or character vectors are ignored.

For an example, see Construct a geoshape Vector from a Structure Array.

constructs
a new `s`

= geoshape(`lat`

,`lon`

,`structArray`

)`geoshape`

vector and sets the `Latitude`

and `Longitude`

properties
equal to the numeric vectors, `lat`

and `lon`

,
and sets the field values of struct `structArray`

as
dynamic properties.

If

`structArray`

contains the fields`Lat`

,`Latitude`

,`Lon`

or`Longitude`

, then those field values are ignored since the`Latitude`

and`Longitude`

property values are set by the`lat`

and`lon`

input vectors.If

`structArray`

is a scalar structure and contains the field`Metadata`

, and the field value is a scalar structure, then it is copied to the`Metadata`

property value. Otherwise, an error is issued if the`Metadata`

field is not a structure, or ignored if`structArray`

is not scalar.

For an example, see Construct a geoshape Vector Using Cell Arrays.

append | Append features to geoshape vector |

cat | Concatenate geoshape vectors |

disp | Display geoshape vector |

fieldnames | Dynamic properties of geoshape vector |

isempty | True if geoshape vector is empty |

isfield | True if dynamic property exists |

isprop | True if property exists |

length | Number of elements in geoshape vector |

properties | Properties of a geoshape vector |

rmfield | Remove dynamic property from geoshape vector |

rmprop | Remove properties from geoshape vector |

size | Size of `geoshape` vector |

struct | Convert geoshape vector to scalar structure |

vertcat | Vertical concatenation for geoshape vectors |

Value. To learn how value classes affect
copy operations, see Copying Objects in
the MATLAB^{®} documentation.

The following examples show how to build geoshape vectors with single or multiple features.

Construct geoshape Vector and Dynamically Add Feature Property

Construct a geoshape Vector and Define Multiple Point Features

You can attach dynamic feature and vertex properties to a geoshape vector by either adding them at construction or by using the dot (.) notation after construction. This is similar to adding new fields to a structure. The following examples highlight the two ways by which a geoshape vector with the same features can be created. In each example the data is read from the same file into a structure array. The first example dynamically adds the features to a geoshape object created with the default constructor. The second example uses the structure array as an argument to constructor which builds the geoshape vector.

Construct a geoshape Vector and Dynamically Add Multiple Line Features

The geoshape vector can be indexed like any MATLAB vector. You can access any element of the vector to obtain a specific feature. The following examples demonstrate this behavior.

Use Indexing to Append a Single Point and a Shape to a geoshape Vector

The following example demonstrates the behavior of differing vector representations of the

`Latitude`

and`Longitude`

properties.If either

`Latitude`

or`Longitude`

is set to [ ], then both coordinate properties are set to [ ] and all dynamic Vertex or Feature properties are removed.If a Vertex or Feature property is set to [ ], then it is removed from the object.

Was this topic helpful?