* it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ """ import os # import GDAL and QGIS libraries from osgeo import gdal, osr, ogr gdal.UseExceptions() import gdalconst # import logging for debug messages import terre_image_logging logger = terre_image_logging.configure_logger() def get_image_epsg_code_with_gdal(image_in): """ Extract the following information from the given image: - epsg code """ try: dataset = gdal.Open(image_in, gdalconst.GA_ReadOnly) except RuntimeError: # OSError is get when the access to a folder is refused logger.exception("Error: Opening " + image_in) return spatialReference = osr.SpatialReference() spatialReference.ImportFromWkt(dataset.GetProjectionRef())
email : [email protected] ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ """ # import logging for debug messages import terre_image_logging logger = terre_image_logging.configure_logger() class TerreImageConstant(object): """ This class allow to manage constants of the catalog. It manages: iface -- iface to link the catalog to qgis (adding layers, acces to canvas...) canvas -- mapCanvas of qgis == self.iface.mapCanvas() legendInterface -- acces from qgis to symbols, layers ... index_group -- qgis group of terre_image. """ instance = None def __new__(cls, *args, **kwargs): # __new__ always a classmethod if not cls.instance: cls.instance = super(TerreImageConstant, cls).__new__(cls, *args, **kwargs) # S2Constant.__S2Constant()