Layer

Luo_Suppe2026-08-15

gma.gio.Layer

[class] Layer(data = None, name = None, gtype = None, ftypes = None, crs = None, **kwargs):

Initialize a Layer object.

Optional:

data = Layer||Geometry||Feature||list||None. Default None.

The data source to create the Layer. It can be:

1) Another GMA Layer object.

2) A Geometry object or a Feature object, or a list of Geometry/Features.

3) None, create an empty Layer.

name = str||None. Default None.

The name of the Layer. If data is a Layer, name can not be set.

gtype = str||None. Default None.

The geometry type of the Layer. Supported geometry type include:

'Point', 'MultiPoint', 'Line', 'MultiLine', 'Polygon', 'MultiPolygon'.

If data is a Layer, gtype can not be set.

ftypes = FieldType||list||dict||None. Default None.

The field types of the Layer. It can be:

1) A FieldType object.

2) A list of FieldType objects.

3) A dict of field name and field type.

If data is a Layer, ftypes can not be set.

crs = str||int||class||None. Default None.

The coordinate system of the Layer. Can be EPSG, WKT, Proj4, and other types of coordinate characters. If data is a Layer, crs can not be set.

**kwargs:

Other parameters passed to _algos.geodatabase.GeoDatabase.

Example

from gma import gio

ly = gio.open_vector('Australia.shp')
print('features:', len(ly))
print('geometry:', ly.gtype)
print('fields  :', len(ly.ftypes.names))
print('bounds  :', tuple(round(v, 2) for v in ly.bounds))
features: 11
geometry: Polygon
fields  : 123
bounds  : (112.91, -43.62, 153.62, -10.05)

Method

add_feature(*features)

Add features to Layer.

Parameters:

*feature: Feature.

One or more vector features.

Returns:

Type: None.

Modify the layer in place.

Example:

from gma import gio

ly = gio.open_vector('Australia.shp')
ft = gio.open_vector('Australia.shp').get_feature(0)
print('Before:', len(ly))
ly.add_feature(ft)
print('After :', len(ly))
print('last feature:', ly.get_feature(len(ly) - 1).fields.get('name'))
Before: 11
After : 12
last feature: Western Australia

add_field(name = None, dtype = "UNKNOWN")

Add a field to Layer.

Optional:

name: str. Default None.

The name of the field. None for dtype name.

dtype: str. Default 'UNKNOWN'.

The data type of the field. See `dtypes.DefinedFieldDataTypes` for valid types.

Returns:

Type: None.

Modify the layer in place.

Example:

from gma import gio

ly = gio.open_vector('Australia.shp')
print('Before:', ly.ftypes.names[-3:])
ly.add_field('new_field', 'String')
print('After :', ly.ftypes.names[-3:])
print('first value:', ly.get_feature(0).fields.get('new_field'))
Before: ['FCLASS_TLC', 'Shape_Leng', 'Shape_Area']
After : ['Shape_Leng', 'Shape_Area', 'new_field']
first value: 

boundary(**kwargs)

Creates buffer polygons around input features to a specified distance. **kwargs:

Other parameters passed to _algos.geo.layer.vector_translate.

Returns:

Type: Layer.

A new layer with the operation applied.

Example:

from gma import gio

ly = gio.open_vector('Australia.shp')
print('Before:', len(ly), ly.gtype)
r = ly.boundary()
print('After :', len(r), r.gtype)
if len(r): print('first feature:', r.get_feature(0).fields.get('name'))
Before: 11 Polygon
After : 11 LineString
first feature: Western Australia

buffer(distance = 10, side = "Both", dissolve = False, **kwargs)

Creates buffer polygons around input features to a specified distance.

Optional:

distance = float. Default 10.

The distance around the input features that will be buffered.

side = str. Default 'Both'.

Specifies the sides of the input features that will be buffered. May be 'Both', 'Left' or 'Right'. 'Both' is only supported for Polygon.

dissolve = bool. Default False.

Whether to dissolve the buffers into one feature.

**kwargs:

Other parameters passed to _algos.geo.layer.vector_translate.

Returns:

Type: Layer.

A new layer with the operation applied.

Example:

from gma import gio

ly = gio.open_vector('Australia.shp')
other = gio.Layer(data=[ly.get_feature(0)], name='WA', gtype='Polygon')
print('Before:', len(ly), ly.gtype)
r = ly.buffer(0.5)
print('After :', len(r), r.gtype)
if len(r): print('first feature:', r.get_feature(0).fields.get('name'))
Before: 11 Polygon
After : 11 MultiPolygon
first feature: Western Australia

Before / after applying a 0.5-degree buffer

calculate_geometry(area = False, length = False, gtype = False, circularity = False, num_points = False, num_geometries = False, ellipsoid_area = False, ellipsoid_length = False, keep_fields = False, keep_geom = True, **kwargs)

Calculate geometry attribute.

Optional:

area = bool||str. Default False.

Whether to calculate the area of the polygon. GeoGCS: deg2; ProjCS:m2.

If str, it will be the new name of the output result.

length = bool||str. Default False.

Whether to calculate the length of a line. GeoGCS: deg; ProjCS:m.

If str, it will be the new name of the output result.

gtype = bool||str. Default False.

Whether to get the type of the geometry. If str, it will be the new name of the output result.

circularity = bool||str. Default False.

Whether to computes the Circularity Index from the given Geometry.

If str, it will be the new name of the output result.

num_points = bool||str. Default False.

Whether to count the number of inflection points. If str, it will be the new name of the output result.

NumGeometries = bool||str. Default False.

Whether to count the number of geometries. If str, it will be the new name of the output result.

ellipsoid_area = bool||str. Default False.

Whether to calculate the area of the polygon using crs's ellipsoid. Unit: m2.

If str, it will be the new name of the output result.

ellipsoid_length = bool||str. Default False.

Whether to calculate the length of a line using crs's ellipsoid. Unit: m.

If str, it will be the new name of the output result.

keep_fields = bool||list. Default False.

Whether to retain attribute table fields. If list, it specifies the field names to be retained.

keep_geom = bool. Default True.

Whether to retain geometry field.

**kwargs:

Other parameters passed to _algos.geo.layer.vector_translate.

Returns:

Type: Layer.

A new layer with the operation applied.

Example:

from gma import gio

ly = gio.open_vector('Australia.shp')
r = ly.calculate_geometry(area=True, length=True, gtype=True)
print(type(r).__name__, len(r))
print('new fields:', r.ftypes.names[-3:])
print('areas:', [round(r.get_feature(i).fields['Area'], 2) for i in range(3)])
Layer 11
new fields: ['Area', 'Length', 'GeomType']
areas: [227.81, 116.2, 92.32]

calculate_statistics(statistics, case = None, where = None, **kwargs)

Calculates summary statistics for fields in a table.

Parameters:

statistics: dict||list||str.

Conduct statistical analysis on selected fields according to the predefined statistical methods.

Format 1: Statistics = {Method: [Field0, Field1, ...]}

All fields will undergo Method(Field) and will be stored in Field_Method field.

Example: Statistics = {'sum': ['field0', 'field1']}

Format 2: Statistics = {Method: {Field0: NewName0, Field1: NewName1, ...}}

All fields will undergo Method(Field) and will be stored in NewName field.

Example: Statistics = {'sum': {'field0': 'NewName0sum', 'field1': 'NewName1sum'}}

Format 3: Statistics = 'Field0 + Field1 AS sum_result'

Calculate the sum of Field0 and Field1 as "sum_result".

If it is a list, it must be a list of str in the format 3.

Including statistics types: 'min', 'max', 'sum', 'avg', 'count', 'total', ...

For more, see SQLite grammar.

Optional:

case = str||list||None. Default None.

The field or fields in the input that will be used to calculate statistics separately for each unique attribute value (or combination of attribute values when multiple fields are specified).

where = str||None. Default None.

The SQL query string expressions to evaluate. For example:

Where = 'ROWID = 1 OR Name IN ("GMA", "Layer")' 'ROWID' and 'Name' are the Layer field names.

Supported Rules:

Comparison Operators: =, !=, <>, <, >, <=, >= Logical Operators: AND, OR, NOT Wildcard Search Symbols: LIKE Range Condition: BETWEEN, IN, NOT IN Null-Value Check Operators: IS NULL, IS NOT NULL Regular expression matching: REGEXP

**kwargs:

Other parameters passed to _algos.geo.layer.vector_translate.

Returns:

Type: Layer.

A new layer with the operation applied.

Example:

from gma import gio

ly = gio.open_vector('Australia.shp')
r = ly.calculate_statistics({'AVG': ['scalerank'], 'COUNT': ['scalerank']})
print(type(r).__name__, len(r))
print('fields:', r.ftypes.names)
print('result:', r.get_feature(0).fields)
Layer 1
fields: ['scalerank_AVG', 'scalerank_COUNT']
result: {'scalerank_AVG': 2.0, 'scalerank_COUNT': 11}

centroid(**kwargs)

The points representing the centroid of each geometry.

Optional:

**kwargs:

Other parameters passed to _algos.geo.layer.vector_translate.

Returns:

Type: Layer.

A new layer with the operation applied.

Example:

from gma import gio

ly = gio.open_vector('Australia.shp')
print('Before:', len(ly), ly.gtype)
r = ly.centroid()
print('After :', len(r), r.gtype)
if len(r): print('first feature:', r.get_feature(0).fields.get('name'))
Before: 11 Polygon
After : 11 Point
first feature: Western Australia

clip(other, **kwargs)

Clip off areas that are not covered by the method layer.

Parameters:

other: Layer.

Another GMA Layer!

Optional:

**kwargs:

Other parameters passed to io.CreateLayer.

Returns:

Type: Layer.

A new layer with the operation applied.

Example:

from gma import gio

ly = gio.open_vector('Australia.shp')
other = gio.Layer(data=[ly.get_feature(0)], name='WA', gtype='Polygon')
print('Before:', len(ly), ly.gtype)
r = ly.clip(other)
print('After :', len(r), r.gtype)
if len(r): print('first feature:', r.get_feature(0).fields.get('name'))
Before: 11 Polygon
After : 5 Polygon
first feature: Western Australia

Western Australia clipped from the full layer

closest_point(other, **kwargs)

Calculate the closest point on the tow layer.

Parameters:

other: Layer.

Another GMA Layer!

Optional:

**kwargs:

Other parameters passed to _algos.geo.layer.vector_translate.

Returns:

Type: Layer.

A new layer with the operation applied.

Example:

from gma import gio

ly = gio.open_vector('Australia.shp')
other = gio.Layer(data=[ly.get_feature(0)], name='WA', gtype='Polygon')
print('Before:', len(ly), ly.gtype)
r = ly.closest_point(other)
print('After :', len(r), r.gtype)
if len(r): print('first feature:', r.get_feature(0).fields.get('name'))
Before: 11 Polygon
After : 8 Point
first feature: None

collect(use_field = None, keep_fields = True, **kwargs)

Collect features based on field values.

Optional:

use_field = str||list||None. Default None.

The field name(s) used to merge Features! If it's None, then dissolve all features.

keep_fields = bool||list. Default False.

Whether to retain attribute table fields. If list, it specifies the field names to be retained.

**kwargs:

Other parameters passed to _algos.geo.layer.vector_translate.

Returns:

Type: Layer.

A new layer with the operation applied.

Example:

from gma import gio

ly = gio.open_vector('Australia.shp')
print('Before:', len(ly), ly.gtype)
r = ly.collect()
print('After :', len(r), r.gtype)
if len(r): print('first feature:', r.get_feature(0).fields.get('name'))
Before: 11 Polygon
After : 1 MultiPolygon
first feature: Western Australia

concave_hull(**kwargs)

The concave hull of a geometry is the smallest concave Polygon containing all the points in each geometry.

Optional:

**kwargs:

Other parameters passed to _algos.geo.layer.vector_translate.

Returns:

Type: Layer.

A new layer with the operation applied.

Example:

from gma import gio

ly = gio.open_vector('Australia.shp')
print('Before:', len(ly), ly.gtype)
r = ly.concave_hull()
print('After :', len(r), r.gtype)
if len(r): print('first feature:', r.get_feature(0).fields.get('name'))
Before: 11 Polygon
After : 11 MultiPolygon
first feature: None

convex_hull(**kwargs)

The convex hull of a geometry is the smallest convex Polygon containing all the points in each geometry.

Optional:

**kwargs:

Other parameters passed to _algos.geo.layer.vector_translate.

Returns:

Type: Layer.

A new layer with the operation applied.

Example:

from gma import gio

ly = gio.open_vector('Australia.shp')
print('Before:', len(ly), ly.gtype)
r = ly.convex_hull()
print('After :', len(r), r.gtype)
if len(r): print('first feature:', r.get_feature(0).fields.get('name'))
Before: 11 Polygon
After : 11 MultiPolygon
first feature: None

copy(**kwargs)

Copy replica to default driver.

Optional:

**kwargs:

Other parameters passed to _algos.geo.layer.vector_translate.

Returns:

Type: Layer.

A new layer with the operation applied.

Example:

from gma import gio

ly = gio.open_vector('Australia.shp')
print('Before:', len(ly), ly.gtype)
r = ly.copy()
print('After :', len(r), r.gtype)
if len(r): print('first feature:', r.get_feature(0).fields.get('name'))
Before: 11 Polygon
After : 11 Polygon
first feature: Western Australia

delaunay_triangulation(edges_only = False, tolerance = 0, **kwargs)

Return a Delaunay triangulation of the vertices of the geometry.

Optional:

tolerance = float. Default 0.0.

Snapping tolerance to use for improved robustness.

edges_only = bool. Default False.

Whether the output geometry should be filled polygons(False) or just boundary lines(True).

**kwargs:

Other parameters passed to _algos.geo.layer.vector_translate.

Returns:

Type: Layer.

A new layer with the operation applied.

Example:

from gma import gio

ly = gio.open_vector('Australia.shp')
other = gio.Layer(data=[ly.get_feature(0)], name='WA', gtype='Polygon')
print('Before:', len(ly), ly.gtype)
r = ly.delaunay_triangulation()
print('After :', len(r), r.gtype)
if len(r): print('first feature:', r.get_feature(0).fields.get('name'))
Before: 11 Polygon
After : 3822 Polygon
first feature: None

dissolve(use_field = None, keep_fields = True, **kwargs)

Dissolve features based on field values.

Optional:

use_field = str||list||None. Default None.

The field name(s) used to dissolve Features! If it's None, then dissolve all features.

keep_fields = bool||list. Default False.

Whether to retain attribute table fields. If list, it specifies the field names to be retained.

**kwargs:

Other parameters passed to _algos.geo.layer.vector_translate.

Returns:

Type: Layer.

A new layer with the operation applied.

Example:

from gma import gio

ly = gio.open_vector('Australia.shp')
print('Before:', len(ly), ly.gtype)
r = ly.dissolve()
print('After :', len(r), r.gtype)
if len(r): print('first feature:', r.get_feature(0).fields.get('name'))
Before: 11 Polygon
After : 1 MultiPolygon
first feature: Western Australia

Before / after dissolving all features into one

distance(other, method = None, densify_fract = 0.1, **kwargs)

Calculates the distance between all geometric shapes within two Layers.

Parameters:

other: Layer.

Another GMA Layer!

Optional:

method = str||None. Default None.

Calculate method. May be None(normal distance), 'Hausdorff' or 'Frechet'.

densify_fract = float. Default 0.1.

A value between 0 and 1, that splits each subsegment of a line string into equal length segments, making the approximation less coarse.

A densify value of 0.5 will add a point halfway between each pair of points. A densify value of 0.25 will add a point every quarter of the way between each pair of points.

**kwargs:

Other parameters passed to _algos.geo.layer.vector_translate.

Returns:

Type: Layer.

A new layer with the operation applied.

Example:

from gma import gio

ly = gio.open_vector('Australia.shp')
other = gio.Layer(data=[ly.get_feature(0)], name='WA', gtype='Polygon')
print('Before:', len(ly), ly.gtype)
r = ly.distance(other)
print('After :', len(r), r.gtype)
if len(r): print('first feature:', r.get_feature(0).fields.get('name'))
Before: 11 Polygon
After : 11 None
first feature: None

drop(rows = None, fields = None)

Drop specified features or fields.

Optional:

rows = int||list||None. Default None.

List of FIDs to be deleted.

fields = str||list||None. Default None.

List of field names to be deleted.

Returns:

Type: None.

Modify the layer in place.

Example:

from gma import gio

ly = gio.open_vector('Australia.shp')
print('Before:', len(ly), len(ly.ftypes.names))
ly.drop(rows=[0, 1], fields=['note'])
print('After :', len(ly), len(ly.ftypes.names))
print('has note:', 'note' in ly.ftypes.names)
Before: 11 123
After : 9 122
has note: False

envelope(union = False, **kwargs)

The envelope of a geometry is the bounding rectangle.

Optional:

union = bool. Default True.

Whether to first integrate all elements before calculating.

**kwargs:

Other parameters passed to _algos.geo.layer.vector_translate.

Returns:

Type: Layer.

A new layer with the operation applied.

Example:

from gma import gio

ly = gio.open_vector('Australia.shp')
print('Before:', len(ly), ly.gtype)
r = ly.envelope()
print('After :', len(r), r.gtype)
if len(r): print('first feature:', r.get_feature(0).fields.get('name'))
Before: 11 Polygon
After : 11 MultiPolygon
first feature: Western Australia

erase(other, **kwargs)

Remove areas that are covered by the method layer.

Parameters:

other: Layer.

Another GMA Layer!

**kwargs:

Other parameters passed to io.CreateLayer.

Returns:

Type: Layer.

A new layer with the operation applied.

Example:

from gma import gio

ly = gio.open_vector('Australia.shp')
other = gio.Layer(data=[ly.get_feature(0)], name='WA', gtype='Polygon')
print('Before:', len(ly), ly.gtype)
r = ly.erase(other)
print('After :', len(r), r.gtype)
if len(r): print('first feature:', r.get_feature(0).fields.get('name'))
Before: 11 Polygon
After : 8 Polygon
first feature: Northern Territory

explode(**kwargs)

Separate a selected multipart feature into its individual.

Optional:

**kwargs:

Other parameters passed to _algos.geo.layer.vector_translate.

Returns:

Type: Layer.

A new layer with the operation applied.

Example:

from gma import gio

ly = gio.open_vector('Australia.shp')
print('Before:', len(ly), ly.gtype)
r = ly.explode()
print('After :', len(r), r.gtype)
if len(r): print('first feature:', r.get_feature(0).fields.get('name'))
Before: 11 Polygon
After : 59 Polygon
first feature: Western Australia

extent(**kwargs)

The extent of a geometry is the bounding rectangle.

Optional:

**kwargs:

Other parameters passed to _algos.geo.layer.vector_translate.

Returns:

Type: Layer.

A new layer with the operation applied.

Example:

from gma import gio

ly = gio.open_vector('Australia.shp')
print('Before:', len(ly), ly.gtype)
r = ly.extent()
print('After :', len(r), r.gtype)
if len(r): print('first feature:', r.get_feature(0).fields.get('name'))
Before: 11 Polygon
After : 1 Polygon
first feature: None

exterior_ring(**kwargs)

Returns a of LinearRings representing the outer bounds of each polygon.

Optional:

**kwargs:

Other parameters passed to _algos.geo.layer.vector_translate.

Returns:

Type: Layer.

A new layer with the operation applied.

Example:

from gma import gio

ly = gio.open_vector('Australia.shp')
print('Before:', len(ly), ly.gtype)
r = ly.exterior_ring()
print('After :', len(r), r.gtype)
if len(r): print('first feature:', r.get_feature(0).fields.get('name'))
Before: 11 Polygon
After : 11 MultiLineString
first feature: None

find_overlaps(**kwargs)

Find overlapping features in Layer.

Optional:

**kwargs:

Other parameters passed to _algos.geo.layer.vector_translate.

Returns:

Type: Layer.

A new layer with the operation applied.

Example:

from gma import gio

ly = gio.open_vector('Australia.shp')
print('Before:', len(ly), ly.gtype)
r = ly.find_overlaps()
print('After :', len(r), r.gtype)
if len(r): print('first feature:', r.get_feature(0).fields.get('name'))
Before: 11 Polygon
After : 4 Polygon
first feature: None

fix_geometry(**kwargs)

Fix invalid geometric features in Layer.

Returns:

Type: Layer.

A new layer with the operation applied.

Example:

from gma import gio

ly = gio.open_vector('Australia.shp')
print('Before:', len(ly), ly.gtype)
r = ly.fix_geometry()
print('After :', len(r), r.gtype)
if len(r): print('first feature:', r.get_feature(0).fields.get('name'))
Before: 11 Polygon
After : 11 Polygon
first feature: Western Australia

gen_grid(grid_type = "Square", size = 1, **kwargs)

Gen a grid of cells (having the edge length of size) precisely covering the input Layer.

Optional:

grid_type = str. Default 'Square'.

Grid type.Can be 'Square', 'Triangular', 'Hexagonal'.

**kwargs:

Other parameters passed to _algos.geo.layer.vector_translate.

Returns:

Type: Layer.

A new layer with the operation applied.

Example:

from gma import gio

ly = gio.open_vector('Australia.shp')
other = gio.Layer(data=[ly.get_feature(0)], name='WA', gtype='Polygon')
print('Before:', len(ly), ly.gtype)
r = ly.gen_grid(size=5)
print('After :', len(r), r.gtype)
if len(r): print('first feature:', r.get_feature(0).fields.get('name'))
Before: 11 Polygon
After : 46 Polygon
first feature: None

A 5-degree square grid covering the layer

geom_self_test()

Geometry self-test. Include: Empty, Simple, Valid, 3D, Measured, Valid Reason, Polygon Clockwise Rule(Counter-Clockwise Rule).

Returns:

Type: Layer.

A layer with geometry validity results for each feature.

Example:

from gma import gio

ly = gio.open_vector('Australia.shp')
r = ly.geom_self_test()
print(type(r).__name__, len(r))
print('first result:', r.get_feature(0).fields)
Layer 11
first result: {'IsEmpty': 0, 'IsSimple': 1, 'IsValid': 1, 'IsValidReason': 'Valid Geometry', 'IsRing': -1, 'Is3D': 0, 'IsMeasured': 0, 'IsPolygonCW': 0, 'IsPolygonCCW': 0}

geom_to_str(wkt = True, gml = False, kml = False, json = False, ewkb = False, ewkt = False, svg = False, **kwargs)

Converts geometry to string.

Optional:

wkt = bool. Default True.

Whether to convert to WTK string.

gml = bool. Default False.

Whether to convert to Gml string.

kml = bool. Default False.

Whether to convert to Kml string.

json = bool. Default False.

Whether to convert to GeoJSON string.

ewkb = bool. Default False.

Whether to convert to EWKB string.

ewkt = bool. Default False.

Whether to convert to EWKT string.

svg = bool. Default False.

Whether to convert to SVG string.

**kwargs:

Other parameters passed to _algos.geo.layer.vector_translate.

Returns:

Type: Layer.

A new layer with the operation applied.

Example:

from gma import gio

ly = gio.open_vector('Australia.shp')
r = ly.geom_to_str(wkt=True)
print(type(r).__name__, len(r))
print('fields:', r.ftypes.names)
print('first WKT:', str(r.get_feature(0).fields.get('WKT', ''))[:80])
Layer 11
fields: ['WKT']
first WKT: MULTIPOLYGON(((113.131813 -25.951992, 113.148227 -25.973833, 113.183119 -26.0530

get_feature(row_num = 0)

Fetch a feature by its identifier.

Optional:

row_num = int. Default 0.

The feature number of the feature to read.

Returns:

Type: Feature.

The feature at the given row number.

Example:

from gma import gio

ly = gio.open_vector('Australia.shp')
ft = ly.get_feature(0)
print(type(ft).__name__, ft.fid, ft.fields['name'], ft.geom.gtype)
Feature 0 Western Australia MultiPolygon

identity(other, o_prefix = "L1_", **kwargs)

Identify the features of this layer with the ones from the identity layer.

Parameters:

other: Layer.

Another GMA Layer!

Optional:

o_prefix = str. Default 'L1_'.

Set a prefix for the field names that will be created from the fields of the method layer.

**kwargs:

Other parameters passed to io.CreateLayer.

Returns:

Type: Layer.

A new layer with the operation applied.

Example:

from gma import gio

ly = gio.open_vector('Australia.shp')
other = gio.Layer(data=[ly.get_feature(0)], name='WA', gtype='Polygon')
print('Before:', len(ly), ly.gtype)
r = ly.identity(other)
print('After :', len(r), r.gtype)
if len(r): print('first feature:', r.get_feature(0).fields.get('name'))
Before: 11 Polygon
After : 11 Polygon
first feature: Western Australia

interior_ring(n = 1, **kwargs)

Returns a of LinearRings representing the inner bounds of each polygon.

Optional:

n = int. Default 1.

Extracted inner ring index (starting from 1).

**kwargs:

Other parameters passed to _algos.geo.layer.vector_translate.

Returns:

Type: Layer.

A new layer with the operation applied.

Example:

from gma import gio

# Build a polygon with a hole from a real WKT definition
g = gio.Geometry(data='POLYGON ((0 0,40 0,40 40,0 40,0 0),(10 10,10 30,30 30,30 10,10 10))')
ly = gio.Layer(data=[gio.Feature(geom=g)], name='holes', gtype='Polygon')

r = ly.interior_ring(1)
print(type(r).__name__, len(r), r.gtype)
print('bounds:', r.get_feature(0).geom.bounds)
Layer 1 MultiLineString
bounds: (10.0, 10.0, 30.0, 30.0)

interpolation(v_field, bounds = None, resolution = None, method = "idw", ipt_opts = {}, **kwargs)

Interpolate points into raster dataset.

Parameters:

v_field: str.

The field to be interpolated.

Optional:

bounds = tuple. Default None.

The four boundaries of the interpolation result are the minimum longitude (left), the minimum latitude (bottom), the maximum longitude (right), and the maximum latitude (top). The default (None) is to extract the range from the input coordinate points.

resolution = float. Default None.

The resolution of the interpolation result. The default (None) is 1/10 of the minimum bounds X and Y difference.

method = str. Default 'idw'.

Interpolation method. Can be 'b_spline', 'idw', 'kriging', 'natural_neighbor', 'nearest', 'rbf' and 'trend'. For more, see smc.interp.

ipt_opts = dict. Default {}.

Interpolation parameters. Corresponding to the interpolation method.

**kwargs:

Other parameters passed to _algos.geo.dataset.raster_translate.

Returns:

Type: Dataset.

NOTE: 3.0.4.1 crashes on this call (see the result block).

Example:

from gma import gio

ly = gio.open_vector('Australia.shp')
pts = ly.centroid()                 # interpolation needs point features
print('points:', len(pts))
r = pts.interpolation('scalerank', resolution=0.5, method='idw')  # 3.0.4.1 bug
print(type(r).__name__, r.shape)
IndexError: index 11 is out of bounds for axis 0 with size 11 (gma 3.0.4.1)

intersection(other, o_prefix = "L1_", **kwargs)

Intersection of two layers.

Parameters:

other: Layer.

Another GMA Layer!

Optional:

o_prefix = str. Default 'L1_'.

Set a prefix for the field names that will be created from the fields of the method layer.

**kwargs:

Other parameters passed to io.CreateLayer.

Returns:

Type: Layer.

A new layer with the operation applied.

Example:

from gma import gio

ly = gio.open_vector('Australia.shp')
other = gio.Layer(data=[ly.get_feature(0)], name='WA', gtype='Polygon')
print('Before:', len(ly), ly.gtype)
r = ly.intersection(other)
print('After :', len(r), r.gtype)
if len(r): print('first feature:', r.get_feature(0).fields.get('name'))
Before: 11 Polygon
After : 3 Polygon
first feature: Western Australia

join(other, spatial_join = None, left_on = None, right_on = None, one_to_one = True, suffixes = "", ext_cond = None, **kwargs)

Join the attribute table of RLayer into the first Layer.

Parameters:

other: Layer.

Another GMA Layer!

Optional:

spatial_join = str. Default None.

Spatial join method. Supported 'Intersects', 'Disjoint', 'Within', 'Equals', 'Touches'.

Default(None) no spatial join.

left_on = str||list||None. Default None.

Feild names to join on in the self Layer. Can also be a list of the length of the self Layer. Default(None) using self FID column if spatial_join is None.

right_on = str||list||None. Default None.

Feild names to join on in the other Layer. Can also be a list of the length of the other Layer. Default(None) using other FID column if spatial_join is None.

one_to_one = bool. Default False.

Whether to keep only one feature in the second layer for each feature in the first layer.

suffixes = str. Default ''.

Extended character used to mark the second layer column.

ext_cond = str||None. Default None.

Additional SQL conditions for joining the two layers. For example:

ext_cond = 'a0.field0 > 10 AND a1.field1 < 20'.

a0 and a1 are the aliases of the self and other layers, respectively.

**kwargs:

Other parameters passed to _algos.geo.layer.vector_translate.

Returns:

Type: Layer.

A new layer with the operation applied.

Example:

from gma import gio

ly = gio.open_vector('Australia.shp')
other = gio.Layer(data=[ly.get_feature(0)], name='WA', gtype='Polygon')
print('Before:', len(ly), ly.gtype)
r = ly.join(other)
print('After :', len(r), r.gtype)
if len(r): print('first feature:', r.get_feature(0).fields.get('name'))
Before: 11 Polygon
After : 11 Polygon
first feature: Western Australia

line_equidistant_points(length, keep_fields = True, **kwargs)

Generate equidistant points along the line geometry.

Parameters:

length: float.

Distance between points.

Optional:

keep_fields = bool. Default True.

Whether to retain attribute table fields.

**kwargs:

Other parameters passed to _algos.geo.layer.vector_translate.

Returns:

Type: Layer.

A new layer with the operation applied.

Example:

from gma import gio

ly = gio.open_vector('Australia.shp')
other = gio.Layer(data=[ly.get_feature(0)], name='WA', gtype='Polygon')
print('Before:', len(ly), ly.gtype)
r = ly.line_equidistant_points(5)
print('After :', len(r), r.gtype)
if len(r): print('first feature:', r.get_feature(0).fields.get('name'))
Before: 11 Polygon
After : 11 MultiPoint
first feature: Western Australia

merge(*others, **kwargs)

Merge all layers.

Parameters:

*others: Layer||list of Layer.

Other GMA Layers!

Optional:

**kwargs:

Other parameters passed to _algos.geo.layer.vector_translate.

Returns:

Type: Layer.

A new layer with the operation applied.

Example:

from gma import gio

ly = gio.open_vector('Australia.shp')
other = gio.Layer(data=[ly.get_feature(0)], name='WA', gtype='Polygon')
print('Before:', len(ly), ly.gtype)
r = ly.merge(other)
print('After :', len(r), r.gtype)
if len(r): print('first feature:', r.get_feature(0).fields.get('name'))
Before: 11 Polygon
After : 12 Polygon
first feature: Western Australia

min_bounding_circle(**kwargs)

Constructs the Minimum Bounding Circle for a generic geometry.

Optional:

**kwargs:

Other parameters passed to _algos.geo.layer.vector_translate.

Returns:

Type: Layer.

A new layer with the operation applied.

Example:

from gma import gio

ly = gio.open_vector('Australia.shp')
print('Before:', len(ly), ly.gtype)
r = ly.min_bounding_circle()
print('After :', len(r), r.gtype)
if len(r): print('first feature:', r.get_feature(0).fields.get('name'))
Before: 11 Polygon
After : 11 MultiPolygon
first feature: Western Australia

min_rotated_rectangle(**kwargs)

Calculate the minimum rotated rectangular polygon which encloses the input geometry.

Optional:

**kwargs:

Other parameters passed to _algos.geo.layer.vector_translate.

Returns:

Type: Layer.

A new layer with the operation applied.

Example:

from gma import gio

ly = gio.open_vector('Australia.shp')
print('Before:', len(ly), ly.gtype)
r = ly.min_rotated_rectangle()
print('After :', len(r), r.gtype)
if len(r): print('first feature:', r.get_feature(0).fields.get('name'))
Before: 11 Polygon
After : 11 MultiPolygon
first feature: Western Australia

min_width(**kwargs)

Calculate the LINESTRING geometry which represents the minimum diameter of the geometry.

Optional:

**kwargs:

Other parameters passed to _algos.geo.layer.vector_translate.

Returns:

Type: Layer.

A new layer with the operation applied.

Example:

from gma import gio

ly = gio.open_vector('Australia.shp')
print('Before:', len(ly), ly.gtype)
r = ly.min_width()
print('After :', len(r), r.gtype)
if len(r): print('first feature:', r.get_feature(0).fields.get('name'))
Before: 11 Polygon
After : 11 MultiLineString
first feature: Western Australia

multi(**kwargs)

Make single part geometry into their multi counterpart.

Optional:

**kwargs:

Other parameters passed to _algos.geo.layer.vector_translate.

Returns:

Type: Layer.

A new layer with the operation applied.

Example:

from gma import gio

ly = gio.open_vector('Australia.shp')
print('Before:', len(ly), ly.gtype)
r = ly.multi()
print('After :', len(r), r.gtype)
if len(r): print('first feature:', r.get_feature(0).fields.get('name'))
Before: 11 Polygon
After : 11 MultiPolygon
first feature: Western Australia

order_by(fields, ascending = True, **kwargs)

Sort by field.

Parameters:

fields: str||list.

Fields or list of fields to be sorted.

Optional:

ascending = bool||list. Default True.

Sort order, which can be True(ascending) or False(descending).

**kwargs:

Other parameters passed to _algos.geo.layer.vector_translate.

Returns:

Type: Layer.

A new layer with the operation applied.

Example:

from gma import gio

ly = gio.open_vector('Australia.shp')
other = gio.Layer(data=[ly.get_feature(0)], name='WA', gtype='Polygon')
print('Before:', len(ly), ly.gtype)
r = ly.order_by('name')
print('After :', len(r), r.gtype)
if len(r): print('first feature:', r.get_feature(0).fields.get('name'))
Before: 11 Polygon
After : 11 Polygon
first feature: Australian Capital Territory

plot(ax = None, **kwargs)

Make plots of Layer.

Optional:

ax = None||matplotlib. ~.AxesSubplot. Default None.

A matplotlib subplot. If None, a default axes will be created.

**kwargs

Other plotting parameters. For more, see:

~.carto.utils.PolyCollection/LineCollection/PointCollection.

Returns:

Type: Axes.

The matplotlib axes with the layer plotted on it.

Example:

from gma import gio

ly = gio.open_vector('Australia.shp')
fig, ax = plt.subplots(figsize=(7, 5))
ax = ly.plot(ax=ax, facecolor='none', edgecolor='navy')
print(type(ax).__name__)
Axes

The real Australia.shp layer plotted with matplotlib

point_on_surface(**kwargs)

Computes a point guaranteed to lie in a polygon, or on a geometry.

Optional:

**kwargs:

Other parameters passed to _algos.geo.layer.vector_translate.

Returns:

Type: Layer.

A new layer with the operation applied.

Example:

from gma import gio

ly = gio.open_vector('Australia.shp')
print('Before:', len(ly), ly.gtype)
r = ly.point_on_surface()
print('After :', len(r), r.gtype)
if len(r): print('first feature:', r.get_feature(0).fields.get('name'))
Before: 11 Polygon
After : 11 MultiPoint
first feature: Western Australia

query(expr, tran_opts = {}, **kwargs)

Query the data with a full SpatiaLite SQL expression.

Parameters:

expr: str.

The query string to evaluate.

Optional:

tran_opts = dict. Default {}.

Vector translate options. For more, see _algos.geo.layer.vector_translate.

**kwargs:

Other parameters passed to ._algos.geo.vrt.VRTGeoDatabase.add_layer.

Returns:

Type: Layer.

A new layer with the operation applied.

Example:

from gma import gio

ly = gio.open_vector('Australia.shp')
r = ly.query('SELECT * FROM Australia WHERE scalerank < 3 LIMIT 3')
print(type(r).__name__, len(r), r.gtype)
Layer 3 Polygon

rotate(angle = 90, **kwargs)

Rotate an angle of the layer.

Parameters:

Angle = float. Default 90.

Rotation angle (In Degrees) with the point [0, 0] as the origin.

Optional:

**kwargs:

Other parameters passed to _algos.geo.layer.vector_translate.

Returns:

Type: Layer.

A new layer with the operation applied.

Example:

from gma import gio

ly = gio.open_vector('Australia.shp')
other = gio.Layer(data=[ly.get_feature(0)], name='WA', gtype='Polygon')
print('Before:', len(ly), ly.gtype)
r = ly.rotate(45)
print('After :', len(r), r.gtype)
if len(r): print('first feature:', r.get_feature(0).fields.get('name'))
Before: 11 Polygon
After : 11 Polygon
first feature: Western Australia

sanitize(**kwargs)

Sanitize geometry. Including removing duplicate points and ensuring closed rings.

Optional:

**kwargs:

Other parameters passed to _algos.geo.layer.vector_translate.

Returns:

Type: Layer.

A new layer with the operation applied.

Example:

from gma import gio

ly = gio.open_vector('Australia.shp')
print('Before:', len(ly), ly.gtype)
r = ly.sanitize()
print('After :', len(r), r.gtype)
if len(r): print('first feature:', r.get_feature(0).fields.get('name'))
Before: 11 Polygon
After : 11 Polygon
first feature: Western Australia

scale(factor = 1, **kwargs)

Select the intersecting features.

Optional:

factor = float||list. Default 1.

X, Y scale factors. If a single value is provided, it is assumed that X = Y.

**kwargs:

Other parameters passed to _algos.geo.layer.vector_translate.

Returns:

Type: Layer.

A new layer with the operation applied.

Example:

from gma import gio

ly = gio.open_vector('Australia.shp')
other = gio.Layer(data=[ly.get_feature(0)], name='WA', gtype='Polygon')
print('Before:', len(ly), ly.gtype)
r = ly.scale(2)
print('After :', len(r), r.gtype)
if len(r): print('first feature:', r.get_feature(0).fields.get('name'))
Before: 11 Polygon
After : 11 Polygon
first feature: Western Australia

select(where = "", keep_fields = True, keep_geom = True, **kwargs)

Using SQL WHERE expressions to filter features by attribute table fields.

Optional:

where = str. Default ''.

The SQL query string expressions to evaluate. For example:

Where = 'ROWID = 1 OR Name IN ("GMA", "Layer")' 'ROWID' and 'Name' are the Layer field names.

Supported Rules:

Comparison Operators: =, !=, <>, <, >, <=, >= Logical Operators: AND, OR, NOT Wildcard Search Symbols: LIKE Range Condition: BETWEEN, IN, NOT IN Null-Value Check Operators: IS NULL, IS NOT NULL Regular expression matching: REGEXP

keep_fields = bool||list. Default False.

Whether to retain attribute table fields. If list, it specifies the field names to be retained.

keep_geom = bool. Default True.

Whether to retain geometry field.

**kwargs:

Other parameters passed to _algos.geo.layer.vector_translate.

Returns:

Type: Layer.

A new layer with the operation applied.

Example:

from gma import gio

ly = gio.open_vector('Australia.shp')
other = gio.Layer(data=[ly.get_feature(0)], name='WA', gtype='Polygon')
print('Before:', len(ly), ly.gtype)
r = ly.select("type='State'")
print('After :', len(r), r.gtype)
if len(r): print('first feature:', r.get_feature(0).fields.get('name'))
Before: 11 Polygon
After : 8 Polygon
first feature: Western Australia

select_overlay(other, method = "Intersects", **kwargs)

Select features that conform to the overlay rule.

Parameters:

other: Layer.

Another GMA Layer!

Optional:

method = str. Default 'Intersects'.

Overlay method. Supported methods include: 'Intersects', 'Disjoint', 'Within', 'Equals', 'Touches'.

**kwargs:

Other parameters passed to _algos.geo.layer.vector_translate.

Returns:

Type: Layer.

A new layer with the operation applied.

Example:

from gma import gio

ly = gio.open_vector('Australia.shp')
other = gio.Layer(data=[ly.get_feature(0)], name='WA', gtype='Polygon')
print('Before:', len(ly), ly.gtype)
r = ly.select_overlay(other, method='Intersects')
print('After :', len(r), r.gtype)
if len(r): print('first feature:', r.get_feature(0).fields.get('name'))
Before: 11 Polygon
After : 5 Polygon
first feature: Western Australia

set_feature(feature, fid = None)

Rewrite an existing feature. To set a feature, but create it if it doesn't exist.

Parameters:

feature: Feature.

A vector feature.

Optional:

fid = int||None. Default None.

The FID added to the layer. Defaults to the feature's FID.

Returns:

Type: None.

Modify the layer in place.

Example:

from gma import gio

ly = gio.open_vector('Australia.shp')
print('Before:', len(ly), ly.get_feature(0).fields['name'])
ft = ly.get_feature(0).copy()
ft.fields['name'] = 'Modified WA'
print('returns:', repr(ly.set_feature(ft, fid=0)))
print('After :', len(ly), ly.get_feature(0).fields['name'])
Before: 11 Western Australia
returns: None
After : 11 Western Australia

set_spatial_filter(geom = None)

Returns:

Type: None.

Modify the layer in place.

Example:

from gma import gio

ly = gio.open_vector('Australia.shp')
print('Before filter:', len(ly))
g = gio.open_vector('Australia.shp').get_feature(0).geom
ly.set_spatial_filter(g)
print('After filter :', len(ly))
print('filter:', type(ly.spatial_filter).__name__)
Before filter: 11
After filter : 5
filter: Geometry

shared_paths(other, **kwargs)

Calculate the shared paths between two layers.

Parameters:

other: Layer.

Another GMA Layer!

Optional:

**kwargs:

Other parameters passed to _algos.geo.layer.vector_translate.

Returns:

Type: Layer.

A new layer with the operation applied.

Example:

from gma import gio

ly = gio.open_vector('Australia.shp')
other = gio.Layer(data=[ly.get_feature(0)], name='WA', gtype='Polygon')
print('Before:', len(ly), ly.gtype)
r = ly.shared_paths(other)
print('After :', len(r), r.gtype)
if len(r): print('first feature:', r.get_feature(0).fields.get('name'))
Before: 11 Polygon
After : 11 MultiLineString
first feature: None

shift(distance = 1, **kwargs)

Shilf a distance of the layer.

Optional:

distance = float||list. Default 1.

X, Y shift distance. If a single value is provided, it is assumed that X = Y.

**kwargs:

Other parameters passed to _algos.geo.layer.vector_translate.

Returns:

Type: Layer.

A new layer with the operation applied.

Example:

from gma import gio

ly = gio.open_vector('Australia.shp')
other = gio.Layer(data=[ly.get_feature(0)], name='WA', gtype='Polygon')
print('Before:', len(ly), ly.gtype)
r = ly.shift(1)
print('After :', len(r), r.gtype)
if len(r): print('first feature:', r.get_feature(0).fields.get('name'))
Before: 11 Polygon
After : 11 Polygon
first feature: Western Australia

shortest_line(other, **kwargs)

Calculate the shortest line between the geometries of tow layers.

Parameters:

other: Layer.

Another GMA Layer!

Optional:

**kwargs:

Other parameters passed to _algos.geo.layer.vector_translate.

Returns:

Type: Layer.

A new layer with the operation applied.

Example:

from gma import gio

ly = gio.open_vector('Australia.shp')
other = gio.Layer(data=[ly.get_feature(0)], name='WA', gtype='Polygon')
print('Before:', len(ly), ly.gtype)
r = ly.shortest_line(other)
print('After :', len(r), r.gtype)
if len(r): print('first feature:', r.get_feature(0).fields.get('name'))
Before: 11 Polygon
After : 11 MultiLineString
first feature: None

simplify(tolerance = 0, preserve_topology = False, **kwargs)

Simplify geometries in the Layer.

Optional:

tolerance = float. Default 0.0.

Tolerance allowed when simplifying geometric features.

preserve_topology = bool. Default False.

Simplify the geometry while preserving topology.

**kwargs:

Other parameters passed to _algos.geo.layer.vector_translate.

Returns:

Type: Layer.

A new layer with the operation applied.

Example:

from gma import gio

ly = gio.open_vector('Australia.shp')
print('Before:', len(ly), ly.gtype)
r = ly.simplify()
print('After :', len(r), r.gtype)
if len(r): print('first feature:', r.get_feature(0).fields.get('name'))
Before: 11 Polygon
After : 11 Polygon
first feature: Western Australia

snap(other = None, tolerance = 0, **kwargs)

Snap vertices to the nearest vertices of another geometry.

Optional:

other = None||Layer. Default None.

Another GMA Layer! If None, snap to the grid.

tolerance = float. Default 0.0.

Tolerance allowed when processing features. If snapped to the grid, this parameter represents the size of the grid. All points and vertices will be aligned to a grid defined by its origin and size.

**kwargs:

Other parameters passed to _algos.geo.layer.vector_translate.

Returns:

Type: Layer.

A new layer with the operation applied.

Example:

from gma import gio

ly = gio.open_vector('Australia.shp')
other = gio.Layer(data=[ly.get_feature(0)], name='WA', gtype='Polygon')
print('Before:', len(ly), ly.gtype)
r = ly.snap(tolerance=0.1)
print('After :', len(r), r.gtype)
if len(r): print('first feature:', r.get_feature(0).fields.get('name'))
Before: 11 Polygon
After : 11 Polygon
first feature: Western Australia

sym_difference(other, o_prefix = "L1_", **kwargs)

Symmetrical difference of two layers.

Parameters:

other: Layer.

Another GMA Layer!

Optional:

o_prefix = str. Default 'L1_'.

Set a prefix for the field names that will be created from the fields of the method layer.

**kwargs:

Other parameters passed to io.CreateLayer.

Returns:

Type: Layer.

A new layer with the operation applied.

Example:

from gma import gio

ly = gio.open_vector('Australia.shp')
other = gio.Layer(data=[ly.get_feature(0)], name='WA', gtype='Polygon')
print('Before:', len(ly), ly.gtype)
r = ly.sym_difference(other)
print('After :', len(r), r.gtype)
if len(r): print('first feature:', r.get_feature(0).fields.get('name'))
Before: 11 Polygon
After : 8 Polygon
first feature: Northern Territory

to_bytearray(keep_geom = False, keep_fields = True)

Read vector attribute table to a bytearray.

Optional:

keep_geom = bool. Default False.

Whether to export the geometry in WKT format!

keep_fields = bool||list. Default False.

Whether to retain attribute table fields. If list, it specifies the field names to be retained.

Returns:

Type: bytearray.

The serialized layer as bytes.

Example:

from gma import gio

ly = gio.open_vector('Australia.shp')
b = ly.to_bytearray()
print(type(b).__name__, len(b))
bytearray 13146

to_crs(crs = "WGS84", **kwargs)

Reproject to another coordinate system.

Optional:

crs = str||int||class. Default 'WGS84'.

The output coordinate system. Can be EPSG, WKT, Proj4, and other types of coordinate characters.

Optional:

**kwargs:

Other parameters passed to _algos.geo.layer.vector_translate.

Returns:

Type: Layer.

A new layer with the operation applied.

Example:

from gma import gio

ly = gio.open_vector('Australia.shp')
other = gio.Layer(data=[ly.get_feature(0)], name='WA', gtype='Polygon')
print('Before:', len(ly), ly.gtype)
r = ly.to_crs('EPSG:3857')
print('After :', len(r), r.gtype)
if len(r): print('first feature:', r.get_feature(0).fields.get('name'))
Before: 11 Polygon
After : 11 Polygon
first feature: Western Australia

Before / after reprojection to EPSG:3857

to_dataset(resolution = 1, field = None, bounds = None, nodata = None, **kwargs)

Translate Layer to DataSet!

Optional:

resolution = float. Default 1.

Resolution of the DataSet.

field = str||None. Default None.

The field to be translated. By default (None), the DataSet will be generated with 0 and 1.

bounds = tuple. Default None.

The four boundaries of the interpolation result are the minimum longitude (left), the minimum latitude (bottom), the maximum longitude (right), and the maximum latitude (top). The default (None) is the bounds of the input Layer.

nodata = float||None. Default None.

The output DataSet nodata value. By default (None), the nodata value is automatically calculated.

**kwargs:

Other parameters passed to algos.dataio.utils.CreateRasterEx.

Returns:

Type: Dataset.

A raster dataset generated from the layer features.

Example:

from gma import gio

ly = gio.open_vector('Australia.shp')
r = ly.to_dataset(1)
print(type(r).__name__, r.shape)
Dataset (1, 34, 41)

to_dim(dim = "XY", z = None, m = None, **kwargs)

Casting space dimension of Layer.

Optional:

dim = str. Default 'XY'.

Space dimensions. Can be 'XY', 'XYZ', 'XYM' or 'XYZM'.

z = float||None. Default None.

Z value. Only valid when SDIM is in 'XYZ', 'ZYZM' and layer SDIM is 'XY'.

m = float||None. Default None.

M value. Only valid when SDIM is in 'XYM', 'ZYZM' and layer SDIM is 'XY'.

**kwargs:

Other parameters passed to _algos.geo.layer.vector_translate.

Returns:

Type: Layer.

A new layer with the operation applied.

Example:

from gma import gio

ly = gio.open_vector('Australia.shp')
other = gio.Layer(data=[ly.get_feature(0)], name='WA', gtype='Polygon')
print('Before:', len(ly), ly.gtype)
r = ly.to_dim('XYZ')
print('After :', len(r), r.gtype)
if len(r): print('first feature:', r.get_feature(0).fields.get('name'))
Before: 11 Polygon
After : 11 3DPolygon
first feature: Western Australia

to_file(out_dst, driver = "ESRI Shapefile", layer_name = None, mode = None, **kwargs)

in_src, out_dst = None, driver = None, optional Save Layer as a vector file.

Parameters:

out_dst: str.

The output vector file path.

Optional:

driver = str. Default 'ESRI Shapefile'.

Output file driver. For other drivers, see ._algos.geo.driver.DriveStatistics().vectors.

layer_name = str||None. Default None.

Output layer name. Default(None) is the self name.

mode = str||None. Default None.

Access mode. Default(None) is 'creation'. Other supported mode include:

'update', 'append', 'upsert' and 'overwrite'.

**kwargs:

Other parameters passed to _algos.geo.layer.vector_translate.

Returns:

Type: None.

Modify the layer in place.

Example:

from gma import gio

ly = gio.open_vector('Australia.shp')
out = ly.to_file('australia_copy.shp')
print('return:', repr(out))
print('written:', os.path.isfile('australia_copy.shp'))
return: None
written: True

to_gtype(gtype = "MultiPolygon", **kwargs)

Change the geometric type of Layer.

Optional:

gtype = str. Default 'MultiPolygon'.

Output geometry type. Supported geometry type include:

'Point', 'MultiPoint', 'Line', 'MultiLine', 'Polygon', 'MultiPolygon'.

**kwargs:

Other parameters passed to _algos.geo.layer.vector_translate.

Returns:

Type: Layer.

A new layer with the operation applied.

Example:

from gma import gio

ly = gio.open_vector('Australia.shp')
other = gio.Layer(data=[ly.get_feature(0)], name='WA', gtype='Polygon')
print('Before:', len(ly), ly.gtype)
r = ly.to_gtype('MultiPolygon')
print('After :', len(r), r.gtype)
if len(r): print('first feature:', r.get_feature(0).fields.get('name'))
Before: 11 Polygon
After : 11 MultiPolygon
first feature: Western Australia

to_pandas(keep_geom = False, keep_fields = True, **kwargs)

Read vector attribute table to a pandas DataFrame.

Optional:

keep_geom = bool. Default False.

Whether to export the geometry in WKT format!

keep_fields = bool||list. Default False.

Whether to retain attribute table fields. If list, it specifies the field names to be retained.

**kwargs:

Other parameters passed to pd.read_csv.

Returns:

Type: DataFrame.

The attribute table as a pandas DataFrame.

Example:

from gma import gio

ly = gio.open_vector('Australia.shp')
df = ly.to_pandas()
print(type(df).__name__, df.shape)
print('columns[:5]:', list(df.columns[:5]))
DataFrame (11, 123)
columns[:5]: ['featurecla', 'scalerank', 'adm1_code', 'diss_me', 'iso_3166_2']

union(other, o_prefix = "L1_", **kwargs)

Union of two layers.

Parameters:

other: Layer.

Another GMA Layer!

Optional:

o_prefix = str. Default 'L1_'.

Set a prefix for the field names that will be created from the fields of the method layer.

**kwargs:

Other parameters passed to io.CreateLayer.

Returns:

Type: Layer.

A new layer with the operation applied.

Example:

from gma import gio

ly = gio.open_vector('Australia.shp')
other = gio.Layer(data=[ly.get_feature(0)], name='WA', gtype='Polygon')
print('Before:', len(ly), ly.gtype)
r = ly.union(other)
print('After :', len(r), r.gtype)
if len(r): print('first feature:', r.get_feature(0).fields.get('name'))
Before: 11 Polygon
After : 11 Polygon
first feature: Western Australia

update(other, **kwargs)

Update this layer with features from the update layer.

Parameters:

other: Layer.

Another GMA Layer!

Optional:

**kwargs:

Other parameters passed to io.CreateLayer.

Returns:

Type: Layer.

A new layer with the operation applied.

Example:

from gma import gio

ly = gio.open_vector('Australia.shp')
other = gio.Layer(data=[ly.get_feature(0)], name='WA', gtype='Polygon')
print('Before:', len(ly), ly.gtype)
r = ly.update(other)
print('After :', len(r), r.gtype)
if len(r): print('first feature:', r.get_feature(0).fields.get('name'))
Before: 11 Polygon
After : 9 Polygon
first feature: Northern Territory

vertices_to_points(**kwargs)

Creates points generated from specified vertices or locations.

Optional:

**kwargs:

Other parameters passed to _algos.geo.layer.vector_translate.

Returns:

Type: Layer.

A new layer with the operation applied.

Example:

from gma import gio

ly = gio.open_vector('Australia.shp')
print('Before:', len(ly), ly.gtype)
r = ly.vertices_to_points()
print('After :', len(r), r.gtype)
if len(r): print('first feature:', r.get_feature(0).fields.get('name'))
Before: 11 Polygon
After : 11 MultiPoint
first feature: Western Australia

voronoj_diagram(ext_frame_size = 5, edges_only = False, **kwargs)

Return a geometric object representing the Voronoj Diagram corresponding to the input Geometry.

Optional:

ext_frame_size = float. Default 5(%).

Allows to arbitrarily set the percent extension of the bounding frame.

edges_only = bool. Default False.

Whether the output geometry should be filled polygons(False) or just boundary lines(True).

**kwargs:

Other parameters passed to _algos.geo.layer.vector_translate.

Returns:

Type: Layer.

A new layer with the operation applied.

Example:

from gma import gio

ly = gio.open_vector('Australia.shp')
print('Before:', len(ly), ly.gtype)
r = ly.voronoj_diagram()
print('After :', len(r), r.gtype)
if len(r): print('first feature:', r.get_feature(0).fields.get('name'))
Before: 11 Polygon
After : 1926 Polygon
first feature: Western Australia

xy_table_to_point(x_field, y_field, crs = "WGS84", **kwargs)

Creates a point Layer based on X, Y-coordinates from a table.

Parameters:

x_field: str.

The field in the input table that contains the x-coordinates (or longitude).

y_field: str.

The field in the input table that contains the y-coordinates (or latitude).

Optional:

crs = str||int||class||None. Default 'WGS84'.

The output coordinate system. Can be EPSG, WKT, Proj4, and other types of coordinate characters.

**kwargs:

Other parameters passed to _algos.geo.layer.vector_translate.

Returns:

Type: Layer.

A new layer with the operation applied.

Example:

from gma import gio

ly = gio.open_vector('Australia.shp')
r = ly.xy_table_to_point('scalerank', 'diss_me')
print(type(r).__name__, len(r), r.gtype)
Layer 11 Point

Property

bounds

Layer bounds(left, bottom, right, top). --> tuple

Example:

from gma import gio

ly = gio.open_vector('Australia.shp')
print(ly.bounds)
(112.9081532637623, -43.61945867967415, 153.61696096897367, -10.05169861030248)

crs

Layer coordinate reference system. --> CoordinateReferenceSystem

Example:

from gma import gio

ly = gio.open_vector('Australia.shp')
print(ly.crs)
<CoordinateReferenceSystem:WGS 84>

driver

Layer driver. --> VectorDriver

Example:

from gma import gio

ly = gio.open_vector('Australia.shp')
print(ly.driver)
ESRI Shapefile - Vector

fid_col

FID field name. --> str

Example:

from gma import gio

ly = gio.open_vector('Australia.shp')
print(ly.fid_col)
RowID

ftypes

Field definitions. --> FieldTypes

Example:

from gma import gio

ly = gio.open_vector('Australia.shp')
print('count:', len(ly.ftypes.names))
print('first five:', ly.ftypes.names[:5])
count: 123
first five: ['featurecla', 'scalerank', 'adm1_code', 'diss_me', 'iso_3166_2']

geom_col

Geometry field name. --> str

Example:

from gma import gio

ly = gio.open_vector('Australia.shp')
print(ly.geom_col)
geometry

gtype

Layer geometry type. --> GMADataType

Example:

from gma import gio

ly = gio.open_vector('Australia.shp')
print(ly.gtype)
Polygon

Layer path link. --> str

Example:

from gma import gio

ly = gio.open_vector('Australia.shp')
print(ly.link)
Australia.shp

name

Example:

from gma import gio

ly = gio.open_vector('Australia.shp')
print(ly.name)
Australia

spatial_filter

Example:

from gma import gio

ly = gio.open_vector('Australia.shp')
print(ly.spatial_filter)
<Geometry: Polygon>

tb

Example:

from gma import gio

ly = gio.open_vector('Australia.shp')
print(type(ly.tb).__name__)
print(ly.tb)
TableStats
<Table:Australia>
Last Updated 11/21/2026, 2:33:17 AM