All Projects → GeoStat-Framework → Gstools

GeoStat-Framework / Gstools

Licence: lgpl-3.0
GSTools - A geostatistical toolbox: random fields, variogram estimation, covariance models, kriging and much more

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Gstools

Pycsw
pycsw is an OGC CSW server implementation written in Python. pycsw fully implements the OpenGIS Catalogue Service Implementation Specification [Catalogue Service for the Web]. Initial development started in 2010 (more formally announced in 2011). The project is certified OGC Compliant, and is an OGC Reference Implementation. pycsw allows for the publishing and discovery of geospatial metadata via numerous APIs (CSW 2/CSW 3, OpenSearch, OAI-PMH, SRU). Existing repositories of geospatial metadata can also be exposed, providing a standards-based metadata and catalogue component of spatial data infrastructures. pycsw is Open Source, released under an MIT license, and runs on all major platforms (Windows, Linux, Mac OS X). Please read the docs at https://pycsw.org/docs for more information.
Stars: ✭ 141 (-17.54%)
Mutual labels:  geospatial
Openrailwaymap
An OpenStreetMap-based project for creating a map of the world's railway infrastructure.
Stars: ✭ 150 (-12.28%)
Mutual labels:  geospatial
Projnet4geoapi
.NET Spatial Reference and Projection Engine
Stars: ✭ 157 (-8.19%)
Mutual labels:  geospatial
Osgeo
The Open Source Geospatial Foundation is not-for-profit organization to empower everyone with open source geospatial. Directly supports projects as an outreach and advocacy organization providing financial, organizational and legal support. Works with our sponsors and partners for open software, standards, data, research and education.
Stars: ✭ 142 (-16.96%)
Mutual labels:  geospatial
H3 Java
Java bindings for H3, a hierarchical hexagonal geospatial indexing system
Stars: ✭ 150 (-12.28%)
Mutual labels:  geospatial
Awesome Biomechanics
A curated, public list collecting resources for biomechanics and human motion: datasets, processing tools, software for simulation, educational videos, lectures, etc.
Stars: ✭ 154 (-9.94%)
Mutual labels:  science
Code Is Science
Scientific code needs to be open source and peer reviewed
Stars: ✭ 133 (-22.22%)
Mutual labels:  science
Geopyspark
GeoTrellis for PySpark
Stars: ✭ 167 (-2.34%)
Mutual labels:  geospatial
Py3dtiles
⚠️ Project migrated to : https://gitlab.com/Oslandia/py3dtiles ⚠️
Stars: ✭ 152 (-11.11%)
Mutual labels:  geospatial
D3 Geo Voronoi
Voronoi / Delaunay tessellations on the sphere
Stars: ✭ 155 (-9.36%)
Mutual labels:  geospatial
Georaptor
Python Geohash Compression Tool
Stars: ✭ 143 (-16.37%)
Mutual labels:  geospatial
Rioxarray
geospatial xarray extension powered by rasterio
Stars: ✭ 148 (-13.45%)
Mutual labels:  geospatial
Geodb
A Persistent Geospatial Database with Geofencing & Google Maps Support
Stars: ✭ 155 (-9.36%)
Mutual labels:  geospatial
Design Of Experiment Python
Design-of-experiment (DOE) generator for science, engineering, and statistics
Stars: ✭ 143 (-16.37%)
Mutual labels:  science
Mapfish Print
A component of MapFish for printing templated cartographic maps. This module is the Java serverside module. For support post to the mailing list: https://groups.google.com/forum/#!forum/mapfish-print-users
Stars: ✭ 159 (-7.02%)
Mutual labels:  geospatial
Lab.js
Online research made easy
Stars: ✭ 140 (-18.13%)
Mutual labels:  science
Python Quickui
Scientific One-Liner Interactive GUI Library
Stars: ✭ 153 (-10.53%)
Mutual labels:  science
Awesome Python Applications
💿 Free software that works great, and also happens to be open-source Python.
Stars: ✭ 13,275 (+7663.16%)
Mutual labels:  science
Code4java
Repository for my java projects.
Stars: ✭ 164 (-4.09%)
Mutual labels:  geospatial
Tidyversity
🎓 Tidy tools for academics
Stars: ✭ 155 (-9.36%)
Mutual labels:  science

Welcome to GSTools

DOI PyPI version Conda Version Build Status Coverage Status Documentation Status Code style: black

GSTools-LOGO

Purpose

GeoStatTools provides geostatistical tools for various purposes:

  • random field generation
  • simple, ordinary, universal and external drift kriging
  • conditioned field generation
  • incompressible random vector field generation
  • (automatted) variogram estimation and fitting
  • directional variogram estimation and modelling
  • data normalization and transformation
  • many readily provided and even user-defined covariance models
  • metric spatio-temporal modelling
  • plotting and exporting routines

Installation

conda

GSTools can be installed via conda on Linux, Mac, and Windows. Install the package by typing the following command in a command terminal:

conda install gstools

In case conda forge is not set up for your system yet, see the easy to follow instructions on conda forge. Using conda, the parallelized version of GSTools should be installed.

pip

GSTools can be installed via pip on Linux, Mac, and Windows. On Windows you can install WinPython to get Python and pip running. Install the package by typing the following command in a command terminal:

pip install gstools

To install the latest development version via pip, see the documentation.

Citation

At the moment you can cite the Zenodo code publication of GSTools:

Sebastian Müller & Lennart Schüler. GeoStat-Framework/GSTools. Zenodo. https://doi.org/10.5281/zenodo.1313628

If you want to cite a specific version, have a look at the Zenodo site.

A publication for the GeoStat-Framework is in preperation.

Documentation for GSTools

You can find the documentation under geostat-framework.readthedocs.io.

Tutorials and Examples

The documentation also includes some tutorials, showing the most important use cases of GSTools, which are

The associated python scripts are provided in the examples folder.

Spatial Random Field Generation

The core of this library is the generation of spatial random fields. These fields are generated using the randomisation method, described by Heße et al. 2014.

Examples

Gaussian Covariance Model

This is an example of how to generate a 2 dimensional spatial random field with a gaussian covariance model.

import gstools as gs
# structured field with a size 100x100 and a grid-size of 1x1
x = y = range(100)
model = gs.Gaussian(dim=2, var=1, len_scale=10)
srf = gs.SRF(model)
srf((x, y), mesh_type='structured')
srf.plot()

Random field

GSTools also provides support for geographic coordinates. This works perfectly well with cartopy.

import matplotlib.pyplot as plt
import cartopy.crs as ccrs
import gstools as gs
# define a structured field by latitude and longitude
lat = lon = range(-80, 81)
model = gs.Gaussian(latlon=True, len_scale=777, rescale=gs.EARTH_RADIUS)
srf = gs.SRF(model, seed=12345)
field = srf.structured((lat, lon))
# Orthographic plotting with cartopy
ax = plt.subplot(projection=ccrs.Orthographic(-45, 45))
cont = ax.contourf(lon, lat, field, transform=ccrs.PlateCarree())
ax.coastlines()
ax.set_global()
plt.colorbar(cont)

lat-lon random field

A similar example but for a three dimensional field is exported to a VTK file, which can be visualized with ParaView or PyVista in Python:

import gstools as gs
# structured field with a size 100x100x100 and a grid-size of 1x1x1
x = y = z = range(100)
model = gs.Gaussian(dim=3, len_scale=[16, 8, 4], angles=(0.8, 0.4, 0.2))
srf = gs.SRF(model)
srf((x, y, z), mesh_type='structured')
srf.vtk_export('3d_field') # Save to a VTK file for ParaView

mesh = srf.to_pyvista() # Create a PyVista mesh for plotting in Python
mesh.contour(isosurfaces=8).plot()

3d Random field

Estimating and Fitting Variograms

The spatial structure of a field can be analyzed with the variogram, which contains the same information as the covariance function.

All covariance models can be used to fit given variogram data by a simple interface.

Example

This is an example of how to estimate the variogram of a 2 dimensional unstructured field and estimate the parameters of the covariance model again.

import numpy as np
import gstools as gs
# generate a synthetic field with an exponential model
x = np.random.RandomState(19970221).rand(1000) * 100.
y = np.random.RandomState(20011012).rand(1000) * 100.
model = gs.Exponential(dim=2, var=2, len_scale=8)
srf = gs.SRF(model, mean=0, seed=19970221)
field = srf((x, y))
# estimate the variogram of the field
bin_center, gamma = gs.vario_estimate((x, y), field)
# fit the variogram with a stable model. (no nugget fitted)
fit_model = gs.Stable(dim=2)
fit_model.fit_variogram(bin_center, gamma, nugget=False)
# output
ax = fit_model.plot(x_max=max(bin_center))
ax.scatter(bin_center, gamma)
print(fit_model)

Which gives:

Stable(dim=2, var=1.85, len_scale=7.42, nugget=0.0, anis=[1.0], angles=[0.0], alpha=1.09)

Variogram

Kriging and Conditioned Random Fields

An important part of geostatistics is Kriging and conditioning spatial random fields to measurements. With conditioned random fields, an ensemble of field realizations with their variability depending on the proximity of the measurements can be generated.

Example

For better visualization, we will condition a 1d field to a few "measurements", generate 100 realizations and plot them:

import numpy as np
import matplotlib.pyplot as plt
import gstools as gs

# conditions
cond_pos = [0.3, 1.9, 1.1, 3.3, 4.7]
cond_val = [0.47, 0.56, 0.74, 1.47, 1.74]

gridx = np.linspace(0.0, 15.0, 151)

# conditioned spatial random field class
model = gs.Gaussian(dim=1, var=0.5, len_scale=2)
krige = gs.krige.Ordinary(model, cond_pos, cond_val)
cond_srf = gs.CondSRF(krige)

# generate the ensemble of field realizations
fields = []
for i in range(100):
    fields.append(cond_srf(gridx, seed=i))
    plt.plot(gridx, fields[i], color="k", alpha=0.1)
plt.scatter(cond_pos, cond_val, color="k")
plt.show()

Conditioned

User Defined Covariance Models

One of the core-features of GSTools is the powerful CovModel class, which allows to easy define covariance models by the user.

Example

Here we re-implement the Gaussian covariance model by defining just a correlation function, which takes a non-dimensional distance h = r/l:

import numpy as np
import gstools as gs
# use CovModel as the base-class
class Gau(gs.CovModel):
    def cor(self, h):
        return np.exp(-h**2)

And that's it! With Gau you now have a fully working covariance model, which you could use for field generation or variogram fitting as shown above.

Have a look at the documentation for further information on incorporating optional parameters and optimizations.

Incompressible Vector Field Generation

Using the original Kraichnan method, incompressible random spatial vector fields can be generated.

Example

import numpy as np
import gstools as gs
x = np.arange(100)
y = np.arange(100)
model = gs.Gaussian(dim=2, var=1, len_scale=10)
srf = gs.SRF(model, generator='VectorField', seed=19841203)
srf((x, y), mesh_type='structured')
srf.plot()

yielding

vector field

VTK/PyVista Export

After you have created a field, you may want to save it to file, so we provide a handy VTK export routine using the .vtk_export() or you could create a VTK/PyVista dataset for use in Python with to .to_pyvista() method:

import gstools as gs
x = y = range(100)
model = gs.Gaussian(dim=2, var=1, len_scale=10)
srf = gs.SRF(model)
srf((x, y), mesh_type='structured')
srf.vtk_export("field") # Saves to a VTK file
mesh = srf.to_pyvista() # Create a VTK/PyVista dataset in memory
mesh.plot()

Which gives a RectilinearGrid VTK file field.vtr or creates a PyVista mesh in memory for immediate 3D plotting in Python.

pyvista export

Requirements:

Optional

Contact

You can contact us via [email protected].

License

LGPLv3 © 2018-2021

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].