Skip to main content
remove unnecessary comment from "edit"
Source Link
Bjorn Svensson
  • 3.6k
  • 20
  • 38

eventually this worked for me:

dataset = rasterio.open(input_file_path, 'r')
bands = [1, 2, 3]
data = dataset.read(bands)
transform = rasterio.transform.from_bounds(west, south, east, north, data.shape[1], data.shape[2])
crs = {'init': 'epsg:3006'}

with rasterio.open(output_file_path, 'w', driver='GTiff',
                   width=data.shape[1], height=data.shape[2],
                   count=3, dtype=data.dtype, nodata=0,
                   transform=transform, crs=crs) as dst:
    dst.write(data, indexes=bands) # changed _data to data

eventually this worked for me:

dataset = rasterio.open(input_file_path, 'r')
bands = [1, 2, 3]
data = dataset.read(bands)
transform = rasterio.transform.from_bounds(west, south, east, north, data.shape[1], data.shape[2])
crs = {'init': 'epsg:3006'}

with rasterio.open(output_file_path, 'w', driver='GTiff',
                   width=data.shape[1], height=data.shape[2],
                   count=3, dtype=data.dtype, nodata=0,
                   transform=transform, crs=crs) as dst:
    dst.write(data, indexes=bands) # changed _data to data

eventually this worked for me:

dataset = rasterio.open(input_file_path, 'r')
bands = [1, 2, 3]
data = dataset.read(bands)
transform = rasterio.transform.from_bounds(west, south, east, north, data.shape[1], data.shape[2])
crs = {'init': 'epsg:3006'}

with rasterio.open(output_file_path, 'w', driver='GTiff',
                   width=data.shape[1], height=data.shape[2],
                   count=3, dtype=data.dtype, nodata=0,
                   transform=transform, crs=crs) as dst:
    dst.write(data, indexes=bands)

eventually this worked for me:

dataset = rasterio.open(input_file_path, 'r')
bands = [1, 2, 3]
data = dataset.read(bands)
transform = rasterio.transform.from_bounds(west, south, east, north, data.shape[1], data.shape[2])
crs = {'init': 'epsg:3006'}

with rasterio.open(output_file_path, 'w', driver='GTiff',
                   width=data.shape[1], height=data.shape[2],
                   count=3, dtype=data.dtype, nodata=0,
                   transform=transform, crs=crs) as dst:
    dst.write(_datadata, indexes=bands) # changed _data to data

eventually this worked for me:

dataset = rasterio.open(input_file_path, 'r')
bands = [1, 2, 3]
data = dataset.read(bands)
transform = rasterio.transform.from_bounds(west, south, east, north, data.shape[1], data.shape[2])
crs = {'init': 'epsg:3006'}

with rasterio.open(output_file_path, 'w', driver='GTiff',
                   width=data.shape[1], height=data.shape[2],
                   count=3, dtype=data.dtype, nodata=0,
                   transform=transform, crs=crs) as dst:
    dst.write(_data, indexes=bands)

eventually this worked for me:

dataset = rasterio.open(input_file_path, 'r')
bands = [1, 2, 3]
data = dataset.read(bands)
transform = rasterio.transform.from_bounds(west, south, east, north, data.shape[1], data.shape[2])
crs = {'init': 'epsg:3006'}

with rasterio.open(output_file_path, 'w', driver='GTiff',
                   width=data.shape[1], height=data.shape[2],
                   count=3, dtype=data.dtype, nodata=0,
                   transform=transform, crs=crs) as dst:
    dst.write(data, indexes=bands) # changed _data to data
Source Link
Arshak
  • 279
  • 2
  • 5

eventually this worked for me:

dataset = rasterio.open(input_file_path, 'r')
bands = [1, 2, 3]
data = dataset.read(bands)
transform = rasterio.transform.from_bounds(west, south, east, north, data.shape[1], data.shape[2])
crs = {'init': 'epsg:3006'}

with rasterio.open(output_file_path, 'w', driver='GTiff',
                   width=data.shape[1], height=data.shape[2],
                   count=3, dtype=data.dtype, nodata=0,
                   transform=transform, crs=crs) as dst:
    dst.write(_data, indexes=bands)