def test_computes_expected_total_value(self): """ RasterStatistics() computes correct total value of raster. """ r = RasterStatistics(raster="worldpop_gambia") result = r.get_dataframe() self.assertAlmostEqual(result["statistic"].iloc[0], 2083543.79777587)
def test_computes_expected_clipping_values(self): """ RasterStatistics() returns correct values when clipping vector and raster layers. """ G = "district_c" vector = Table(schema="public", name="gambia_admin2") r = RasterStatistics(raster="worldpop_gambia", vector=vector, grouping_element=G) result = r.get_dataframe() for expected_result in self.rasterio_results.to_dict("records"): self.assertAlmostEqual( int(result[result[G] == expected_result["district"]].statistic.iloc[0]), expected_result["value"], )