def write_raster_dataset(fpath, dataset, format, options=None, remove=False):
""" Write raster dataset to file format
.. versionadded 0.10.0
Parameters
----------
fpath : string
A file path - should have file extension corresponding to format.
dataset : gdal.Dataset
gdal raster dataset
format : string
gdal raster format string
options : list
List of option strings for the corresponding format.
remove : bool
if True, existing gdal.Dataset will be
removed before creation
Note
----
For format and options refer to
`formats_list <http://www.gdal.org/formats_list.html>`_.
Examples
--------
See :ref:`notebooks/fileio/wradlib_gis_export_example.ipynb`.
"""
# check for option list
if options is None:
options = []
driver = gdal.GetDriverByName(format)
metadata = driver.GetMetadata()
# check driver capability
if 'DCAP_CREATECOPY' in metadata and metadata['DCAP_CREATECOPY'] != 'YES':
assert "Driver %s doesn't support CreateCopy() method.".format(format)
if remove:
if os.path.exists(fpath):
driver.Delete(fpath)
target = driver.CreateCopy(fpath, dataset, 0, options)
del target
评论列表
文章目录