code: def copyproj(src_fn, dst_fn, gt=True):
      
      src_ds = gdal.Open(src_fn, gdal.GA_ReadOnly)
      dst_ds = gdal.Open(dst_fn, gdal.GA_Update)
      dst_ds.SetProjection(src_ds.GetProjection())
      if gt:
          src_gt = np.array(src_ds.GetGeoTransform())
          src_dim = np.array([src_ds.RasterXSize, src_ds.RasterYSize])
          dst_dim = np.array([dst_ds.RasterXSize, dst_ds.RasterYSize])
          #This preserves dst_fn resolution
          if np.any(src_dim != dst_dim):
              res_factor = src_dim/dst_dim.astype(float)
              src_gt[[1, 5]] *= max(res_factor)
              #src_gt[[1, 5]] *= min(res_factor)
              #src_gt[[1, 5]] *= res_factor
          dst_ds.SetGeoTransform(src_gt)
      src_ds = None
      dst_ds = None
docs: Copy projection and geotransform from one raster file to another