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_values(raster_file, x_list, y_list, ...)

Get the z position of corresponding x and y as lon lat

rasterio_get_nb_bands(→ int)

Get the number of bands in an image file

rasterio_get_image_type(→ list)

Get the image type

rasterio_get_nbits(raster_file)

Get the band nbits list

rasterio_get_size(→ Tuple[int, int])

Get the size of an image (file)

rasterio_get_pixel_points(→ list)

Get pixel point coordinates of terrain points

rasterio_get_bounds(→ Tuple[int, int])

Get the bounds of an image (file)

rasterio_get_epsg_code(→ Tuple[int, int])

Get the epsg code of an image (file)

rasterio_get_list_min_max(→ Tuple[int, int])

Get the stats 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_get_transform(→ Dict)

Get the transform of an image file

rasterio_get_epsg(→ int)

Get the epsg of an image file

rasterio_transform_epsg(file_name, new_epsg)

Modify epsg of raster 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

get_descriptions_bands(→ Dict)

Get the descriptions bands of an image file

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_values(raster_file: str, x_list, y_list, proj_function)

Get the z position of corresponding x and y as lon lat

Parameters
  • raster_file – Image file

  • x_list (np array) – list of x position

  • y_list (np array) – list of y position

  • proj_function – projection function to use

Returns

The corresponding z position

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_image_type(raster_file: str) list

Get the image type

Parameters

raster_file – Image file

Returns

The image type

cars.core.inputs.rasterio_get_nbits(raster_file)

Get the band nbits list

Parameters

raster_file – Image file

Returns

The band nbits list

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_get_pixel_points(raster_file: str, terrain_points) list

Get pixel point coordinates of terrain points

Parameters
  • raster_file – Image file

  • terrain_points – points in terrain

Returns

pixel points

cars.core.inputs.rasterio_get_bounds(raster_file: str, apply_resolution_sign=False) Tuple[int, int]

Get the bounds of an image (file)

Parameters

raster_file – Image file

Returns

The size (width, height)

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

Get the epsg code of an image (file)

Parameters

raster_file – Image file

Returns

epsg code

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

Get the stats of an image (file)

Parameters

raster_file – Image file

Returns

The list min max

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_get_transform(raster_file: str) Dict

Get the transform of an image file

Parameters

raster_file – Image file

Returns

The transform of the given image

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

Get the epsg of an image file

Parameters

raster_file – Image file

Returns

The epsg of the given image

cars.core.inputs.rasterio_transform_epsg(file_name, new_epsg)

Modify epsg of raster file

Parameters
  • file_name – Image file

  • new_epsg – new epsg

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

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

Get the descriptions bands of an image file

Parameters

raster_file – Image file

Returns

The descriptions list of the given image