本文整理汇总了Python中django.contrib.gis.gdal.raster.const.GDAL_RESAMPLE_ALGORITHMS属性的典型用法代码示例。如果您正苦于以下问题:Python const.GDAL_RESAMPLE_ALGORITHMS属性的具体用法?Python const.GDAL_RESAMPLE_ALGORITHMS怎么用?Python const.GDAL_RESAMPLE_ALGORITHMS使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类django.contrib.gis.gdal.raster.const
的用法示例。
在下文中一共展示了const.GDAL_RESAMPLE_ALGORITHMS属性的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: transform
# 需要导入模块: from django.contrib.gis.gdal.raster import const [as 别名]
# 或者: from django.contrib.gis.gdal.raster.const import GDAL_RESAMPLE_ALGORITHMS [as 别名]
def transform(self, srid, driver=None, name=None, resampling='NearestNeighbour',
max_error=0.0):
"""
Returns a copy of this raster reprojected into the given SRID.
"""
# Convert the resampling algorithm name into an algorithm id
algorithm = GDAL_RESAMPLE_ALGORITHMS[resampling]
# Instantiate target spatial reference system
target_srs = SpatialReference(srid)
# Create warped virtual dataset in the target reference system
target = capi.auto_create_warped_vrt(
self._ptr, self.srs.wkt.encode(), target_srs.wkt.encode(),
algorithm, max_error, c_void_p()
)
target = GDALRaster(target)
# Construct the target warp dictionary from the virtual raster
data = {
'srid': srid,
'width': target.width,
'height': target.height,
'origin': [target.origin.x, target.origin.y],
'scale': [target.scale.x, target.scale.y],
'skew': [target.skew.x, target.skew.y],
}
# Set the driver and filepath if provided
if driver:
data['driver'] = driver
if name:
data['name'] = name
# Warp the raster into new srid
return self.warp(data, resampling=resampling, max_error=max_error)