I am trying to understand how to properly set up an affine transformation using Rasterio. I have read through guides online and I have used the format provided but for some reason, it does not seem to be working with my data.
Here is an example of the affine transformation
transform = rasterio.Affine(0.016540527, 0, -134.49954, 0, -0.007511139, 69.13232)
My understanding is that when using this transformation the origin (0,0) should be the lower left corner of the raster (that is what I am expecting). However, when I test it using the following code
x, y = transform * (0, 0)
The origin ends up being (-134.49954, 69.13232) - the top left corner of the raster. Therefore when saving the image using this transformation it ends up being inverted. The south side of the raster is the top and the north side of the raster is the bottom.
The code I am using to save the raster is this
with rasterio.open(
raster_outname,
'w',
driver='GTiff',
height=raster.shape[0],
width=raster.shape[1],
count=1,
dtype=data.dtype,
crs=crs,
transform=transform,
) as tif_dataset:
tif_dataset.write(data, 1)
Could there be an issue with the data itself? Possibly with the way it is being saved as a GeoTiff?
numpy.flipud