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
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’.