These past few weeks I have been taking the most out of one of my favorite software libraries for data analysis: Matplotlib. This powefull open-source software library from python-based ecosystem, along with others like Numpy, Scipy, IPython, Pandas, Sympy, etc., is a core package in The Scipy Stack, the Scientific Computing Tools for Python (http://www.scipy.org/).
Although I have been working with Matplotlib for several years, a thorough study of its core has allowed me to slowly get to know their true potential.
Like a geographer, it couldn’t be otherwise Matplotlib toolkit most often used by me is Basemap, which I spent many hours plotting results before include them in a Geographic Information System (GIS). It is noteworthy the strength of Basemap is underpinned by two top quality libraries: PROJ4 and GEOS.
Even though Basemap runs inside Matplotlib, it is a solely library developed by Jeffrey S. Whitaker, a meteorologist from Earth System Research Laboratory – National Oceanic and Atmospheric Administration (NOAA).
It’s a fairy one to remember the importance of Jeffrey S. Whitaker in geoscientific computing world because he has given several very valuable tools to community, like Python binding to Unidata NetCDF C Library or Python bindings to main GRIB file decoders (NOAA and ECMWF).
You can find an example of my last works with Basemap in a tiny library I have developed around it, and I have called daynight2geojson. The aim of this little application is to get worldwide spatial distribution of night at specified date (must be UTC).
If it is not specified a date, this library computes night cover at current date (UTC, of course). When it has been retrieved all data, these are processed and stored in a GeoJSON file. This file could be load in any client capable to read this very simple format (currently most clients can handle this file format without any problem).
All processing are done with the help of Python GeoJSON library and Shapely, a Python library for manipulation and analysis of geometric objects in the Cartesian plane (this library works over GEOS). Output layer Coordinate Reference System (CRS) is EPSG:4326.
For people who want to delve into the subject, all the mathematical background on which is builded the computation of worldwide night geometry are in Basemap solar module: GHA (Greenwich hour angle) computation, solar declination, etc.
Below are displayed some examples of calculations using the library daynight2geojson at different dates:
- Computations for January 15, 2015 at 12:00 UTC.
- Computations for January 15, 2015 at 18:00 UTC. (same day at different time).
You can get the source on Github: https://github.com/GeographicaGS/daynight2geojson
Do you have an idea, comment or issue? You can contribute forking the project or opening an issue. You will be welcome.
See you soon!