I have image as numpy array with no projection or geographical data and I have information of the bouding box of this numpy array (the image suppose to match perfectly the bbox). The bbox is sentinelhub.geometry.BBox type.

I have the following informtion about the bbox:

>>>(850, 1279) #it has 1279 rows and 850 columns, not to be confused

>>>[-56.413932589, -12.93287647, -56.335907465, -12.81704823]  #lower left, upper right

The problem is that whenever I'm trying to save my numpy array, I believe there is problem with the transform as I get it very disorted. I'm using the following for the transform:

transform=rasterio.transform.from_bounds(*bbox, width= bbox_size[1], height= bbox_size[0])
>>>Affine(6.1004788115715275e-05, 0.0, -56.413932589,
       0.0, -0.00013626851764705978, -12.81704823)

and the result look like this : (the red crosses are where there real lower left and upper right suppose to be:
enter image description here

Why is this happens? I believe there is something very basic that i'm missing here

  • 1
    If this is related to your previous question, then I think you're over complicating things and you can just re-use the georeferencing from your original raster (there are methods to do so even if you've clipped or resampled).
    – user2856
    Apr 5, 2021 at 21:21

1 Answer 1


You confused the height & width parameters and are passing them reversed. You use columns=height and rows=width when you should be using columns=width and rows=height. Change your code to:

transform=rasterio.transform.from_bounds(*bbox, width=bbox_size[0], height= bbox_size[1])
  • you are right. I thought it is different as seems like rows and columns are columns and then rows in sentinelhub but you are right
    – Reut
    Apr 6, 2021 at 5:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.