Exemplo n.º 1
0
 def test_sample_2d_array(self):
     grid = RegularGrid([0.0, 0.0, 1.0, 1.0, 0.0, 0.0],
                        values=np.array([[0, 1], [1, 0.5]]))
     xi = np.array([[0.7, 1.3], [0.7, 1.3]])
     yi = np.array([[0.7, 0.7], [1.3, 1.3]])
     z = grid.sample(xi, yi, method="nearest")
     self.assertTrue(np.all(z == np.array([[0, 1], [1, 0.5]])))
Exemplo n.º 2
0
 def test_sample_multipoint(self):
     grid = RegularGrid([0.0, 0.0, 1.0, 1.0, 0.0, 0.0],
                        values=np.array([[0, 1], [1, 0.5]]))
     mp = karta.Multipoint([(0.6, 0.7), (0.6, 1.3), (1.4, 0.3), (1.6, 1.3)],
                           crs=grid.crs)
     self.assertTrue(
         np.all(
             np.allclose(grid.sample(mp, method="nearest"),
                         np.array([0.0, 1.0, 1.0, 0.5]))))