cars.core.inputs

Inputs module: contains some CARS global shared general purpose inputs functions

Module Contents

Functions

read_vector(path_to_file)

Read vector file and returns the corresponding polygon

rasterio_get_nb_bands(→ int)

Get the number of bands in an image file

rasterio_get_size(→ Tuple[int, int])

Get the size of an image (file)

rasterio_read_as_array(→ Tuple[numpy.ndarray, dict])

Get the data of an image file, and its profile

rasterio_get_profile(→ Dict)

Get the profile of an image file

rasterio_can_open(→ bool)

Test if a file can be open by rasterio

ncdf_can_open(file_path)

Checks if the given file can be opened by NetCDF

check_json(conf, schema)

Check a dictionary with respect to a schema

cars.core.inputs.read_vector(path_to_file)

Read vector file and returns the corresponding polygon

:raise Exception when the input file is unreadable

Parameters

path_to_file (str) – path to the file to open

Returns

a shapely polygon

Return type

tuple (polygon, epsg)

cars.core.inputs.rasterio_get_nb_bands(raster_file: str) int

Get the number of bands in an image file

Parameters

raster_file – Image file

Returns

The number of bands

cars.core.inputs.rasterio_get_size(raster_file: str) Tuple[int, int]

Get the size of an image (file)

Parameters

raster_file – Image file

Returns

The size (width, height)

cars.core.inputs.rasterio_read_as_array(raster_file: str, window: rasterio.windows.Window = None) Tuple[numpy.ndarray, dict]

Get the data of an image file, and its profile

Parameters
  • raster_file – Image file

  • window – Window to get data from

Returns

The array, its profile

cars.core.inputs.rasterio_get_profile(raster_file: str) Dict

Get the profile of an image file

Parameters

raster_file – Image file

Returns

The profile of the given image

cars.core.inputs.rasterio_can_open(raster_file: str) bool

Test if a file can be open by rasterio

Parameters

raster_file – File to test

Returns

True if rasterio can open file and False otherwise

cars.core.inputs.ncdf_can_open(file_path)

Checks if the given file can be opened by NetCDF :param file_path: file path. :type file_path: str :return: True if it can be opened, False otherwise. :rtype: bool

cars.core.inputs.check_json(conf, schema)

Check a dictionary with respect to a schema

Parameters
  • conf (dict) – The dictionary to check

  • schema (dict) – The schema to use

Returns

conf if check succeeds (else raises CheckerError)

Return type

dict