Beispiel #1
0
 def test_middle_point_with_GRS80(self):
     # Same as test_middle_point(), but with a different reference system, GRS80; the
     # result should be the same.
     point = hspatial.coordinates2point(325077, 4205177, srid=2100)
     self.assertAlmostEqual(hspatial.extract_point_from_raster(
         point, self.fp),
                            2.2,
                            places=2)
Beispiel #2
0
 def test_with_prefix(self):
     # Same as test_with_list_of_files(), but with prefix.
     point = hspatial.coordinates2point(22.01001, 37.98001)
     prefix = os.path.join(self.tempdir, "test")
     ts = hspatial.PointTimeseries(point,
                                   prefix=prefix,
                                   default_time=dt.time(23, 58)).get()
     self._check_against_expected(ts)
Beispiel #3
0
 def test_bottom_left_point_with_GRS80(self):
     # Same as test_bottom_left_point(), but with a different reference system,
     # GRS80; the result should be the same.
     point = hspatial.coordinates2point(324076, 4205176, srid=2100)
     self.assertAlmostEqual(hspatial.extract_point_from_raster(
         point, self.fp),
                            3.1,
                            places=2)
Beispiel #4
0
 def test_bottom_left_point(self):
     # Use almost exactly same point as test_middle_point(), only slightly altered
     # so that we get bottom left point instead.
     point = hspatial.coordinates2point(22.00999, 37.97999)
     self.assertAlmostEqual(hspatial.extract_point_from_raster(
         point, self.fp),
                            3.1,
                            places=2)
Beispiel #5
0
 def test_middle_point(self):
     # We use co-ordinates almost to the common corner of the four lower left points,
     # only a little bit towards the center.
     point = hspatial.coordinates2point(22.01001, 37.98001)
     self.assertAlmostEqual(hspatial.extract_point_from_raster(
         point, self.fp),
                            2.2,
                            places=2)
Beispiel #6
0
 def test_with_list_of_files(self):
     # Use co-ordinates almost to the common corner of the four lower left points,
     # and only a little bit towards the center.
     point = hspatial.coordinates2point(22.01001, 37.98001)
     filenames = [
         os.path.join(self.tempdir, "test-2014-11-22-16-1.tif"),
         os.path.join(self.tempdir, "test-2014-11-21-16-1.tif"),
         os.path.join(self.tempdir, "test-2014-11-23-16-1.tif"),
     ]
     ts = hspatial.PointTimeseries(point, filenames=filenames).get()
     self._check_against_expected(ts)
Beispiel #7
0
 def test_transform_does_not_modify_srid_of_gdal_point(self):
     pppoint = hspatial.PassepartoutPoint(
         hspatial.coordinates2point(324651, 4205742, srid=2100))
     original_spatial_reference = pppoint.point.GetSpatialReference(
     ).ExportToWkt()
     sr = osr.SpatialReference()
     sr.ImportFromEPSG(4326)
     pppoint.transform_to(sr.ExportToWkt())
     self.assertEqual(
         pppoint.point.GetSpatialReference().ExportToWkt(),
         original_spatial_reference,
     )
Beispiel #8
0
 def setUp(self):
     super().setUp()
     self.point = hspatial.coordinates2point(22.01001, 37.98001)
     self.prefix = os.path.join(self.tempdir, "test")
     self.dest = os.path.join(self.tempdir, "dest.hts")
Beispiel #9
0
 def test_unit_of_measurement(self):
     point = hspatial.coordinates2point(22.01001, 37.98001)
     prefix = os.path.join(self.tempdir, "test")
     ts = hspatial.PointTimeseries(point, prefix=prefix).get()
     self.assertEqual(ts.unit, "microkernels")
Beispiel #10
0
 def test_with_prefix_and_geodjango(self):
     point = hspatial.coordinates2point(22.01001, 37.98001)
     prefix = os.path.join(self.tempdir, "test")
     ts = hspatial.PointTimeseries(point, prefix=prefix).get()
     self._check_against_expected(ts)
Beispiel #11
0
 def test_fails_gracefully_when_osr_point_is_really_outside_crs_limits(
         self):
     point = hspatial.coordinates2point(125.0, 85.0)
     with self.assertRaises(RuntimeError):
         hspatial.extract_point_from_raster(point, self.fp)
Beispiel #12
0
 def test_point_outside_raster(self):
     point = hspatial.coordinates2point(21.0, 38.0)
     with self.assertRaises(RuntimeError):
         hspatial.extract_point_from_raster(point, self.fp)
Beispiel #13
0
 def test_does_not_modify_srid_of_point(self):
     point = hspatial.coordinates2point(325077, 4205177, srid=2100)
     original_spatial_reference = point.GetSpatialReference().ExportToWkt()
     hspatial.extract_point_from_raster(point, self.fp)
     self.assertEqual(point.GetSpatialReference().ExportToWkt(),
                      original_spatial_reference)
Beispiel #14
0
 def test_top_middle_point(self):
     point = hspatial.coordinates2point(22.015, 37.995)
     self.assertTrue(
         math.isnan(hspatial.extract_point_from_raster(point, self.fp)))
Beispiel #15
0
 def test_top_left_point(self):
     point = hspatial.coordinates2point(22.005, 37.995)
     self.assertAlmostEqual(hspatial.extract_point_from_raster(
         point, self.fp),
                            1.1,
                            places=2)