geopyspark.geotrellis.rasterize module

geopyspark.geotrellis.rasterize.rasterize(geoms, crs, zoom, fill_value, cell_type=<CellType.FLOAT64: 'float64'>, options=None, partition_strategy=None)

Rasterizes a Shapely geometries.

Parameters:
  • geoms ([shapely.geometry] or (shapely.geometry) or pyspark.RDD[shapely.geometry]) – Either a list, tuple, or a Python RDD of shapely geometries to rasterize.
  • crs (str or int) – The CRS of the input geometry.
  • zoom (int) – The zoom level of the output raster.
  • fill_value (int or float) – Value to burn into pixels intersectiong geometry
  • cell_type (str or CellType) – Which data type the cells should be when created. Defaults to CellType.FLOAT64.
  • options (RasterizerOptions, optional) – Pixel intersection options.
  • partition_strategy (HashPartitionStrategy or SpatialPartitioinStrategy, optional) –

    Sets the Partitioner for the resulting layer and how many partitions it has. Default is, None.

    If None, then the output layer will have the default Partitioner and a number of paritions that was determined by the method.

    If partition_strategy is set but has no num_partitions, then the resulting layer will have the Partioner specified in the strategy with the with same number of partitions the source layer had.

    If partition_strategy is set and has a num_partitions, then the resulting layer will have the Partioner and number of partitions specified in the strategy.

Returns:

TiledRasterLayer

geopyspark.geotrellis.rasterize.rasterize_features(features, crs, zoom, cell_type=<CellType.FLOAT64: 'float64'>, options=None, zindex_cell_type=<CellType.INT8: 'int8'>, partition_strategy=None)

Rasterizes a collection of Features.

Parameters:
  • features (pyspark.RDD[Feature]) –

    A Python RDD that contains Features.

    Note

    The properties of each Feature must be an instance of CellValue.

  • crs (str or int) – The CRS of the input geometry.
  • zoom (int) –

    The zoom level of the output raster.

    Note

    Not all rasterized Features may be present in the resulting layer if the zoom is not high enough.

  • cell_type (str or CellType) – Which data type the cells should be when created. Defaults to CellType.FLOAT64.
  • options (RasterizerOptions, optional) – Pixel intersection options.
  • zindex_cell_type (str or CellType) – Which data type the Z-Index cells are. Defaults to CellType.INT8.
  • partition_strategy (HashPartitionStrategy or SpatialPartitioinStrategy, optional) –

    Sets the Partitioner for the resulting layer and how many partitions it has. Default is, None.

    If None, then the output layer will have the default Partitioner and a number of paritions that was determined by the method.

    If partition_strategy is set but has no num_partitions, then the resulting layer will have the Partioner specified in the strategy with the with same number of partitions the source layer had.

    If partition_strategy is set and has a num_partitions, then the resulting layer will have the Partioner and number of partitions specified in the strategy.

Returns:

TiledRasterLayer