eolearn.visualization.xarray_utils

This module implements conversion from/to xarray DataArray/Dataset

eolearn.visualization.xarray_utils.string_to_variable(string, extension=None)[source]
Parameters
  • string (str) – string to be used as python variable name

  • extension (str) – string to be appended to string

Returns

valid python variable name

Return type

str

eolearn.visualization.xarray_utils.get_coordinates(eopatch, feature, crs)[source]

Creates coordinates for xarray DataArray

Parameters
  • eopatch (EOPatch) – eopatch

  • feature ((FeatureType, str)) – feature of eopatch

  • crs (sentinelhub.crs) – convert spatial coordinates to crs

Returns

coordinates for xarry DataArray/Dataset

Return type

dict

eolearn.visualization.xarray_utils.get_dimensions(feature)[source]

Returns list of dimensions for xarray DataArray/Dataset

Parameters

feature ((FeatureType, str)) – eopatch feature

Returns

dimensions for xarray DataArray/Dataset

Return type

list(str)

eolearn.visualization.xarray_utils.array_to_dataframe(eopatch, feature, remove_depth=True, crs=None, convert_bool=True)[source]

Converts one feature of eopatch to xarray DataArray

Parameters
  • eopatch (EOPatch) – eopatch

  • feature ((FeatureType, str)) – feature of eopatch

  • remove_depth (bool) – removes last dimension if it is one

  • crs (sentinelhub.crs) – converts dimensions to crs

  • convert_bool (bool) – If True it will convert boolean dtype into uint8 dtype

Returns

dataarray

Return type

xarray DataArray

eolearn.visualization.xarray_utils.eopatch_to_dataset(eopatch, remove_depth=True)[source]

Converts eopatch to xarray Dataset

Parameters
  • eopatch (EOPatch) – eopathc

  • remove_depth (bool) – removes last dimension if it is one

Returns

dataset

Return type

xarray Dataset

eolearn.visualization.xarray_utils.new_coordinates(data, crs, new_crs)[source]

Returns coordinates for xarray DataArray/Dataset in new crs.

Parameters
  • data (xarray.DataArray or xarray.Dataset) – data for converting coordinates for

  • crs (sentinelhub.CRS) – old crs

  • new_crs (sentinelhub.CRS) – new crs

Returns

new x and y coordinates

Return type

(float, float)