title: How to read PNG and add data from a tiff file to it and save it as another tiff?
body: <p>I have two files. One is PNG and the other is TIFF (or .jp2). I want to read geospatial data from the satellite image (.jp2 or .tif) and &quot;put it in&quot; the png file, then save it as a new tif.</p>
  <p>I'm very new to working with raster data. I'm using rasterio and so far I've managed to get the meta of a tif file:</p>
  <pre><code>import rasterio as rio
  tif = rio.open(&quot;TIFFile.tif&quot;)
  png = rio.open(&quot;PNGFile.png&quot;)
  
  tif_read = tif.read()
  png_read = png.read()
  
  tif_width = tif.width
  tif_height = tif.height
  tif_dim = (tif_width, tif_height)
  
  png_width = png.width
  png_height = png.height
  png_dim = (png_width, png_height)
  
  tif_meta = tif.meta
  png_meta = png.meta
  
  print(&quot;TIF META: &quot;, tif_meta)
  print(&quot;PNG META: &quot;, png_meta)
  </code></pre>
  <p>Output:</p>
  <pre><code>TIF META:  {'driver': 'GTiff', 'dtype': 'float32', 'nodata': None, 'width': 10980, 'height': 10980, 'count': 4, 'crs': CRS.from_epsg(32635), 'transform': Affine(10.0, 0.0, 699965.0,
     0.0, -10.0, 4100035.0)}
  PNG META:  {'driver': 'GTiff', 'dtype': 'float32', 'nodata': None, 'width': 5490, 'height': 5490, 'count': 1, 'crs': None, 'transform': Affine(1.0, 0.0, 0.0,
     0.0, 1.0, 0.0)}
  </code></pre>
  <p>I know I can create a new tif file using original tif's meta like this:</p>
  <pre><code>with rio.open('NEWTIF.tif', 'w', **tif_meta) as dst:
      dst.write(tif_read.astype(rio.float32))
  </code></pre>
  <p>In light of this, basically, I'd like to know how to create a new tif file adding another tif's meta into a png file - merging png's raster data with tif's geospatial data.</p>
  <p>I've been searching for this but couldn't understood what I've found in SO:</p>
  <p><a href="https://stackoverflow.com/questions/58505245/how-to-convert-png-files-to-geotiff">How to convert png files to geotiff</a>
  <a href="https://gis.stackexchange.com/questions/371065/apply-same-coordinate-system-to-raster-image-and-geojson-with-rasterio">https://gis.stackexchange.com/questions/371065/apply-same-coordinate-system-to-raster-image-and-geojson-with-rasterio</a>
  <a href="https://gis.stackexchange.com/questions/379027/georeferencing-of-png-and-convert-to-tiff-using-python">https://gis.stackexchange.com/questions/379027/georeferencing-of-png-and-convert-to-tiff-using-python</a></p>
  <p>How to achieve this?</p>