FESOM / pyfesom

python library and tools for pre and post processing of the FESOM ocean model files
http://pyfesom.readthedocs.io/en/latest/index.html
MIT License
11 stars 6 forks source link

Add function to convert a FESOM mesh to a gdal dataset (e.g. shapefile) #7

Closed strawpants closed 5 years ago

strawpants commented 5 years ago

Dear Nikolay, I'm working with @stolzenbergers using the FESOM model, and we want to convert the FESOM mesh to something we can put in a shapefile ( or better a PostGIS enabled database). Once that is done, we can do for example spatial queries against other geospatial datasets (argo, along track altimetry etc) and obtain a list of nodeids so we can extract the relevant data from the FESOM dataruns.

I've now created a python function which does this conversion, and you're of course welcome to add this to the toolbox if you feel this is useful. Note that I didn't add the pythonfile entry into the __init__.py because it introduces a dependency on python GDAL, so I don't know if you want to have this imported per default.

The basic workflow for a conversion would be something like:

import pyfesom as pf
from pyfesom.fesom2gdal import fesom2gdal
meshpath  ='mesh24km'
mesh = pf.fesom_mesh(meshpath)
outdset='FESOM24kmGIS.gpkg'
fesom2gdal(mesh,outdset)

You can see here a screenshot from the resulting geopackage as plotted in Qgis: FESOMscreenshot

The first commit is a simple setup.py file for easier installing but I just saw this was also discussed in the recent pull request for making the toolbox pipable, so you may consider ignoring that.

All the best and keep up the good work,

Roelof

koldunovn commented 5 years ago

Dear Roelof,

Thanks a lot for the PR, I will only have a chance to look at it on Wednesday. I just wanted to say how cool that is and let you know that If you have some tutorial examples on how to use FESOM data with GIS software I will be happy to share them either on FESOM youtube channel or on fesom.de.

strawpants commented 5 years ago

Great, once we have a nice working example we might provide you with a jupyter notebook or something similar.

koldunovn commented 5 years ago

I merged two setup.py from you and Paul. Not having the fesom2gdal in __init__.py is a good one - GDAL and friends are not always the easiest dependency :)

Thanks a lot for the PR!

strawpants commented 5 years ago

You're welcome, thanks for maintaining pyfesom