'Get Rasterio Transform/Affine from lat and long arrays

I have lat, long, and data arrays

data = np.array [[1,3],[2,3],[3,4]]

lat = np.array [[44,43],[46,44],[43,45]]

long = np.array [[33,32],[31,33],[36,33]] 

The coordinates here are random but my question is how to get the rasterio transform from such objects, my original image is a slanted rectangle so the rasterio.transform.from_bounds(west, south, east, north, width, height) didn't work out.

My final goal is to write the data array as a GeoTIFF.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source