コード例 #1
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))
コード例 #2
0
ファイル: test_export_geotiff.py プロジェクト: bjlittle/iris
 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
ファイル: test_export_geotiff.py プロジェクト: Jozhogg/iris
 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]]')
コード例 #4
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]]')
コード例 #5
0
ファイル: test_export_geotiff.py プロジェクト: bjlittle/iris
 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))
コード例 #6
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))
コード例 #7
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))
コード例 #8
0
ファイル: test_export_geotiff.py プロジェクト: bjlittle/iris
 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
ファイル: test_export_geotiff.py プロジェクト: bjlittle/iris
 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
ファイル: test_export_geotiff.py プロジェクト: bjlittle/iris
 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)
コード例 #12
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)
コード例 #13
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(), '')