Skip to content Skip to sidebar Skip to footer

How To Convert Png Files To Geotiff

I have set of png files and EPSG:3006 coordinates of the edges of each file. How can I convert those png files to geotiff files using Python so the tiff files would contain the geo

Solution 1:

found the solution:

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'}

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

Post a Comment for "How To Convert Png Files To Geotiff"