catatom2osm.geo.layer.polygon module

class catatom2osm.geo.layer.polygon.PolygonLayer(path, baseName, providerLib='ogr')[fuente]

Bases: catatom2osm.geo.layer.base.BaseLayer

Base class for polygon layers.

clean()[fuente]

Clean geometries.

Delete invalid geometries and close vertices, add topological points and simplify vertices.

delete_invalid_geometries(query_small_area=<function PolygonLayer.<lambda>>)[fuente]

Delete invalid geometries.

Test if any of it acute angle vertex could be deleted. Also removes zig-zag and spike vertex (see Point.get_spike_context).

delete_small_geometries()[fuente]
difference(layer)[fuente]

Calculate the difference of each geometry with those in layer.

explode_multi_parts(request=<qgis._core.QgsFeatureRequest object>)[fuente]

Split multipolygons.

Creates a new WKBPolygon feature for each part of any WKBMultiPolygon feature in request. This avoid relations with many “outer” members in OSM data set. From this moment, localId will not be a unique identifier for buildings.

get_adjacents_and_geometries(expression='')[fuente]

Auxiliary indexes for adjacency of geometries.

Devuelve

(list) groups of adjacent polygons (dict) feature id: geometry

get_area()[fuente]

Return sum of all features area.

get_contacts_and_geometries(expression='')[fuente]

Auxiliary indexes for contact of geometries.

Devuelve

(list) groups of polygons with at least one common node (dict) feature id: geometry

get_parents_per_vertex_and_geometries(expression='')[fuente]

Auxiliary indexes for vertex of geometries.

Devuelve

(dict) parent fids for each vertex, (dict) geometry for each fid.

Precondition:

Called before reproject.

is_inside(feature)[fuente]

Return first feature of this layer that is_inside feature.

is_inside_area(feature)[fuente]

Return first feature of this layer that is_inside_area feature.

static is_shared_segment(parents_per_vx, va, vb, feature_id)[fuente]

Return True if a segment is used by another geometry.

Given a dictionary of parents per vertex check if segment va-vb in geometry of feature with id “feature_id” is shared with another geometry.

merge_adjacent_polygons()[fuente]

Merge adjacent polygons in each feature geometry.

merge_adjacents()[fuente]

Merge polygons with shared segments.

merge_geometries(groups, geometries, sort=None, reverse=False, split=True)[fuente]

Merge groups of fids from geometries.

Parámetros
  • groups (list) – groups of adjacent polygons

  • geometries (dict) – feature id: geometry

  • sort (lambda or None) – key to sort group

  • reverse (bool) – reverse sort if True

  • split (bool) – split multipart geometries if True

Devuelve

feature id: geometry changed geometries

Tipo del valor devuelto

(dict)

simplify()[fuente]

Reduce the number of vertices in a polygon layer.

  • Delete vertex if the angle with its adjacents is near of the straight angle for less than “straight_thr” degrees in all its parents.

  • Delete vertex if the distance to the segment formed by its parents is less than “cath_thr” meters.

topology(dup_thr=False)[fuente]

Add to nearest segments each vertex in a polygon layer.