Small utilities to transform netCDF files into (GeoDataFrames)
Project description
netcdf2dataframe
This repo contains a small utility used to transform netCDF files to geopandas.GeoDataFrames.
Why netcdf2dataframe?
⚠️ This project was initiated due to the need of colleagues. It's considered a work in progress !
Installation
pip install netcdf2dataframe
Basic usage
from netcdf2dataframe import netcdf2dataframe
path = "IMERG_total_precipitation_day_0.5x0.5_global_2021_v6.0.nc"
df = netcdf2dataframe(path, "pr")
Note that this module may end up crashing your machine, as DataFrames are not RAM-efficient objects (compared to the netCDF format). But sometimes, this is what you may need...
Full docstring:
netcdf2dataframe(path: str, target: str = 'pr', dropna: bool = True) -> geopandas.geodataframe.GeoDataFrame
Picks a netCDF file and extracts one variable ("target") on the form of
a GeoDataFrame.
Parameters
----------
path : str
Path to netCDF file
target : str, optional
Target variable. The default is "pr".
Note that available variables are displayed in the log (info level).
dropna : bool, optional
If True, the GeoDataFrame will not contain missing values, hence
being more frugal (less RAM consumption). The default is True.
Returns
-------
gpd.GeoDataFrame
GeoDataFrame of the extracted values
Example
-------
>>> df = netcdf2dataframe(
"IMERG_total_precipitation_day_0.5x0.5_global_2021_v6.0.nc,
"pr",
)
>>> df.head()
pr time_val geometry
0 0.000000 2021-01-01 POINT (-179.74998 -78.24999)
1 0.382080 2021-01-01 POINT (-177.24998 -78.24999)
2 1.625944 2021-01-01 POINT (-176.74998 -78.24999)
3 1.772459 2021-01-01 POINT (-176.24998 -78.24999)
4 1.412688 2021-01-01 POINT (-175.74998 -78.24999)
Support
In case of bugs, please open an issue on the repo.
Contribution
Any help is welcome.
Author
Thomas GRANDJEAN (DREAL Hauts-de-France, service Information, Développement Durable et Évaluation Environnementale, pôle Promotion de la Connaissance).
Licence
GPL-3.0-or-later
Project Status
Development.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file netcdf2dataframe-0.1.0.tar.gz.
File metadata
- Download URL: netcdf2dataframe-0.1.0.tar.gz
- Upload date:
- Size: 4.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.4 CPython/3.10.12 Linux/5.10.16.3-microsoft-standard-WSL2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e7fef17a2a78013fff90718473fa9e296d6b390b9cc54656b24a28cd10115419
|
|
| MD5 |
bdafbf312b7ba458a0754880088f2934
|
|
| BLAKE2b-256 |
adecb4e710f9fda9a47fe12029753df55530e957d9b4b410e74160ba0bc380c5
|
File details
Details for the file netcdf2dataframe-0.1.0-py3-none-any.whl.
File metadata
- Download URL: netcdf2dataframe-0.1.0-py3-none-any.whl
- Upload date:
- Size: 5.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.4 CPython/3.10.12 Linux/5.10.16.3-microsoft-standard-WSL2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c91e30aa12ceaa42944251e8554564de515e526a75ebc8c9d33c083b2309548e
|
|
| MD5 |
0efedabf3cdd253fb68566f95a837442
|
|
| BLAKE2b-256 |
808c77bd589e0ac2dbb6b49eb2690b7d1e2030a9e98aae73e69ad0fca4216ec7
|