Read Data

netCDF

We recommend using xarray’s open_dataset

For a single file

import xarray as xr
ds = xr.open_dataset(filename)

For multiple files

import xarray as xr
ds = xr.open_mfdataset(list_of_filenames)

R code coming soon!

# Coming soon!

Matlab code coming soon!

#| echo: true
# Coming soon!

HDF5

For HDF5 files, there are two methods we can use: xarray’s open_dataset and h5py

import xarray as xr
ds = xr.open_dataset(filename,
                     group=path_to_H5netCDF_group)
# add in directions for h5py

R code coming soon!

# Coming soon!

Matlab code coming soon!

#| echo: true
# Coming soon!

GeoTIFF

For GeoTIFF files, we recommend using rioxarray’s open_rasterio

import rioxarray
xds = rioxarray.open_rasterio("my.tif")

R code coming soon!

# Coming soon!

Matlab code coming soon!

#| echo: true
# Coming soon!

Shapefiles & GeoJSON

To open shapefiles or GeoJSON, we recommend using geopandas’s read_file.

import geopandas as gpd
gdf = gpd.read_file(filename)

R code coming soon!

# Coming soon!

Matlab code coming soon!

#| echo: true
# Coming soon!

CSV

To open CSV files, we recommend using pandas’s read_csv.

import pandas as pd
df = pd.read_csv(filename)

R code coming soon!

# Coming soon!

Matlab code coming soon!

#| echo: true
# Coming soon!

Excel

To open Excel files, we recommend using pandas’s read_excel

import pandas as pd
df = pd.read_excel(filename)

R code coming soon!

# Coming soon!

Matlab code coming soon!

#| echo: true
# Coming soon!

.mat Files

#coming soon! scipy & .mat

R code coming soon!

# Coming soon!

Matlab code coming soon!

#| echo: true
# Coming soon!

Binary Files

To open binary files, we recommend using numpy’s from_file. You will need to know the dimensions and data type of the binary file and if there is an offset or header information in the binary file.

import numpy as np
arr = np.from_file(filepath, dtype=data_type).reshape(nrows, ncols)

R code coming soon!

# Coming soon!

Matlab code coming soon!

#| echo: true
# Coming soon!