qgreenland/util/raster.py
def _get_raster_srs_str(fp):
    """Read a raster with GDAL and return its SRS or None."""
    try:
        tmp_ds = gdal.Open(fp, GA_ReadOnly)

        # Get WKT projection from gdal
        srs_str = tmp_ds.GetProjection()

        if not srs_str:
            raise Exception('GDAL failed to detect any projection.')

        # Attempt to do better than the WKT from gdal...
        try:
            proj = pyproj.crs.CRS.from_wkt(srs_str)
            return proj.to_string()
        except Exception:
            pass

        # Close the gdal dataset
        del tmp_ds

        return srs_str
    except Exception as e:
        logger.info(f'Failed to detect projection: {e}')
        return None
Read a raster with GDAL and return its SRS or None.
Read a raster with GDAL and return its SRS or None.
Read a raster with GDAL and return its SRS or None .
def _get_raster_srs_str(fp):
    try:
        tmp_ds = gdal.Open(fp, GA_ReadOnly)
        srs_str = tmp_ds.GetProjection()
        if not srs_str:
            raise Exception('GDAL failed to detect any projection.')
        try:
            proj = pyproj.crs.CRS.from_wkt(srs_str)
            return proj.to_string()
        except Exception:
            pass
        del tmp_ds
        return srs_str
    except Exception as e:
        logger.info(f'Failed to detect projection: {e}')
        return None
def _get_raster_srs_str ( fp ) : try : tmp_ds = gdal . Open ( fp , GA_ReadOnly ) srs_str = tmp_ds . GetProjection ( ) if not srs_str : raise Exception ( 'GDAL failed to detect any projection.' ) try : proj = pyproj . crs . CRS . from_wkt ( srs_str ) return proj . to_string ( ) except Exception : pass del tmp_ds return srs_str except Exception as e : logger . info ( f'Failed to detect projection: {e}' ) return None
Read a raster with GDAL and return its SRS or None.
Read a raster with GDAL and return its SRS or None .
"""Read a raster with GDAL and return its SRS or None.""" # Get WKT projection from gdal # Attempt to do better than the WKT from gdal... # Close the gdal dataset
fp