sgsPy
structurally guided sampling
Loading...
Searching...
No Matches

Functions

OGRGeometry * sgs::systematic::getAccessPolygon (vector::GDALVectorWrapper *p_access, std::string layerName, double buffInner, double buffOuter)
bool sgs::systematic::checkExtent (double x, double y, double xMin, double xMax, double yMin, double yMax)
bool sgs::systematic::checkAccess (OGRPoint *p_point, OGRGeometry *p_geometry)
bool sgs::systematic::checkExisting (double x, double y, existing::Existing &existing)
bool sgs::systematic::checkNotNan (raster::GDALRasterWrapper *p_raster, double *IGT, double xCoord, double yCoord, bool force)
std::tuple< vector::GDALVectorWrapper *, std::vector< std::vector< double > >, std::vector< std::vector< std::vector< double > > > > sgs::systematic::systematic (raster::GDALRasterWrapper *p_raster, double cellSize, std::string shape, std::string location, vector::GDALVectorWrapper *p_existing, vector::GDALVectorWrapper *p_access, std::string layerName, double buffInner, double buffOuter, bool force, bool plot, std::string filename)

Detailed Description

Function Documentation

◆ checkAccess()

bool sgs::systematic::checkAccess ( OGRPoint * p_point,
OGRGeometry * p_geometry )
inline

Helper function for checking to see whether a pixel occurs within accessible area.

Parameters
OGRPoint*p_point
OGRGeometry*p_geometry
Returns
bool

◆ checkExisting()

bool sgs::systematic::checkExisting ( double x,
double y,
existing::Existing & existing )
inline

Helper function for checking to see whether a pixel is already an existing sample location.

Parameters
doublex
doubley
Existing&existing
Returns
bool

◆ checkExtent()

bool sgs::systematic::checkExtent ( double x,
double y,
double xMin,
double xMax,
double yMin,
double yMax )
inline

Helper function for ensuring the x and y coordinates are within the raster extent.

Parameters
doublex
doubley
doublexMin
doublexMax
doubleyMin
doubleyMax
Returns
bool

◆ checkNotNan()

bool sgs::systematic::checkNotNan ( raster::GDALRasterWrapper * p_raster,
double * IGT,
double xCoord,
double yCoord,
bool force )
inline

Helper function for checking to see whether a coordinate occurs in an area of nodata.

the 'force' parameter is first checked, because if force is not true, then samples are allowed to occur on nodata pixels.

THe inverted geotransform is used to find the x and y values from the coordinates given. Then, every raster band within the input raster is checked, and if that pixel is a no data value in any of them false is returned. the GDALRasterBand RasterIO function is used to read the desried pixel from the raster.

Parameters
GDALRasterWrapper*p_raster,
double*IGT
doublexCoord
doubleyCoord
boolforce
Returns
bool

◆ getAccessPolygon()

OGRGeometry * sgs::systematic::getAccessPolygon ( vector::GDALVectorWrapper * p_access,
std::string layerName,
double buffInner,
double buffOuter )

Helper function for generating a vector geometry containing polygons of the accessible area. This function is called if an access vector is given.

The input vector dataset must be comprised of solely LineString and MultiLineString geometries. The LineStrings are buffered by buff outer, then have buff_inner subtracted from them.

The returned geometry is checked to see whether it contains points which are trying to be sampled. If the geometry does not contain a given point, that point is considered inaccessible and thus not sampled.

Parameters
GDALVectorWrapper*p_access
std::stringlayerName
doublebuffInner
doublebuffOuter
Returns
OGRGeometry *

◆ systematic()

std::tuple< vector::GDALVectorWrapper *, std::vector< std::vector< double > >, std::vector< std::vector< std::vector< double > > > > sgs::systematic::systematic ( raster::GDALRasterWrapper * p_raster,
double cellSize,
std::string shape,
std::string location,
vector::GDALVectorWrapper * p_existing,
vector::GDALVectorWrapper * p_access,
std::string layerName,
double buffInner,
double buffOuter,
bool force,
bool plot,
std::string filename )

This function conducts Systematic sampling on an input raster image.

First, the extent polygon of the raster is determined, then a random point is found within the polygon to act as the origin. An SQL query is conducted using one of the ST_SquareGrid, or ST_HexagonalGrid spatialite functions to create a grid of polygons of the user-specified shape. The grid is then rotated by a randomly generated rotation angle.

Next, the resulting grid polygons are iterated through, and a sample point is determined for each polygon depending on the user-defined location parameter (centers, corners, or random), and the samples are saved to an OGRLayer which is part of GDALDataset. Plot-required data is saved if plot is true (to later be utilized by the Python side of the application with matplotlib).

If the an access vector is given, then polygons of the accessible area are created, and each sample is check to ensure it falls within the accessible area.

If an existing vector is given, all of the sample points within the existing vector are added, and each point is checked to ensure it has not already been added by virtue of already existing as a sample point.

If the force parameter is given, every sample added is checked against the input raster to ensure the sample does not fall in a no data pixel. If it does the sample is thrown out. In the case where each grid cell is randomly sampled, 10 tries are allowed to find a point which is contains a data pixel otherwise that cell is not sampled.

Parameters
GDALRasterWrapper*p_raster
doublecellSize
std::stringshape
std::stringlocation
boolplot
std::stringfilename
Returns
std::tuple< GDALVectorWrapper *, std::vector<std::vector<double>>, std::vector<std::vector<std::vector<double>>> >