Given a simple jpg of an oblique aerial photography, the geometry and a CRS I am trying to determine its affine transform so I can convert it into a GeoTIFF.

import rasterio, rasterio.crs

raster = rasterio.open('oblique.jpg') as src:
raster.crs = rasterio.crs.CRS({'init': 'epsg:25832'})
geom = {
    'geometry': {
        'type': 'Polygon',
        'coordinates': [[(723104.0, 6181270.0), (723113.0, 6180450.0), (721842.0, 6180440.0), (721833.0, 6181250.0), (723104.0, 6181270.0)]]

I am unsure how to proceed for here I think that this is wrong but including it so you may see the attempt

import rasterio.transform, shapely.geometry

left, bottom, right, top = shapely.geometry.shape(geom['geometry']).bounds
transform = rasterio.transform.from_bounds(left, bottom, right, top, raster.width, raster.height)

I notice that there are zeros so this transform is not accounting for the oblique angle.

>>> transform
Affine(0.09502598366740905, 0.0, 721833.0,
       0.0, -0.09573241061130335, 6181270.0)

What am I doing wrong? Besides the raster, geom, crs I also have following fields given but unsure what they code for: easting, northing, height, omega, phi, kappa, direction, estacc, height_eli, references, level, comment_co, comment_gs, gsd, hist_low, hist_high, drive, SunAngle

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.