def test_clip_raster(self): """Test we can clip a raster layer.""" layer = load_test_raster_layer('gisv4', 'hazard', 'earthquake.asc') expected = QgsRectangle(106.75, -6.2, 106.80, -6.1) new_layer = clip_by_extent(layer, expected) extent = new_layer.extent() self.assertAlmostEqual(expected.xMinimum(), extent.xMinimum(), 0) self.assertAlmostEqual(expected.xMaximum(), extent.xMaximum(), 0) self.assertAlmostEqual(expected.yMinimum(), extent.yMinimum(), 0) self.assertAlmostEqual(expected.yMaximum(), extent.yMaximum(), 0)
def test_clip_raster(self): """Test we can clip a raster layer.""" layer = load_test_raster_layer('gisv4', 'hazard', 'earthquake.asc') expected = QgsRectangle(106.75, -6.2, 106.80, -6.1) new_layer = clip_by_extent(layer, expected) extent = new_layer.extent() self.assertAlmostEqual(expected.xMinimum(), extent.xMinimum(), 0) self.assertAlmostEqual(expected.xMaximum(), extent.xMaximum(), 0) self.assertAlmostEqual(expected.yMinimum(), extent.yMinimum(), 0) self.assertAlmostEqual(expected.yMaximum(), extent.yMaximum(), 0)