本文整理汇总了Python中nansat.domain.Domain.get_geolocation_grids方法的典型用法代码示例。如果您正苦于以下问题:Python Domain.get_geolocation_grids方法的具体用法?Python Domain.get_geolocation_grids怎么用?Python Domain.get_geolocation_grids使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nansat.domain.Domain
的用法示例。
在下文中一共展示了Domain.get_geolocation_grids方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_get_geolocation_grids_from_geolocationArray
# 需要导入模块: from nansat.domain import Domain [as 别名]
# 或者: from nansat.domain.Domain import get_geolocation_grids [as 别名]
def test_get_geolocation_grids_from_geolocationArray(self):
lat, lon = np.mgrid[25:35:0.02, 70:72:0.004]
d = Domain(lon=lon, lat=lat)
lon, lat = d.get_geolocation_grids()
self.assertEqual(type(lon), np.ndarray)
self.assertEqual(type(lat), np.ndarray)
self.assertEqual(lat.shape, (500, 500))
示例2: test_get_geolocation_grids
# 需要导入模块: from nansat.domain import Domain [as 别名]
# 或者: from nansat.domain.Domain import get_geolocation_grids [as 别名]
def test_get_geolocation_grids(self):
d = Domain(4326, "-te 25 70 35 72 -ts 500 500")
lon, lat = d.get_geolocation_grids()
self.assertEqual(type(lon), np.ndarray)
self.assertEqual(type(lat), np.ndarray)
self.assertEqual(lat.shape, (500, 500))
示例3: test_get_geolocation_grids_from_GDAL_transformer
# 需要导入模块: from nansat.domain import Domain [as 别名]
# 或者: from nansat.domain.Domain import get_geolocation_grids [as 别名]
def test_get_geolocation_grids_from_GDAL_transformer(self, mock_transform_points):
mock_transform_points.return_value=(
np.meshgrid(range(0,500),range(0,500))[0].flatten()*(35-25)/500.+25,
np.meshgrid(range(0,500),range(0,500))[1].flatten()*(70-72)/500.+72)
d = Domain(4326, "-te 25 70 35 72 -ts 500 500")
lon, lat = d.get_geolocation_grids()
self.assertEqual(type(lon), np.ndarray)
self.assertEqual(type(lat), np.ndarray)
self.assertEqual(lat.shape, (500, 500))
示例4: __init__
# 需要导入模块: from nansat.domain import Domain [as 别名]
# 或者: from nansat.domain.Domain import get_geolocation_grids [as 别名]
def __init__(self, fileName, gdalDataset, gdalMetadata, **kwargs):
''' Create Radarsat2 VRT '''
fPathName, fExt = os.path.splitext(fileName)
if zipfile.is_zipfile(fileName):
# Open zip file using VSI
fPath, fName = os.path.split(fPathName)
fileName = '/vsizip/%s/%s' % (fileName, fName)
if not 'RS' in fName[0:2]:
raise WrongMapperError('Provided data is not Radarsat-2')
gdalDataset = gdal.Open(fileName)
gdalMetadata = gdalDataset.GetMetadata()
#if it is not RADARSAT-2, return
if (not gdalMetadata or
not 'SATELLITE_IDENTIFIER' in gdalMetadata.keys()):
raise WrongMapperError
elif gdalMetadata['SATELLITE_IDENTIFIER'] != 'RADARSAT-2':
raise WrongMapperError
# read product.xml
productXmlName = os.path.join(fileName, 'product.xml')
productXml = self.read_xml(productXmlName)
# Get additional metadata from product.xml
rs2_0 = Node.create(productXml)
rs2_1 = rs2_0.node('sourceAttributes')
rs2_2 = rs2_1.node('radarParameters')
if rs2_2['antennaPointing'].lower() == 'right':
antennaPointing = 90
else:
antennaPointing = -90
rs2_3 = rs2_1.node('orbitAndAttitude').node('orbitInformation')
passDirection = rs2_3['passDirection']
# create empty VRT dataset with geolocation only
VRT.__init__(self, gdalDataset)
#define dictionary of metadata and band specific parameters
pol = []
metaDict = []
# Get the subdataset with calibrated sigma0 only
for dataset in gdalDataset.GetSubDatasets():
if dataset[1] == 'Sigma Nought calibrated':
s0dataset = gdal.Open(dataset[0])
s0datasetName = dataset[0][:]
band = s0dataset.GetRasterBand(1)
s0datasetPol = band.GetMetadata()['POLARIMETRIC_INTERP']
for i in range(1, s0dataset.RasterCount+1):
iBand = s0dataset.GetRasterBand(i)
polString = iBand.GetMetadata()['POLARIMETRIC_INTERP']
suffix = polString
# The nansat data will be complex
# if the SAR data is of type 10
dtype = iBand.DataType
if dtype == 10:
# add intensity band
metaDict.append(
{'src': {'SourceFilename':
('RADARSAT_2_CALIB:SIGMA0:'
+ fileName + '/product.xml'),
'SourceBand': i,
'DataType': dtype},
'dst': {'wkv': 'surface_backwards_scattering_coefficient_of_radar_wave',
'PixelFunctionType': 'intensity',
'SourceTransferType': gdal.GetDataTypeName(dtype),
'suffix': suffix,
'polarization': polString,
'dataType': 6}})
# modify suffix for adding the compled band below
suffix = polString+'_complex'
pol.append(polString)
metaDict.append(
{'src': {'SourceFilename': ('RADARSAT_2_CALIB:SIGMA0:'
+ fileName
+ '/product.xml'),
'SourceBand': i,
'DataType': dtype},
'dst': {'wkv': 'surface_backwards_scattering_coefficient_of_radar_wave',
'suffix': suffix,
'polarization': polString}})
if dataset[1] == 'Beta Nought calibrated':
b0dataset = gdal.Open(dataset[0])
b0datasetName = dataset[0][:]
for j in range(1, b0dataset.RasterCount+1):
jBand = b0dataset.GetRasterBand(j)
polString = jBand.GetMetadata()['POLARIMETRIC_INTERP']
if polString == s0datasetPol:
b0datasetBand = j
###############################
# Add SAR look direction
###############################
d = Domain(ds=gdalDataset)
lon, lat = d.get_geolocation_grids(100)
'''
(GDAL?) Radarsat-2 data is stored with maximum latitude at first
#.........这里部分代码省略.........