def test_ggb_from_rio_dataset(self): # get Land/Sea data file for this bounding box utmZone = 56 utmDataPath = '/g/data/v10/eoancillarydata/Land_Sea_Rasters/WORLDzone%d.tif' % (utmZone,) # read the data for the Flinders islet region with rio.open(utmDataPath) as ds: # get the gridded box for the full data extent datasetGGB = GriddedGeoBox.from_dataset(ds) # print # print "For Land/Sea read via rasterio:" self._land_sea_GGB_asserts(datasetGGB)
def no_test_ggb_subsets(self): # get Land/Sea data file for this bounding box utmZone = 56 utmDataPath = '/g/data/v10/eoancillarydata/Land_Sea_Rasters/WORLDzone%d.tif' % (utmZone,) # read the data for the Flinders islet region with rio.open(utmDataPath) as ds: # get the gridded box for the full data extent datasetGGB = GriddedGeoBox.from_dataset(ds) flindersGGB = getFlindersIsletGGB() window = datasetGGB.window(flindersGGB) print('window=', window) windowShape = (window[1][1] - window[1][0], window[0][1] - window[0][0]) print(windowShape) # transform the origin of the window windowOriginXY = (window[1][0], window[0][0]) print('windowOriginXY=', windowOriginXY) windowOriginUTM = datasetGGB.affine * windowOriginXY print('windowOriginUTM=', windowOriginUTM) utm2wgs84 = osr.CoordinateTransformation(datasetGGB.crs, flindersGGB.crs) windowOrigin = utm2wgs84.TransformPoint(windowOriginUTM[0], windowOriginUTM[1]) print('windowOrigin=', windowOrigin) flindersOrigin = (150.927659, -34.453309) print('flindersOrigin=', flindersOrigin) diff = (flindersOrigin[0] - windowOrigin[0], flindersOrigin[1] - windowOrigin[1]) print('diff=', diff) wgs842utm = osr.CoordinateTransformation(flindersGGB.crs, datasetGGB.crs) (xUtm, yUtm, zzz) = wgs842utm.TransformPoint(flindersOrigin[0], flindersOrigin[1]) (xWgs84, yWgs84, zzz) = utm2wgs84.TransformPoint(xUtm, yUtm) print('(xUtm, yUtm)= ', (xUtm, yUtm)) print('(xWgs84, yWgs84)=', (xWgs84, yWgs84)) if not windowShape == flindersGGB.shape: self.fail("%s == %s" % (windowShape, flindersGGB.shape))
def no_test_ggb_copy_and_rereference(self): # get Land/Sea data file for this bounding box utmZone = 56 utmDataPath = '/g/data/v10/eoancillarydata/Land_Sea_Rasters/WORLDzone%d.tif' % (utmZone,) # read the data for the Flinders islet region with rio.open(utmDataPath) as ds: # get the gridded box for the full data extent datasetGGB = GriddedGeoBox.from_dataset(ds) # dataset will be UTM # print datasetGGB # copy to WSG84 newGGB = datasetGGB.copy(crs='EPSG:4326')
def test_convert_coordinate_to_image(self): """ Test that an input image/array co-ordinate is correctly converted to a map co-cordinate. Simple case: The first pixel. """ # get Land/Sea data file for this bounding box utmZone = 56 utmDataPath = '/g/data/v10/eoancillarydata/Land_Sea_Rasters/WORLDzone%d.tif' % (utmZone,) # read the data for the Flinders islet region with rio.open(utmDataPath) as ds: # get the gridded box for the full data extent datasetGGB = GriddedGeoBox.from_dataset(ds) ximg, yimg = datasetGGB.convert_coordinates(datasetGGB.origin, to_map=False) self.assertTrue((0, 0) == (ximg, yimg))
def no_test_ggb_subsets(self): # get Land/Sea data file for this bounding box utmZone = 56 utmDataPath = '/g/data/v10/eoancillarydata/Land_Sea_Rasters/WORLDzone%d.tif' % (utmZone,) # read the data for the Flinders islet region with rio.open(utmDataPath) as ds: # get the gridded box for the full data extent datasetGGB = GriddedGeoBox.from_dataset(ds) flindersGGB = getFlindersIsletGGB() scale = 0.00025 shapeYX = (3, 3) origin = (150.0, -34.0) corner = (shapeYX[1] * scale + origin[0], origin[1] - shapeYX[0] * scale) ggb = GriddedGeoBox(shapeYX, origin) assert ggb is not None self.assertEqual(shapeYX, ggb.shape) self.assertEqual(origin, ggb.origin) self.assertEqual(corner, ggb.corner)
def test_convert_coordinate_to_map_offset(self): """ Test that an input image/array co-ordinate is correctly converted to a map co-cordinate using a pixel centre offset. Simple case: The first pixel. """ # get Land/Sea data file for this bounding box utmZone = 56 utmDataPath = '/g/data/v10/eoancillarydata/Land_Sea_Rasters/WORLDzone%d.tif' % (utmZone,) # read the data for the Flinders islet region with rio.open(utmDataPath) as ds: # get the gridded box for the full data extent datasetGGB = GriddedGeoBox.from_dataset(ds) xmap, ymap = datasetGGB.convert_coordinates((0, 0), centre=True) # Get the actual centre co-ordinate of the first pixel xcentre, ycentre = datasetGGB.convert_coordinates((0.5, 0.5)) self.assertTrue((xcentre, ycentre) == (xmap, ymap))