πŸ“¦ Reading data

EOmaps provides some basic capabilities to read and plot directly from commonly used file-types.

Note

At the moment, the readers are intended as a β€œshortcut” to read well-structured datasets! If they fail, read the data manually and then set the data as usual via Maps.set_data().

Under the hood, EOmaps uses the following libraries to read data:

  • GeoTIFF (rioxarray + xarray.open_dataset())

  • NetCDF (xarray.open_dataset())

  • CSV (pandas.read_csv())

Read data from a file

m.read_file.<filetype>(...) can be used to read all relevant data (e.g. values, coordinates & crs) from a file.

m = Maps()
data = Maps.read_file.NetCDF(
    "the filepath",
    parameter="adsf",
    coords=("longitude", "latitude"),
    data_crs=4326,
    isel=dict(time=123)
    )
m.set_data(**data)
...
m.plot_map()

read_file.GeoTIFF

Read all relevant information necessary to add a GeoTIFF to the map.

read_file.NetCDF

Read all relevant information necessary to add a NetCDF to the map.

read_file.CSV

Read all relevant information necessary to add a CSV-file to the map.

Initialize a Maps-object from a file

Maps.from_file.<filetype>(...) can be used to directly initialize a Maps object from a file. (This is particularly useful if you have a well-defined file-structure that you need to access regularly)

m = Maps.from_file.GeoTIFF(
    "the filepath",
    classify_specs=dict(Maps.CLASSFIERS.Quantiles, k=10),
    cmap="RdBu"
    )
m.add_colorbar()
m.cb.pick.attach.annotate()

from_file.GeoTIFF

Convenience function to initialize a new Maps-object from a GeoTIFF file.

from_file.NetCDF

Convenience function to initialize a new Maps-object from a NetCDF file.

from_file.CSV

Convenience function to initialize a new Maps-object from a CSV file.

Create a new layer from a file

Similar to Maps.from_file , a new layer based on a file can be added to an existing Maps object via Maps.new_layer_from_file.<filetype>(...).

m = Maps()
m.add_feature.preset.coastline()

m2 = m.new_layer_from_file(
    "the filepath",
    parameter="adsf",
    coords=("longitude", "latitude"),
    data_crs=4326,
    isel=dict(time=123),
    classify_specs=dict(Maps.CLASSFIERS.Quantiles, k=10),
    cmap="RdBu"
    )

new_layer_from_file.GeoTIFF

Convenience function to initialize a new Maps-object from a GeoTIFF file.

new_layer_from_file.NetCDF

Convenience function to initialize a new Maps-object from a NetCDF file.

new_layer_from_file.CSV

Convenience function to initialize a new Maps-object from a CSV file.