Transforms

Module

The module provides the transformation of the georeferenced data from raster to vector format and back.

Vector map rasterization

aeronet.dataset.transforms.rasterize(feature_collection, transform, out_shape, name='mask')[source]
Transform vector geometries to raster form, return band sample where
raster is np.array of bool dtype (True value correspond to objects area)
Parameters:
  • feature_collectionFeatureCollection object
  • transform – Affine transformation object Transformation from pixel coordinates of source to the coordinate system of the input shapes. See the transform property of dataset objects.
  • out_shape – tuple or list Shape of output numpy ndarray.
  • name – output sample name, default mask
Returns:

BandSample object

Raster mask polygonization

aeronet.dataset.transforms.polygonize(sample, epsilon=0.1, properties={})[source]

Transform the raster mask to vector polygons. The pixels in the raster mask are treated as belonging to the object if their value is non-zero, and zero values are background. All the objects are transformed to the vector form (polygons).

The algorithm is OpenCV cv2.findContours

This method is used as it does process the hierarchy of inlayed contours correctly. It also makes polygon simplification, which produces more smooth and lightweight polygons, but they do not match the raster mask exactly, which should be taken into account.

Parameters:
  • sample – BandSample to be vectorized
  • epsilon – the epsilon parameter for the cv2.approxPolyDP, which specifies the approximation accuracy.
  • is the maximum distance between the original curve and its approximation (This) –
  • properties – (dict) Properties to be added to the resulting FeatureCollection
Returns:

Polygons in the CRS of the sample, that represent non-black objects in the image

Return type:

FeatureCollection