Warping (reprojection) of SAR Imagery in Swath Geometry
pyswarp is a lightweight Python package for efficient warping (reprojection) of SAR imagery in swath geometry
Installation
pip install pyswarp
Or install runtime dependencies directly:
pip install -r requirements.txt
Quick start
from pyswarp import SwathGeometry, RegularGeometry, Warper
from osgeo import gdal
from pyproj import Proj
# Read the first SAR image with GDAL
# The image must have ground control points (GCPs)
ds0 = gdal.Open(tiff_file0)
geo0 = SwathGeometry.from_gdal_dataset(ds0)
img0 = ds0.ReadAsArray()
# Read the second SAR image with GDAL
# The image must have ground control points (GCPs)
ds1 = gdal.Open(tiff_file1)
geo1 = SwathGeometry.from_gdal_dataset(ds1)
img1 = ds1.ReadAsArray()
# Warp img0 on img1
warper_0_1 = Warper(geo0, geo1)
img0_warped_on_img1 = warper_0_1(img0)
# Define regular geometry
proj4str = '+proj=stere +lat_0=90 +lat_ts=70 +lon_0=-45 +x_0=0 +y_0=0 +a=6378273 +b=6356889.449 +units=m +no_defs'
geo2 = RegularGeometry(Proj(proj4str), xmin, xmax, ymin, ymax, (x_res, y_res))
# Warp img0 on regular geometry
warper_0_2 = Warper(geo0, geo2)
img0_warped_on_img2 = warper_0_2(img0)
# Warp data from regular grid to img0
regular_data = READ_YOUR_DATA()
warper_2_0 = Warper(geo2, geo0)
reg_data_warped_on_img0 = warper_2_0(img0)
# Create SwathGeometry without GDAL
# 1. Read full resolution longitude and latitude
lon_grid = READ_LONGITUDE_GRID()
lat_grid = READ_LATITUDE_GRID()
# Subset full-res grids
col_grid_sub, row_grid_sub = np.meshgrid(
np.linspace(0, lon_grid.shape[1] - 1, 100),
np.linspace(0, lon_grid.shape[0] - 1, 100),
)
lon_grid_sub = lon_grid[row_grid_sub, col_grid_sub]
lat_grid_sub = lat_grid[row_grid_sub, col_grid_sub]
geo3 = SwathGeometry(
crs = Proj('+proj=longlat'),
x = lon_grid_sub,
y = lat_grid_sub,
col = col_grid_sub,
row = row_grid_sub,
width = lon_grid.shape[1],
height = lon_grid.shape[0]
)
# Use geo3 in Warper similar to geo0, geo1, etc.
Citation
Korosov A., and Telegina A., Efficient algorithm fow warping SAR imagery with motion compensation, https://github.com/nansencenter/sar_image_warping
Coming soon
Sea ice drift compensation
Metadata
Release files for pyswarp 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pyswarp-0.1.0.tar.gz | 5.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pyswarp-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 11.3 kB
Release files / pyswarp-0.1.0.tar.gz
| Download URL | pyswarp-0.1.0.tar.gz |
|---|---|
| Size | 5.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4636a1ba170331c4205593945d099e5fbaa9698208f5b30b57bec236ab1ace00
|
|
BLAKE2b-256 checksum How to use checksums |
2009a677eda6405a85b0e65e886c933194a64b916bf6132ab6c2cb3af3100b5b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.2
|
Release files / pyswarp-0.1.0-py3-none-any.whl
| Download URL | pyswarp-0.1.0-py3-none-any.whl |
|---|---|
| Size | 5.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d5185148ee7caa900afcc79082d1bc09355ea2f893e1cbff054eb58573a92b4d
|
|
BLAKE2b-256 checksum How to use checksums |
3e7faa628f2c2fda52e57d99b876a8921104d176ab32ffab5d4d2dc42a12a4f3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.2
|