GEOS 3.15.0dev
Public Member Functions | Static Public Member Functions | List of all members
geos::operation::grid::GridIntersection Class Reference

The GridIntersection class computes and stores information about intersection of a Grid and a Geometry. For a polygonal geometry, the fraction of each grid cell covered by polygon is stored. For a linear geometry, the length of the line in each grid cell is stored. More...

#include <GridIntersection.h>

Public Member Functions

 GridIntersection (const Grid< bounded_extent > &raster_grid, const geom::Geometry &g, const std::shared_ptr< Matrix< float > > &cov=nullptr)
 Compute the fraction of each cell in a rectangular grid that is covered by a Geometry. A matrix can be provided to which the fractions will be added.
 
 GridIntersection (const Grid< bounded_extent > &raster_grid, const geom::Envelope &box, const std::shared_ptr< Matrix< float > > &cov=nullptr)
 Compute the fraction of each cell in a rectangular grid that is covered by an Envelope. A matrix can be provided to which the fractions will be added.
 
std::shared_ptr< Matrix< float > > getResults ()
 Return the intersection result matrix.
 

Static Public Member Functions

static std::unique_ptr< geom::GeometrysubdividePolygon (const Grid< bounded_extent > &grid, const geom::Geometry &g, bool includeExterior)
 Partition a polygonal geometry by a grid.
 
static std::shared_ptr< Matrix< float > > getIntersectionFractions (const Grid< bounded_extent > &grid, const geom::Geometry &g)
 Calculate the fraction of each cell in a Grid that is covered by a polygon.
 
static std::shared_ptr< Matrix< float > > getIntersectionFractions (const Grid< bounded_extent > &grid, const geom::Envelope &box)
 
static geom::Envelope processingRegion (const geom::Envelope &raster_extent, const geom::Geometry &geometry)
 Determines the bounding box of the raster-vector intersection. Considers the bounding boxes of individual polygon components separately to avoid unnecessary computation for sparse multi-polygons.
 

Detailed Description

The GridIntersection class computes and stores information about intersection of a Grid and a Geometry. For a polygonal geometry, the fraction of each grid cell covered by polygon is stored. For a linear geometry, the length of the line in each grid cell is stored.

Intersection information returned as Raster with an equivalent resolution to the input Grid. The spatial extent may be reduced from the input Grid.

Member Function Documentation

◆ getIntersectionFractions()

static std::shared_ptr< Matrix< float > > geos::operation::grid::GridIntersection::getIntersectionFractions ( const Grid< bounded_extent > &  grid,
const geom::Geometry g 
)
static

Calculate the fraction of each cell in a Grid that is covered by a polygon.

Parameters
gridthe Grid for which coverage fractions should be returned
ga polygonal or linear geometry
Returns
a matrix having the same number of rows and columns as the grid, whose values contain either the fraction of the cell area (for polygonal inputs) or the length of the intersection (for linear inputs)

◆ processingRegion()

static geom::Envelope geos::operation::grid::GridIntersection::processingRegion ( const geom::Envelope raster_extent,
const geom::Geometry geometry 
)
static

Determines the bounding box of the raster-vector intersection. Considers the bounding boxes of individual polygon components separately to avoid unnecessary computation for sparse multi-polygons.

Parameters
raster_extentEnvelope representing the extent of the vector
geometryGeometry to be processed
Returns
the portion of raster_extent that intersects one or more component_boxes

◆ subdividePolygon()

static std::unique_ptr< geom::Geometry > geos::operation::grid::GridIntersection::subdividePolygon ( const Grid< bounded_extent > &  grid,
const geom::Geometry g,
bool  includeExterior 
)
static

Partition a polygonal geometry by a grid.

Parameters
gridthe Grid by which the polygon should be partitioned. The Grid does not need to cover the polygon.
ga polygonal geometry
includeExteriorwhether the result should contain any portions of the input that fall outside the grid.
Returns
a GeometryCollection containing the partitioned polygon.

The documentation for this class was generated from the following file: