Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save copernicusmarinegist/b57417225d0d4ea47c5d6200f9d8cac3 to your computer and use it in GitHub Desktop.
Save copernicusmarinegist/b57417225d0d4ea47c5d6200f9d8cac3 to your computer and use it in GitHub Desktop.
Python Notebook Example on how to convert a netcdf file to csv file
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@saratiedt
Copy link

Hi, I'm looking for a dataset just like your to use on my project, can you shere the link with me, i will appreciated.

@copernicusmarine
Copy link

Hi @saratiedt! The data access for the dataset used in this (very old) tutorial is available from the official dataset landing page: https://resources.marine.copernicus.eu/?option=com_csw&view=details&product_id=SST_GLO_SST_L4_NRT_OBSERVATIONS_010_001

Feel free to check our HelpCenter out for self-service support!

Copernicus Pro Tips: Would you need any assistance, please contact our human user support team using the widget chat on the bottom right of the page!

Thanks,
D.

@mara24na
Copy link

mara24na commented Dec 6, 2021

Hello, thanks for the great explanation!

My data would appear in a 3x3 grid for lon and lat.
What data is included in the csv? Only the one from the "top left corner"?
Or is it interpolated?

@dbazin-eo
Copy link

dbazin-eo commented Dec 6, 2021

Hi @mara24na , thanks for your comment !

Please note that this snippet code is quite old and I would recommend to use the Copernicus Marine User Support Toolbox that has the feature to convert from NetCDF to CSV, namely .to_csv() and .to_mfcsv(), "out of the box".

You can install it via PyPI:
pip install cmemsapi

Or (most recommended) if you prefer conda :
conda create --name cmems --channel conda-forge --channel cmust python=3.8 cmemsapi --yes

You can read more and get examples in How to download a large volume (e.g. full time-series, several GigaBytes) of data in netcdf4 or csv file format?.

W/r on your question, I strongly suggest to get in touch with the User Support using the widget chat in bottom right of each Copernicus Marine webpages:

image

Wishing you good luck!

@GIS243
Copy link

GIS243 commented Nov 28, 2022

Hi @copernicusmarine

Thanks for the code is there a way to only convert the netcdf to csv for a specific region rather than the whole netcdf files please.

Thanks

@copernicusmarine
Copy link

copernicusmarine commented Nov 28, 2022

Hi @GIS243,
There are many ways to achieve what you expect!
Please contact our User Support (or via chat) with an example of marine product of your interest. They will guide you with the best scenario matching your needs (i.e. preprocessing netcdf file before downloading it).
Thanks

PS: the code presented from this page is very very old. We cannot delete it because previous gist account has been lost.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment