def _check_dtype(self, dtype, gdal_dtype):
     cube = self._cube(dtype)
     with self.temp_filename('.tif') as temp_filename:
         export_geotiff(cube, temp_filename)
         dataset = gdal.Open(temp_filename, gdal.GA_ReadOnly)
         band = dataset.GetRasterBand(1)
         self.assertEqual(band.DataType, gdal_dtype)
         self.assertEqual(band.ComputeRasterMinMax(1), (20, 31))
示例#2
0
 def _check_dtype(self, dtype, gdal_dtype):
     cube = self._cube(dtype)
     with self.temp_filename(".tif") as temp_filename:
         export_geotiff(cube, temp_filename)
         dataset = gdal.Open(temp_filename, gdal.GA_ReadOnly)
         band = dataset.GetRasterBand(1)
         self.assertEqual(band.DataType, gdal_dtype)
         self.assertEqual(band.ComputeRasterMinMax(1), (20, 31))
示例#3
0
 def test_ellipsoid(self):
     cube = self._cube(GeogCS(6377000, 6360000))
     with self.temp_filename('.tif') as temp_filename:
         export_geotiff(cube, temp_filename)
         dataset = gdal.Open(temp_filename, gdal.GA_ReadOnly)
         self.assertEqual(
             dataset.GetProjection(),
             'GEOGCS["unnamed ellipse",DATUM["unknown",'
             'SPHEROID["unnamed",6377000,375.117647058816]],'
             'PRIMEM["Greenwich",0],UNIT["degree",0.0174532925199433]]')
 def test_ellipsoid(self):
     cube = self._cube(GeogCS(6377000, 6360000))
     with self.temp_filename('.tif') as temp_filename:
         export_geotiff(cube, temp_filename)
         dataset = gdal.Open(temp_filename, gdal.GA_ReadOnly)
         self.assertEqual(
             dataset.GetProjection(),
             'GEOGCS["unnamed ellipse",DATUM["unknown",'
             'SPHEROID["unnamed",6377000,375.117647058816]],'
             'PRIMEM["Greenwich",0],UNIT["degree",0.0174532925199433]]')
示例#5
0
 def test_(self):
     data = np.arange(12).reshape(3, 4).astype(np.uint8)
     cube = Cube(data, "air_pressure_anomaly")
     coord = DimCoord([30, 40, 50], "latitude", units="degrees")
     coord.guess_bounds()
     cube.add_dim_coord(coord, 0)
     coord = DimCoord([-10, -5, 0, 5], "longitude", units="degrees")
     coord.guess_bounds()
     cube.add_dim_coord(coord, 1)
     with self.temp_filename(".tif") as temp_filename:
         export_geotiff(cube, temp_filename)
         dataset = gdal.Open(temp_filename, gdal.GA_ReadOnly)
         self.assertEqual(dataset.GetGeoTransform(), (-12.5, 5, 0, 55, 0, -10))
 def test_(self):
     data = np.arange(12).reshape(3, 4).astype(np.uint8)
     cube = Cube(data, 'air_pressure_anomaly')
     coord = DimCoord([30, 40, 50], 'latitude', units='degrees')
     coord.guess_bounds()
     cube.add_dim_coord(coord, 0)
     coord = DimCoord([-10, -5, 0, 5], 'longitude', units='degrees')
     coord.guess_bounds()
     cube.add_dim_coord(coord, 1)
     with self.temp_filename('.tif') as temp_filename:
         export_geotiff(cube, temp_filename)
         dataset = gdal.Open(temp_filename, gdal.GA_ReadOnly)
         self.assertEqual(dataset.GetGeoTransform(),
                          (-12.5, 5, 0, 55, 0, -10))
 def test_ellipsoid(self):
     cube = self._cube(GeogCS(6377000, 6360000))
     with self.temp_filename('.tif') as temp_filename:
         export_geotiff(cube, temp_filename)
         dataset = gdal.Open(temp_filename, gdal.GA_ReadOnly)
         projection_string = dataset.GetProjection()
         # String has embedded floating point values,
         # Test with values to N decimal places, using a regular expression.
         re_pattern = (
             r'GEOGCS\["unnamed ellipse",DATUM\["unknown",'
             r'SPHEROID\["unnamed",637....,375.117[0-9]*\]\],'
             r'PRIMEM\["Greenwich",0\],UNIT\["degree",0.01745[0-9]*\]\]')
         re_exp = re.compile(re_pattern)
         self.assertIsNotNone(
             re_exp.match(projection_string),
             'projection string {!r} does not match {!r}'.format(
                 projection_string, re_pattern))
示例#8
0
 def test_ellipsoid(self):
     cube = self._cube(GeogCS(6377000, 6360000))
     with self.temp_filename(".tif") as temp_filename:
         export_geotiff(cube, temp_filename)
         dataset = gdal.Open(temp_filename, gdal.GA_ReadOnly)
         projection_string = dataset.GetProjection()
         # String has embedded floating point values,
         # Test with values to N decimal places, using a regular expression.
         re_pattern = (
             r'GEOGCS\["unnamed ellipse",DATUM\["unknown",'
             r'SPHEROID\["unnamed",637....,375.117[0-9]*\]\],'
             r'PRIMEM\["Greenwich",0\],UNIT\["degree",0.01745[0-9]*\]\]'
         )
         re_exp = re.compile(re_pattern)
         self.assertIsNotNone(
             re_exp.match(projection_string),
             "projection string {!r} does not match {!r}".format(projection_string, re_pattern),
         )
示例#9
0
 def test_sphere(self):
     cube = self._cube(GeogCS(6377000))
     with self.temp_filename(".tif") as temp_filename:
         export_geotiff(cube, temp_filename)
         dataset = gdal.Open(temp_filename, gdal.GA_ReadOnly)
         projection_string = dataset.GetProjection()
         # String has embedded floating point values,
         # Test with values to N decimal places, using a regular expression.
         re_pattern = (
             r'GEOGCS\["unknown",DATUM\["unknown",'
             r'SPHEROID\["unknown",637....,0\]\],PRIMEM\["Greenwich",0\],'
             r'UNIT\["degree",0.01745[0-9]*,AUTHORITY\["EPSG","9122"\]\],'
             r'AXIS\["Latitude",NORTH\],AXIS\["Longitude",EAST\]\]')
         re_exp = re.compile(re_pattern)
         self.assertIsNotNone(
             re_exp.match(projection_string),
             "projection string {!r} does not match {!r}".format(
                 projection_string, re_pattern),
         )
示例#10
0
 def test_no_ellipsoid(self):
     cube = self._cube()
     with self.temp_filename(".tif") as temp_filename:
         export_geotiff(cube, temp_filename)
         dataset = gdal.Open(temp_filename, gdal.GA_ReadOnly)
         self.assertEqual(dataset.GetProjection(), "")
示例#11
0
 def test_invalid(self):
     cube = self._cube("i1")
     with self.assertRaises(ValueError):
         with self.temp_filename(".tif") as temp_filename:
             export_geotiff(cube, temp_filename)
 def test_invalid(self):
     cube = self._cube('i1')
     with self.assertRaises(ValueError):
         with self.temp_filename('.tif') as temp_filename:
             export_geotiff(cube, temp_filename)
 def test_no_ellipsoid(self):
     cube = self._cube()
     with self.temp_filename('.tif') as temp_filename:
         export_geotiff(cube, temp_filename)
         dataset = gdal.Open(temp_filename, gdal.GA_ReadOnly)
         self.assertEqual(dataset.GetProjection(), '')