AgentSkillsCN

gemgis

利用GemPy进行地质建模的空间数据处理。当Claude需要执行以下操作时使用:(1) 为GemPy模型准备空间数据;(2) 从地质图中提取界面点;(3) 处理产状与倾角测量数据;(4) 沿剖面或横断面采样数字高程模型(DEM);(5) 在GIS格式与GemPy输入之间进行转换;(6) 为建模裁剪或变换矢量/栅格数据;(7) 根据地理空间范围划定模型边界。

SKILL.md
--- frontmatter
name: gemgis
description: |
  Spatial data processing for geological modelling with GemPy. Use when Claude
  needs to: (1) Prepare spatial data for GemPy models, (2) Extract interface
  points from geological maps, (3) Process orientations/dip measurements,
  (4) Sample DEMs along profiles or cross-sections, (5) Convert between GIS
  formats and GemPy inputs, (6) Clip/transform vector/raster data for modeling,
  (7) Create model extents from geospatial bounds.

GemGIS - Geospatial Data for Geological Modelling

Quick Reference

python
import gemgis as gg
import geopandas as gpd

# Load vector data
gdf = gpd.read_file('geology.shp')

# Extract XYZ from geometry with elevation from DEM
interfaces = gg.vector.extract_xyz(gdf=gdf, dem='dem.tif')

# Define model extent
extent = [x_min, x_max, y_min, y_max]

# Clip to extent
gdf_clipped = gg.vector.clip_by_extent(gdf=gdf, extent=extent)

Key Modules

ModulePurpose
gemgis.vectorVector data processing, XYZ extraction
gemgis.rasterRaster/DEM processing, sampling, interpolation
gemgis.utilsUtility functions, extent management
gemgis.postprocessingModel postprocessing

Essential Operations

Extract Interface Points

python
contacts = gpd.read_file('contacts.shp')
interfaces = gg.vector.extract_xyz(gdf=contacts, dem='dem.tif')
interfaces['formation'] = contacts['formation']
# Returns DataFrame with X, Y, Z, formation columns

Extract Orientations

python
measurements = gpd.read_file('structural_measurements.shp')
orientations = gg.vector.extract_xyz(gdf=measurements, dem='dem.tif')
orientations['dip'] = measurements['dip']
orientations['azimuth'] = measurements['strike'] + 90  # strike to dip direction
orientations['formation'] = measurements['formation']

Sample DEM Along Profile

python
profile = gg.raster.sample_from_raster(
    raster='dem.tif',
    line=[(500000, 5600000), (510000, 5605000)],
    n_samples=100
)
# Returns dict with 'distance' and 'Z' arrays

Define Model Extent

python
# From coordinates
extent = gg.utils.set_extent(
    x_min=500000, x_max=510000,
    y_min=5600000, y_max=5610000
)

# From GeoDataFrame bounds
extent = gg.utils.set_extent_from_bounds(gdf)

Clip Data to Extent

python
from shapely.geometry import box
extent_poly = box(500000, 5600000, 510000, 5610000)
gdf_clipped = gdf.clip(extent_poly)

# Or using gemgis
gdf_clipped = gg.vector.clip_by_extent(
    gdf=gdf,
    extent=[500000, 510000, 5600000, 5610000]
)

CRS Conversion

python
# Always work in projected CRS (meters) for modeling
gdf_utm = gdf.to_crs('EPSG:32632')  # UTM zone 32N

# Or use GemGIS utility
gdf_utm = gg.vector.reproject(gdf, 'EPSG:32632')

Supported Formats

FormatExtensionReadWrite
Shapefile.shpYesYes
GeoJSON.geojsonYesYes
GeoPackage.gpkgYesYes
GeoTIFF.tifYesYes
ASCII Grid.ascYesYes

Common CRS

EPSGDescription
4326WGS84 (lat/lon)
32632UTM Zone 32N
32633UTM Zone 33N

Tips

  1. Always check CRS - All data must be in the same coordinate system
  2. Use UTM for modelling - Meters are easier than degrees
  3. Assign Z from DEM - Ensures consistent elevations across datasets
  4. Validate geometry - Fix invalid geometries before processing
  5. Buffer extent slightly - Avoid edge effects in interpolation

References

Scripts