eobox.raster.gdalutils¶
-
eobox.raster.gdalutils.buildvrt(input_file_list, output_file, relative=True, **kwargs)[source]¶ Build a VRT
See also: https://www.gdal.org/gdalbuildvrt.html
You can find the possible BuildVRTOptions (kwargs) here: https://github.com/nextgis/pygdal/blob/78a793057d2162c292af4f6b240e19da5d5e52e2/2.1.0/osgeo/gdal.py#L1051
- Parameters
{list of str or Path objects} -- List of input files. (input_file_list) –
{str or Path object} -- Output file (output_file) –
- Keyword Arguments
{bool} -- If True, the input_file_list paths are converted to relative (relative) – paths (relative to the output file) and the VRT works even if the data is moved somewhere else - given that the relative location of theVRT and the input files does not chance!
{} -- BuildVRTOptions - see function description for a link to . (**kwargs) –
- Returns
[int] – If successful, 0 is returned as exit code.
-
eobox.raster.gdalutils.rasterize(src_vector: str, burn_attribute: str, src_raster_template: str, dst_rasterized: str, gdal_dtype: int = 4)[source]¶ Rasterize the values of a spatial vector file.
- Parameters
{str}} -- A OGR vector file (src_vector) – data to be rasterized.
{str} -- The attribute of the vector data to be burned in the raster. (burn_attribute) –
{str} -- Path to a GDAL raster file to be used as template for the (src_raster_template) – rasterized data.
{str} -- Path of the destination file. (dst_rasterized) –
{int} -- Numeric GDAL data type (gdal_dtype) – See https://github.com/mapbox/rasterio/blob/master/rasterio/dtypes.py for useful look-up tables.
to 4 which is UInt32. (defaults) – See https://github.com/mapbox/rasterio/blob/master/rasterio/dtypes.py for useful look-up tables.
- Returns
None
-
eobox.raster.gdalutils.reproject_on_template_raster(src_file, dst_file, template_file, resampling='near', compress=None, overwrite=False)[source]¶ Reproject a one-band raster to fit the projection, extend, pixel size etc. of a template raster.
Function based on https://stackoverflow.com/questions/10454316/how-to-project-and-resample-a-grid-to-match-another-grid-with-gdal-python
- Parameters
{str} -- Filename of the source one-band raster. (src_file) –
{str} -- Filename of the destination raster. (dst_file) –
{str} -- Filename of the template raster. (template_file) –
{str} -- Resampling type (resampling) – ‘near’ (default), ‘bilinear’, ‘cubic’, ‘cubicspline’, ‘lanczos’, ‘average’, ‘mode’, ‘max’, ‘min’, ‘med’, ‘q1’, ‘q3’, see https://www.gdal.org/gdalwarp.html -r parameter.
{str} -- Compression type (compress) – None (default), ‘lzw’, ‘packbits’, ‘defalte’.