Geology and Python

A blog stuffed with easy-to-follow Python recipes for geosciences !

Introducing Geology and Python


Python is an awesome tool for geoscientists and geophysics. Inside this programming language, there are tools to quickly load, analyse, plot and report geological data. I have been studying Python and all it's super powers for three years and I was feeling selfish to keep all the things that I have learned to myself.

People could learn from what I have learned !

With Geology and Python I hope that some readers can benefit from the snippets that I am going to share here and keep improving themselves into learning and exploring Python. There is also so much stuff that have already been done that make our lifes easier like:

  1. Manipulating arrays and scientific data. In Python, this is done by most people by using numpy and pandas. Image how much trouble early programmers had for doing things like indexing, adding and transposing arrays? numpy just gives us the power to do this and much more. It is also capable of creating N dimensions arrays, so you can, basically, have spatial data in three dimensions. Then time in a fourth dimension and any other geological properties to analyse in the fifth, sixth (and so on) dimensions.

  2. Visualization. This is where Python packages like matplotlib and mayavi shine. With matplotlib it is possible to visualize a function with one line of code and then customize it with a variety of methods and other packages. It is fully integrated with numpy and one can simply slice and quickly plot arrays. The learning curve for mayavi is a bit steep, but it is a great tool for visualizing 3D data. I will also explore tools for stereonets and ternary plots.

  3. Geographical Information Systems. There is a programmer called Sean Gillies. He is the author of the most important spatial tools that boosts most of the open source GIS systems. Use and abuse of these in Python without limits (only space and time). Some of the tools are Shapely , rasterio , Fiona and affine. They are responsible for reading, writing and manipulating rasters and vectors in Python. We will explore each of these in future posts. Other great GIS tools to be explored here are geopandas and pyproj.

  4. Remote Sensing & Geophysics. There are also tools dedicated for remote sensing and geophysics. I will be looking into these ones too, of course.

  5. Machine Learning. Python is the top programming language for Machine Learning purposes. Modules like scikit-learn and tensorflow exists to give humans the power to predict and estimate using complex algorithms. This is a big game changer in geology. With today's technology we can gather an absurd amount of data from different geological parameters and use machines to identify complex patterns or classify it for us.

Each of these tools are called Python modules (or packages) and they contain codes done by great programmers. These packages allow us to forget a little bit of the heavy computational knowledge and math behind the scenes and focus only on our task.

What about you ?

I am looking for a nice geological community that can learn from and/or contribute to all the information that I will share.

I am no computer scientist and no fluent english speaker so feel free to correct me if anything is wrong.

I am a competent geologist, but mistakes are made and you are also free to correct me.

Share on: