Expect that column values as geometries each have a centroid that are within a given reference shape.
expect_column_values_geometry_centroids_to_be_within_shape
This expectation level is BETA
Contributors:
Tags:
geospatial
hackathon-2022
Metrics:
column_values.nonnull.unexpected_count
column_values.geometry.centroids_within_shape.unexpected_count
table.row_count
column_values.geometry.centroids_within_shape.unexpected_values
Description
Expect that column values as geometries each have a centroid that are within a given reference shape.
expect_column_values_geometry_centroids_to_be_within_shape is a Column Map Expectation.
Args:
- column (str): The column name. Column values must be provided in WKT or WKB format, which are commom formats for GIS Database formats. WKT can be accessed thhrough the ST_AsText() or ST_AsBinary() functions in queries for PostGIS and MSSQL.
Keyword Args:
- shape (str or list of str): The reference geometry
- shape_format (str): Geometry format for 'shape' string(s). Can be provided as 'Well Known Text' (WKT), 'Well Known Binary' (WKB), or as GeoJSON. Must be one of: [wkt, wkb, geojson]. Default: wkt
- column_shape_format (str): Geometry format for 'column'. Column values must be provided in WKT or WKB format, which are commom formats for GIS Database formats. WKT can be accessed thhrough the ST_AsText() or ST_AsBinary() functions in queries for PostGIS and MSSQL.
Returns:
Notes:
- Convention is (X Y Z) for points, which would map to (Longitude Latitude Elevation) for geospatial cases.
- Any convention can be followed as long as the test and reference shapes are consistent.
- The reference shape allows for an array, but will union (merge) all the shapes into 1 and check the contains condition.
- MultiLinestrings and Multipolygons area weighted by their length and areas, respectively. See the pygeos docs for reference.
Want to make your own Expectation or an improvement to this one?
We've put together some great how to guides (including videos) on how to create your own expectations in a flash!
You can see those resources here: Contributor Resources