45 Opening ESRI ASC Grids and ZMAP Grids#

GemGIS can also read ArcGIS ASC files and ZMAP Grids. The data examples shown below were obtained from https://www.nlog.nl/en/scan-2d-seismic-interpretation-and-depth-conversion-dinantian.

6ea5a990efec4c638a1aebde725ad696

ESRI Grids Reference: https://desktop.arcgis.com/en/arcmap/10.3/manage-data/raster-and-images/esri-grid-format.htm

Set File Paths and download Tutorial Data#

If you downloaded the latest GemGIS version from the Github repository, append the path so that the package can be imported successfully. Otherwise, it is recommended to install GemGIS via pip install gemgis and import GemGIS using import gemgis as gg. In addition, the file path to the folder where the data is being stored is set. The tutorial data is downloaded using Pooch (https://www.fatiando.org/pooch/latest/index.html) and stored in the specified folder. Use pip install pooch if Pooch is not installed on your system yet.

[1]:
import gemgis as gg

file_path ='data/45_opening_asc_and_zmap_grids/'
WARNING (theano.configdefaults): g++ not available, if using conda: `conda install m2w64-toolchain`
C:\Users\ale93371\Anaconda3\envs\test_gempy\lib\site-packages\theano\configdefaults.py:560: UserWarning: DeprecationWarning: there is no c++ compiler.This is deprecated and with Theano 0.11 a c++ compiler will be mandatory
  warnings.warn("DeprecationWarning: there is no c++ compiler."
WARNING (theano.configdefaults): g++ not detected ! Theano will be unable to execute optimized C-implementations (for both CPU and GPU) and will default to Python implementations. Performance will be severely degraded. To remove this warning, set Theano flags cxx to an empty string.
WARNING (theano.tensor.blas): Using NumPy C-API based implementation for BLAS functions.
[2]:
gg.download_gemgis_data.download_tutorial_data(filename="45_opening_asc_and_zmap_grids.zip", dirpath=file_path)
Downloading file '45_opening_asc_and_zmap_grids.zip' from 'https://rwth-aachen.sciebo.de/s/AfXRsZywYDbUF34/download?path=%2F45_opening_asc_and_zmap_grids.zip' to 'C:\Users\ale93371\Documents\gemgis\docs\getting_started\tutorial\data\45_opening_asc_and_zmap_grids'.

Loading the ASC Grid#

When loading the ASC Grid, it will be returned as dict containing the array data, the extent, resolution and nodata_val. A CRS is not provided for the grid. The retrieved data can now be used and saved as tif using save_as_tif(..) or it can be visualized in PyVista as shown below.

[2]:
data = gg.raster.read_asc(path= file_path + 'top_dinant_final_tvd.asc')
data
WARNING (theano.configdefaults): g++ not available, if using conda: `conda install m2w64-toolchain`
C:\Users\ale93371\Anaconda3\envs\test_gempy\lib\site-packages\theano\configdefaults.py:560: UserWarning: DeprecationWarning: there is no c++ compiler.This is deprecated and with Theano 0.11 a c++ compiler will be mandatory
  warnings.warn("DeprecationWarning: there is no c++ compiler."
WARNING (theano.configdefaults): g++ not detected ! Theano will be unable to execute optimized C-implementations (for both CPU and GPU) and will default to Python implementations. Performance will be severely degraded. To remove this warning, set Theano flags cxx to an empty string.
WARNING (theano.tensor.blas): Using NumPy C-API based implementation for BLAS functions.
[2]:
{'Data': array([[nan, nan, nan, ..., nan, nan, nan],
        [nan, nan, nan, ..., nan, nan, nan],
        [nan, nan, nan, ..., nan, nan, nan],
        ...,
        [nan, nan, nan, ..., nan, nan, nan],
        [nan, nan, nan, ..., nan, nan, nan],
        [nan, nan, nan, ..., nan, nan, nan]]),
 'Extent': [-42250.0, 279000.0, 306000.0, 867000.0],
 'Resolution': 250.0,
 'Nodata_val': nan}
[3]:
data['Data']
[3]:
array([[nan, nan, nan, ..., nan, nan, nan],
       [nan, nan, nan, ..., nan, nan, nan],
       [nan, nan, nan, ..., nan, nan, nan],
       ...,
       [nan, nan, nan, ..., nan, nan, nan],
       [nan, nan, nan, ..., nan, nan, nan],
       [nan, nan, nan, ..., nan, nan, nan]])

The extent is defined as xmin, xmax, ymin, ymax.

[4]:
data['Extent']
[4]:
[-42250.0, 279000.0, 306000.0, 867000.0]
[5]:
data['Resolution']
[5]:
250.0
[6]:
data['Nodata_val']
[6]:
nan
[7]:
import numpy as np
data['Data'][data['Data'] == data['Nodata_val']] = 500
data['Data']
[7]:
array([[nan, nan, nan, ..., nan, nan, nan],
       [nan, nan, nan, ..., nan, nan, nan],
       [nan, nan, nan, ..., nan, nan, nan],
       ...,
       [nan, nan, nan, ..., nan, nan, nan],
       [nan, nan, nan, ..., nan, nan, nan],
       [nan, nan, nan, ..., nan, nan, nan]])
[8]:
data['Nodata_val'] = 500

Visualization in PyVista#

The data can be visualized using a Structured Grid. Therefore, the function create_structured_grid_from_asc(...) can be used.

[9]:
grid = gg.visualization.create_structured_grid_from_asc(data=data)
grid
[9]:
HeaderData Arrays
StructuredGridInformation
N Cells2880012
N Points2883540
X Bounds-4.225e+04, 2.788e+05
Y Bounds3.060e+05, 8.668e+05
Z Bounds-1.132e+04, 2.887e+02
Dimensions2244, 1285, 1
N Arrays1
NameFieldTypeN CompMinMax
Depth [m]Pointsfloat641-1.132e+042.887e+02
[10]:
grid.save(file_path + 'top_dinant_final_tvd.vtk')

Creating Contour Lines#

import numpy as np contours = grid.contour(isosurfaces=np.arange(-11000, 0, 250)) contourscontours.save(file_path+'top_dinant_final_tvd_contours.vtk')
[11]:
import pyvista as pv
contours = pv.read(file_path+'top_dinant_final_tvd_contours.vtk')
contours_shape = gg.vector.create_linestrings_from_contours(contours=contours, crs='EPSG:28992') contours_shape.head()contours_shape.to_file(file_path+'top_dinant_final_tvd_contours.shp')import geopandas as gpd contours_shape = gpd.read_file(filename=file_path+'top_dinant_final_tvd_contours.shp') contours_shape.head()
[12]:
sargs = dict(fmt="%.0f", color='black')

p = pv.Plotter(notebook=True)

p.add_mesh(grid, scalars='Depth [m]', nan_opacity=0, scalar_bar_args=sargs)

p.show_grid(color='black')
p.set_background(color='white')
p.show()
../../_images/getting_started_tutorial_45_opening_asc_and_zmap_grids_23_0.png

Loading the ZMAP Grid#

The same dataset as before is also provided as ZMAP Grid.

[13]:
data = gg.raster.read_zmap(file_path + 'top_dinant_final_tvd.dat')
data
[13]:
{'Data': array([[nan, nan, nan, ..., nan, nan, nan],
        [nan, nan, nan, ..., nan, nan, nan],
        [nan, nan, nan, ..., nan, nan, nan],
        ...,
        [nan, nan, nan, ..., nan, nan, nan],
        [nan, nan, nan, ..., nan, nan, nan],
        [nan, nan, nan, ..., nan, nan, nan]]),
 'Extent': [-42250.0, 278750.0, 306000.0, 866750.0],
 'Resolution': [250.0, 250.0],
 'Nodata_val': 1e+30,
 'Dimensions': (2244, 1285),
 'CRS': 'Amersfoort * EPSG-Nld / RD New [28992,1672]',
 'Creation_date': '21/10/2019',
 'Creation_time': '16',
 'File_name': 'TOP_DINANTIAN_TVD_final'}
[14]:
grid = gg.visualization.create_structured_grid_from_zmap(data=data)
grid
[14]:
HeaderData Arrays
StructuredGridInformation
N Cells2880012
N Points2883540
X Bounds-4.225e+04, 2.788e+05
Y Bounds3.060e+05, 8.668e+05
Z Bounds-1.132e+04, 2.887e+02
Dimensions2244, 1285, 1
N Arrays1
NameFieldTypeN CompMinMax
Depth [m]Pointsfloat641-1.132e+042.887e+02
[15]:
import pyvista as pv
sargs = dict(fmt="%.0f", color='black')

p = pv.Plotter(notebook=True)

p.add_mesh(grid, scalars='Depth [m]', nan_opacity=0, scalar_bar_args=sargs)

p.show_grid(color='black')
p.set_background(color='white')
p.show()
../../_images/getting_started_tutorial_45_opening_asc_and_zmap_grids_27_0.png
[ ]: