glymur/jp2box.py
def _print_geotiff_as_geotiff(self):
        """
        Print geotiff information.  Shamelessly ripped off from gdalinfo.py

        Returns
        -------
        str
            String representation of the degenerate geotiff.
        """
        if self.data is None:
            return "corrupt"
        in_mem_name = '/vsimem/geo.tif'
        gdal.FileFromMemBuffer(in_mem_name, self.raw_data)
        gtif = gdal.Open(in_mem_name)

        # Report projection
        proj_ref = gtif.GetProjectionRef()
        sref = osr.SpatialReference()
        sref.ImportFromWkt(proj_ref)
        psz_pretty_wkt = sref.ExportToPrettyWkt(False)

        # report geotransform
        geo_xform = gtif.GetGeoTransform(can_return_null=True)
        geotransform_str = (
            f'Origin = ({geo_xform[0]:.15f},{geo_xform[3]:.15f})\n'
            f'Pixel Size = ({geo_xform[1]:.15f},{geo_xform[5]:.15f})'
        )

        # setup projected to lat/long transform if appropriate
        if proj_ref is not None and len(proj_ref) > 0:
            hProj = osr.SpatialReference(proj_ref)
            if hProj is not None:
                hLatLong = hProj.CloneGeogCS()

            if hLatLong is not None:
                hTransform = osr.CoordinateTransformation(hProj, hLatLong)
            else:
                raise RuntimeError('Unable to proceed.')

        # report corners
        uleft = self.GDALInfoReportCorner(gtif, hTransform, "Upper Left", 0, 0)
        lleft = self.GDALInfoReportCorner(gtif, hTransform, "Lower Left",
                                          0, gtif.RasterYSize)
        uright = self.GDALInfoReportCorner(gtif, hTransform, "Upper Right",
                                           gtif.RasterXSize, 0)
        lright = self.GDALInfoReportCorner(gtif, hTransform, "Lower Right",
                                           gtif.RasterXSize, gtif.RasterYSize)
        center = self.GDALInfoReportCorner(gtif, hTransform, "Center",
                                           gtif.RasterXSize / 2.0,
                                           gtif.RasterYSize / 2.0)

        gdal.Unlink(in_mem_name)

        fmt = ("Coordinate System =\n"
               "{coordinate_system}\n"
               "{geotransform}\n"
               "Corner Coordinates:\n"
               "{upper_left}\n"
               "{lower_left}\n"
               "{upper_right}\n"
               "{lower_right}\n"
               "{center}")
        coordinate_system = textwrap.indent(psz_pretty_wkt, ' ' * 4)
        msg = fmt.format(coordinate_system=coordinate_system,
                         geotransform=geotransform_str,
                         upper_left=uleft, upper_right=uright,
                         lower_left=lleft, lower_right=lright, center=center)
        return msg

        Print geotiff information.  Shamelessly ripped off from gdalinfo.py

        Returns
        -------
        str
            String representation of the degenerate geotiff.
        
Print geotiff information.  Shamelessly ripped off from gdalinfo.py
Returns

str
String representation of the degenerate geotiff.
Print geotiff information . Shamelessly ripped off from gdalinfo . py Returns str String representation of the degenerate geotiff .
def _print_geotiff_as_geotiff(self):
        if self.data is None:
            return "corrupt"
        in_mem_name = '/vsimem/geo.tif'
        gdal.FileFromMemBuffer(in_mem_name, self.raw_data)
        gtif = gdal.Open(in_mem_name)
        proj_ref = gtif.GetProjectionRef()
        sref = osr.SpatialReference()
        sref.ImportFromWkt(proj_ref)
        psz_pretty_wkt = sref.ExportToPrettyWkt(False)
        geo_xform = gtif.GetGeoTransform(can_return_null=True)
        geotransform_str = (
            f'Origin = ({geo_xform[0]:.15f},{geo_xform[3]:.15f})\n'
            f'Pixel Size = ({geo_xform[1]:.15f},{geo_xform[5]:.15f})'
        )
        if proj_ref is not None and len(proj_ref) > 0:
            hProj = osr.SpatialReference(proj_ref)
            if hProj is not None:
                hLatLong = hProj.CloneGeogCS()
            if hLatLong is not None:
                hTransform = osr.CoordinateTransformation(hProj, hLatLong)
            else:
                raise RuntimeError('Unable to proceed.')
        uleft = self.GDALInfoReportCorner(gtif, hTransform, "Upper Left", 0, 0)
        lleft = self.GDALInfoReportCorner(gtif, hTransform, "Lower Left",
                                          0, gtif.RasterYSize)
        uright = self.GDALInfoReportCorner(gtif, hTransform, "Upper Right",
                                           gtif.RasterXSize, 0)
        lright = self.GDALInfoReportCorner(gtif, hTransform, "Lower Right",
                                           gtif.RasterXSize, gtif.RasterYSize)
        center = self.GDALInfoReportCorner(gtif, hTransform, "Center",
                                           gtif.RasterXSize / 2.0,
                                           gtif.RasterYSize / 2.0)
        gdal.Unlink(in_mem_name)
        fmt = ("Coordinate System =\n"
               "{coordinate_system}\n"
               "{geotransform}\n"
               "Corner Coordinates:\n"
               "{upper_left}\n"
               "{lower_left}\n"
               "{upper_right}\n"
               "{lower_right}\n"
               "{center}")
        coordinate_system = textwrap.indent(psz_pretty_wkt, ' ' * 4)
        msg = fmt.format(coordinate_system=coordinate_system,
                         geotransform=geotransform_str,
                         upper_left=uleft, upper_right=uright,
                         lower_left=lleft, lower_right=lright, center=center)
        return msg
def _print_geotiff_as_geotiff ( self ) : if self . data is None : return "corrupt" in_mem_name = '/vsimem/geo.tif' gdal . FileFromMemBuffer ( in_mem_name , self . raw_data ) gtif = gdal . Open ( in_mem_name ) proj_ref = gtif . GetProjectionRef ( ) sref = osr . SpatialReference ( ) sref . ImportFromWkt ( proj_ref ) psz_pretty_wkt = sref . ExportToPrettyWkt ( False ) geo_xform = gtif . GetGeoTransform ( can_return_null = True ) geotransform_str = ( f'Origin = ({geo_xform[0]:.15f},{geo_xform[3]:.15f})\n' f'Pixel Size = ({geo_xform[1]:.15f},{geo_xform[5]:.15f})' ) if proj_ref is not None and len ( proj_ref ) > 0 : hProj = osr . SpatialReference ( proj_ref ) if hProj is not None : hLatLong = hProj . CloneGeogCS ( ) if hLatLong is not None : hTransform = osr . CoordinateTransformation ( hProj , hLatLong ) else : raise RuntimeError ( 'Unable to proceed.' ) uleft = self . GDALInfoReportCorner ( gtif , hTransform , "Upper Left" , 0 , 0 ) lleft = self . GDALInfoReportCorner ( gtif , hTransform , "Lower Left" , 0 , gtif . RasterYSize ) uright = self . GDALInfoReportCorner ( gtif , hTransform , "Upper Right" , gtif . RasterXSize , 0 ) lright = self . GDALInfoReportCorner ( gtif , hTransform , "Lower Right" , gtif . RasterXSize , gtif . RasterYSize ) center = self . GDALInfoReportCorner ( gtif , hTransform , "Center" , gtif . RasterXSize / 2.0 , gtif . RasterYSize / 2.0 ) gdal . Unlink ( in_mem_name ) fmt = ( "Coordinate System =\n" "{coordinate_system}\n" "{geotransform}\n" "Corner Coordinates:\n" "{upper_left}\n" "{lower_left}\n" "{upper_right}\n" "{lower_right}\n" "{center}" ) coordinate_system = textwrap . indent ( psz_pretty_wkt , ' ' * 4 ) msg = fmt . format ( coordinate_system = coordinate_system , geotransform = geotransform_str , upper_left = uleft , upper_right = uright , lower_left = lleft , lower_right = lright , center = center ) return msg
Print geotiff information.
Print geotiff information .
"""
        Print geotiff information.  Shamelessly ripped off from gdalinfo.py

        Returns
        -------
        str
            String representation of the degenerate geotiff.
        """ # Report projection # report geotransform # setup projected to lat/long transform if appropriate # report corners
self