Spatial Interpolation

GeoSense ✅
Geoinfomatics
Published in
6 min readAug 31, 2024

--

Implement spatial interpolation using Python exclusively, without relying on ArcGIS software.

  • Perform multiple interpolation techniques on a set of data points
  • Extract interpolated values at designated locations without original samples

Interpolation is a technique for estimating values at unsampled locations by utilizing data from known, sampled points within a given area or phenomenon. This chapter will delve into three distinct interpolation approaches:

  1. Thiessen polygons, also known as Voronoi diagrams
  2. K-nearest neighbors (KNN)
  3. Kriging

Load libraries

# Import modules
import geopandas as gpd
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
from pykrige.ok import OrdinaryKriging
import rasterio
import rasterio.mask
from rasterio.plot import show
from rasterio.transform import Affine
from scipy.spatial import Voronoi, voronoi_plot_2d
from shapely.geometry import box
from shapely.geometry import Polygon, Point
from sklearn.gaussian_process import GaussianProcessRegressor
from sklearn.metrics import r2_score
from sklearn.model_selection import train_test_split
from sklearn.neighbors import KNeighborsRegressor
# Load data
# County boundaries

counties = gpd.read_file("sf_bay_counties/sf_bay_counties.shp")

# Rainfall measurement "locations"
# Modified by author by clipping raster to San Francisco Bay Area, generating random points, and extracting…

--

--

GeoSense ✅
Geoinfomatics

🌏 Remote sensing | 🛰️ Geographic Information Systems (GIS) | ℹ️ https://www.tnmthai.com/medium