cebs
cebs

Reputation: 1

Interpolating Transect Data: How to Create a 1-Meter Resolution Grid?

I have topographic data from five transects, each spaced 100 meters apart, perpendicular to a beach, all stored in a single txt file. Is there a method to interpolate these data to generate a surface and create a 1-meter resolution grid with parallel transects?

I've attached an example of the data and transects, along with the code I've developed so far.

t1
806880  2.34331e+06 1.0777
806880  2.34331e+06 1.0703
...
t2
806684  2.34333e+06 0.8415
806684  2.34333e+06 0.8262
806684  2.34333e+06 0.9112
...
t3...

The measured transects are shown in yellow, while the ones I'm aiming to generate using Python are highlighted in blue

import os
import numpy as np
import matplotlib.pyplot as plt
from scipy.interpolate import griddata

dtype = np.float64
usecols = (0, 1, 2)

topo_ini = np.genfromtxt('T16toT20.txt', delimiter=' ', dtype=dtype, usecols=usecols, skip_header=2, missing_values='nan')
topo_ini = topo_ini[~np.isnan(topo_ini).any(axis=1)]

lat = topo_ini[:, 0]
lon = topo_ini[:, 1]
elev = topo_ini[:, 2]

lat_min, lat_max = min(lat), max(lat)
lon_min, lon_max = min(lon), max(lon)

n_puntos = 100
lat_grid = np.linspace(lat_min, lat_max, n_puntos)
lon_grid = np.linspace(lon_min, lon_max, n_puntos)

lon_mesh, lat_mesh = np.meshgrid(lon_grid, lat_grid)

elev_interp = griddata((topo_ini, elev, (lat_mesh,lon_mesh), method='nearest')

Insights on how to accomplish this or similar tasks across various fields would be highly valued.

Upvotes: 0

Views: 22

Answers (0)

Related Questions