def path_to_dataset(test_dataset_filename) -> str: '''Create a new dataset file and return its path.''' path_to_dataset = test_dataset_filename(__file__) RasterDataset.create(path_to_dataset, 'GTiff', gdal.GDT_Float32, shape=(6, 4, 5), origin=(-123, 45), pixel_size=(1.0, 2.0), coordinate_system='WGS84') return path_to_dataset
def valid_dataset_filename(test_dataset_filename) -> str: '''Return a new gdal.Dataset instance''' valid_dataset_filename = test_dataset_filename(__file__) RasterDataset.create(valid_dataset_filename, 'GTiff', gdal.GDT_Float32, shape=(4, 3, 2), origin=(-123, 45), pixel_size=(1.0, 2.0), coordinate_system='WGS84') return valid_dataset_filename
def raster_dataset(test_dataset_filename, array_assigned_to_band_index_0, array_assigned_to_band_index_1) -> gdal.Dataset: '''Create a new dataset, and set its values using write_band() and write_pixel() functions.''' # create the new dataset dataset_file = test_dataset_filename(__file__) raster_dataset = RasterDataset.create(dataset_file, 'GTiff', gdal.GDT_Float32, shape=(2, 2, 2), origin=(-123, 45), pixel_size=(1.0, 1.0), coordinate_system='WGS84') # set the values in band 1 with a call to write_band raster_dataset.write_band(0, array_assigned_to_band_index_0, float('Nan')) # set the values in band 2 with calls to write_pixel raster_dataset.write_pixel(1, 0, 0, array_assigned_to_band_index_1[0, 0]) raster_dataset.write_pixel(1, 0, 1, array_assigned_to_band_index_1[0, 1]) raster_dataset.write_pixel(1, 1, 0, array_assigned_to_band_index_1[1, 0]) raster_dataset.write_pixel(1, 1, 1, array_assigned_to_band_index_1[1, 1]) raster_dataset.flush() return raster_dataset
def raster_dataset(test_dataset_filename) -> RasterDataset: '''Return a new RasterDataset.''' return RasterDataset.create(test_dataset_filename(__file__), 'GTiff', gdal.GDT_Float32, shape=(6, 4, 5), origin=(-123, 45), pixel_size=(1.0, 2.0), coordinate_system='WGS84')
def raster_dataset(test_dataset_filename, array_assigned_to_band_index_0, array_assigned_to_band_index_1) -> RasterDataset: '''Create a new dataset, and set its values using write_band() functions.''' datafile_path = test_dataset_filename(__file__) raster_dataset = RasterDataset.create(datafile_path, 'GTiff', gdal.GDT_Float32, shape=(2, 2, 2), origin=(-123, 45), pixel_size=(1.0, 1.0), coordinate_system='WGS84') # set the values in bands 0 and 1 with calls to write_band raster_dataset.write_band(0, array_assigned_to_band_index_0, float('nan')) raster_dataset.write_band(1, array_assigned_to_band_index_1, float('nan')) raster_dataset.flush() return raster_dataset