Skip to content

Instantly share code, notes, and snippets.

@rileyhales
Created April 14, 2024 18:51
Show Gist options
  • Save rileyhales/ec78fa1c1d6453c407faee8d9c72acea to your computer and use it in GitHub Desktop.
Save rileyhales/ec78fa1c1d6453c407faee8d9c72acea to your computer and use it in GitHub Desktop.
Save GEOGLOWS datasets to disc
import geoglows
# get a list of river id numbers you are interested in downloading
river_ids = [710431167, ]
# Pandas DataFrames and Xarray Datasets each support several output formats
# Use the function for the file format you want and provide a file path for the output
# example using DataFrames - works for both forecasts and retrospective data
df = geoglows.data.forecast(river_id=river_ids, format='df')
df.to_parquet('./forecast_data.parquet')
df.to_csv('./forecast_data.csv')
df.to_excel('./forecast_data.xlsx')
# example using Datsets - works for both forecasts and retrospective data
ds = geoglows.data.retrospective(river_id=river_ids, format='xarray')
ds.to_netcdf('./forecast_data.nc')
ds.to_zarr('./forecast_data.zarr')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment