|
sgsPy
structurally guided sampling
|
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) |
|
inline |
Helper function for checking to see whether a pixel occurs within accessible area.
| OGRPoint | *p_point |
| OGRGeometry | *p_geometry |
|
inline |
Helper function for checking to see whether a pixel is already an existing sample location.
| double | x |
| double | y |
| Existing& | existing |
|
inline |
Helper function for ensuring the x and y coordinates are within the raster extent.
| double | x |
| double | y |
| double | xMin |
| double | xMax |
| double | yMin |
| double | yMax |
|
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.
| GDALRasterWrapper | *p_raster, |
| double | *IGT |
| double | xCoord |
| double | yCoord |
| bool | force |
| 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.
| GDALVectorWrapper | *p_access |
| std::string | layerName |
| double | buffInner |
| double | buffOuter |
| 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.
| GDALRasterWrapper | *p_raster |
| double | cellSize |
| std::string | shape |
| std::string | location |
| bool | plot |
| std::string | filename |