# shapely.get_coordinates#

get_coordinates(geometry, include_z=False, return_index=False)#

Gets coordinates from a geometry array as an array of floats.

The shape of the returned array is (N, 2), with N being the number of coordinate pairs. With the default of `include_z=False`, three-dimensional data is ignored. When specifying `include_z=True`, the shape of the returned array is (N, 3).

Parameters
geometryGeometry or array_like
include_zbool, default False

If, True include the third dimension in the output. If a geometry has no third dimension, the z-coordinates will be NaN.

return_indexbool, default False

If True, also return the index of each returned geometry as a separate ndarray of integers. For multidimensional arrays, this indexes into the flattened array (in C contiguous order).

Examples

```>>> from shapely import LineString, Point
>>> get_coordinates(Point(0, 0)).tolist()
[[0.0, 0.0]]
>>> get_coordinates(LineString([(2, 2), (4, 4)])).tolist()
[[2.0, 2.0], [4.0, 4.0]]
>>> get_coordinates(None)
array([], shape=(0, 2), dtype=float64)
```

By default the third dimension is ignored:

```>>> get_coordinates(Point(0, 0, 0)).tolist()
[[0.0, 0.0]]
>>> get_coordinates(Point(0, 0, 0), include_z=True).tolist()
[[0.0, 0.0, 0.0]]
```

When return_index=True, indexes are returned also:

```>>> geometries = [LineString([(2, 2), (4, 4)]), Point(0, 0)]
>>> coordinates, index = get_coordinates(geometries, return_index=True)
>>> coordinates.tolist(), index.tolist()
([[2.0, 2.0], [4.0, 4.0], [0.0, 0.0]], [0, 0, 1])
```