code: def get_center(ds, t_srs=None):
      
      gt = ds.GetGeoTransform()
      ds_srs = get_ds_srs(ds)
      #Note: this is center of center pixel, not ul corner of center pixel
      center = [gt[0] + (gt[1] * ds.RasterXSize/2.0), gt[3] + (gt[5] * ds.RasterYSize/2.0)]
      #include t_srs.Validate() and t_srs.Fixup()
      if t_srs is not None and not ds_srs.IsSame(t_srs):
          ct = osr.CoordinateTransformation(ds_srs, t_srs)
          center = list(ct.TransformPoint(*center)[0:2])
      return center
docs: Get center coordinates of GDAL Dataset