当前位置: 首页>>代码示例>>Python>>正文


Python gdal.GetDataTypeName方法代码示例

本文整理汇总了Python中osgeo.gdal.GetDataTypeName方法的典型用法代码示例。如果您正苦于以下问题:Python gdal.GetDataTypeName方法的具体用法?Python gdal.GetDataTypeName怎么用?Python gdal.GetDataTypeName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在osgeo.gdal的用法示例。


在下文中一共展示了gdal.GetDataTypeName方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: GetGeoInfo

# 需要导入模块: from osgeo import gdal [as 别名]
# 或者: from osgeo.gdal import GetDataTypeName [as 别名]
def GetGeoInfo(FileName):

    if exists(FileName) is False:
            raise Exception('[Errno 2] No such file or directory: \'' + FileName + '\'')    
    
    
    SourceDS = gdal.Open(FileName, gdal.GA_ReadOnly)
    if SourceDS == None:
        raise Exception("Unable to read the data file")
    
    NDV = SourceDS.GetRasterBand(1).GetNoDataValue()
    xsize = SourceDS.RasterXSize
    ysize = SourceDS.RasterYSize
    GeoT = SourceDS.GetGeoTransform()
    Projection = osr.SpatialReference()
    Projection.ImportFromWkt(SourceDS.GetProjectionRef())
    DataType = SourceDS.GetRasterBand(1).DataType
    DataType = gdal.GetDataTypeName(DataType)
    
    return NDV, xsize, ysize, GeoT, Projection, DataType
#==============================================================================

#==============================================================================
# Function to read the original file's projection: 
开发者ID:LSDtopotools,项目名称:LSDMappingTools,代码行数:26,代码来源:LSDMappingTools.py

示例2: get_reference_water_data

# 需要导入模块: from osgeo import gdal [as 别名]
# 或者: from osgeo.gdal import GetDataTypeName [as 别名]
def get_reference_water_data(self):
		ds = self.get_reference_water_dataset()
		
		band = ds.GetRasterBand(1)
		#print 'Band Type=',gdal.GetDataTypeName(band.DataType)

		#min = band.GetMinimum()
		#max = band.GetMaximum()
		#if min is None or max is None:
		#	(min,max) = band.ComputeRasterMinMax(1)
		#	print 'Min=%.3f, Max=%.3f' % (min,max)

		data = band.ReadAsArray(0, 0, ds.RasterXSize, ds.RasterYSize )
		# Read individual pixels using [yoff, xoff]
		# (math matrix notation is [row,col], not [x,y])
		
		return data 
开发者ID:vightel,项目名称:FloodMapsWorkshop,代码行数:19,代码来源:hand_floodfill.py

示例3: GetGeoInfo

# 需要导入模块: from osgeo import gdal [as 别名]
# 或者: from osgeo.gdal import GetDataTypeName [as 别名]
def GetGeoInfo(FileName):
    """This gets information from the raster file using gdal

    Args:
        FileName (str): The filename (with path and extension) of the raster.

    Return:
        float: A vector that contains:
            * NDV: the nodata values
            * xsize: cellsize in x direction
            * ysize: cellsize in y direction
            * GeoT: the tranform (a string)
            * Projection: the Projection (a string)
            * DataType: The type of data (an int explaing the bits of each data element)

    Author: SMM
    """


    if exists(FileName) is False:
            raise Exception('[Errno 2] No such file or directory: \'' + FileName + '\'')


    SourceDS = gdal.Open(FileName, gdal.GA_ReadOnly)
    if SourceDS == None:
        raise Exception("Unable to read the data file")

    NDV = SourceDS.GetRasterBand(1).GetNoDataValue()
    xsize = SourceDS.RasterXSize
    ysize = SourceDS.RasterYSize
    GeoT = SourceDS.GetGeoTransform()
    Projection = osr.SpatialReference()
    Projection.ImportFromWkt(SourceDS.GetProjectionRef())
    DataType = SourceDS.GetRasterBand(1).DataType
    DataType = gdal.GetDataTypeName(DataType)

    return NDV, xsize, ysize, GeoT, Projection, DataType
#==============================================================================

#==============================================================================
# This gets the UTM zone, if it exists 
开发者ID:LSDtopotools,项目名称:LSDMappingTools,代码行数:43,代码来源:LSDMap_GDALIO.py

示例4: get_geo_info

# 需要导入模块: from osgeo import gdal [as 别名]
# 或者: from osgeo.gdal import GetDataTypeName [as 别名]
def get_geo_info(filename, band=1):
    ''' Gets information from a Raster data set
    '''
    sourceds = gdal.Open(filename, GA_ReadOnly)
    ndv = sourceds.GetRasterBand(band).GetNoDataValue()
    xsize = sourceds.RasterXSize
    ysize = sourceds.RasterYSize
    geot = sourceds.GetGeoTransform()
    projection = osr.SpatialReference()
    projection.ImportFromWkt(sourceds.GetProjectionRef())
    datatype = sourceds.GetRasterBand(band).DataType
    datatype = gdal.GetDataTypeName(datatype)
    return ndv, xsize, ysize, geot, projection, datatype

# Function to map location in pixel of raster array 
开发者ID:ozak,项目名称:georasters,代码行数:17,代码来源:georasters.py

示例5: get_bil_data

# 需要导入模块: from osgeo import gdal [as 别名]
# 或者: from osgeo.gdal import GetDataTypeName [as 别名]
def get_bil_data(self, dataset):
		band = dataset.GetRasterBand(1)
		#print 'Band Type=',gdal.GetDataTypeName(band.DataType)
		data = band.ReadAsArray(0, 0, dataset.RasterXSize, dataset.RasterYSize )

		return data

	#	
	# Convert from EPSG:3857 meters to EPSG:4326 latlng
	# 
开发者ID:vightel,项目名称:FloodMapsWorkshop,代码行数:12,代码来源:hand_floodfill.py

示例6: _fromGDAL

# 需要导入模块: from osgeo import gdal [as 别名]
# 或者: from osgeo.gdal import GetDataTypeName [as 别名]
def _fromGDAL(self):
		'''Use GDAL to extract raster infos and init'''
		if self.path is None or not self.fileExists:
			raise IOError("Cannot find file on disk")
		ds = gdal.Open(self.path, gdal.GA_ReadOnly)
		self.size = xy(ds.RasterXSize, ds.RasterYSize)
		self.format = ds.GetDriver().ShortName
		if self.format in ['JP2OpenJPEG', 'JP2ECW', 'JP2KAK', 'JP2MrSID'] :
			self.format = 'JPEG2000'
		self.nbBands = ds.RasterCount
		b1 = ds.GetRasterBand(1) #first band (band index does not count from 0)
		self.noData = b1.GetNoDataValue()
		ddtype = gdal.GetDataTypeName(b1.DataType)#Byte, UInt16, Int16, UInt32, Int32, Float32, Float64
		if ddtype == "Byte":
			self.dtype = 'uint'
			self.depth = 8
		else:
			self.dtype = ddtype[0:len(ddtype)-2].lower()
			self.depth = int(ddtype[-2:])
		#Get Georef
		self.georef = GeoRef.fromGDAL(ds)
		#Close (gdal has no garbage collector)
		ds, b1 = None, None

	#######################################
	# Dynamic properties
	####################################### 
开发者ID:domlysz,项目名称:BlenderGIS,代码行数:29,代码来源:georaster.py

示例7: __init__

# 需要导入模块: from osgeo import gdal [as 别名]
# 或者: from osgeo.gdal import GetDataTypeName [as 别名]
def __init__(self,ds_filename,load_data=True,latlon=True,band=1,
        spatial_ref=None,geo_transform=None,downsampl=1):
        """ Open a single band raster.
        
        :param ds_filename: filename of the dataset to import
        :type ds_filename: str
        
        :param load_data: If True, to import the data into obj.r.  If False, 
        do not load any data. Provide tuple (left, right, bottom, top) to load 
        subset, in which case extent will be set to reflect subset area.
        :type load_data: 


            latlon : default True. Only used if load_data=tuple. Set as False
                     if tuple is projected coordinates, True if WGS84.
            band : default 1. Specify GDAL band number to load. If you want to
                   load multiple bands at once use MultiBandRaster instead.
            downsampl : default 1. Used to down-sample the image when loading it. 
                A value of 2 for example will multiply the resolution by 2. 

            Optionally, you can manually specify/override the georeferencing. 
            To do this you must set both of the following parameters:

            spatial_ref : a OSR SpatialReference instance
            geo_transform : a Geographic Transform tuple of the form 
                            (top left x, w-e cell size, 0, top left y, 0, 
                             n-s cell size (-ve))
            
        """

        # Do basic dataset loading - set up georeferencing
        self._load_ds(ds_filename,spatial_ref=spatial_ref,
                      geo_transform=geo_transform)

        # Import band datatype
        band_tmp = self.ds.GetRasterBand(band)
        self.dtype = gdal.GetDataTypeName(band_tmp.DataType)
        
        # Load entire image
        if load_data == True:
            self.r = self.read_single_band(band,downsampl=downsampl)

        # Or load just a subset region
        elif isinstance(load_data,tuple) or isinstance(load_data,list):
            if len(load_data) == 4:
                self.r = self.read_single_band_subset(load_data,latlon=latlon,
                    band=band,update_info=True,downsampl=downsampl)

        elif load_data == False:
            return

        else:
            print('Warning : load_data argument not understood. No data loaded.') 
开发者ID:GeoUtils,项目名称:georaster,代码行数:55,代码来源:georaster.py


注:本文中的osgeo.gdal.GetDataTypeName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。