1

enter image description here

I want to generate a JPEG from a GeoTIFF file which has a stack of RGB bands. Considering the JPEG won't necessarily have any geo-referencing information about any pixels, how do I get rid of the black borders? I want the data-pixels(the colored ones here) to fit the frame as a rectangle.

I have experimented that the angle of inclination increases as we go to the polar regions from equator.

  • Rotate the canvas https://gis.stackexchange.com/questions/104143/is-it-possible-to-rotate-the-canvas-in-qgis then export the map https://docs.qgis.org/2.18/en/docs/user_manual/print_composer/create_output.html to JPEG. – Michael Stimson Jul 20 '20 at 01:47
  • That's new for me, thank you. But I wanted to do it with a Python Script, for example if I could calculate the degree of rotation with coordinates or (row/path) combination. – Shivashis Padhi Jul 20 '20 at 06:03
  • I'm sure that it would be possible, the orbit of the satellite is standard and you should be able to get that from somewhere.. NASA would be a place to start, they track lots of junk in orbit and are fairly good with open data. Intersect the orbit with your raster extent then calculate the degrees to rotate from the line. I can remember something like this coming up many years ago to auto mask the 0's around the outside without masking the valid 0's within the image area which ended up working, unfortunately it was a coworkers code so I only know a little bit about how he achieved it. – Michael Stimson Jul 20 '20 at 07:43
  • Right, I will keep searching, thank you for the input. For now, I can correct the generated 'JPEG' image with this link https://www.pyimagesearch.com/2017/02/20/text-skew-correction-opencv-python/ – Shivashis Padhi Jul 20 '20 at 14:14

1 Answers1

1

https://www.pyimagesearch.com/2017/02/20/text-skew-correction-opencv-python/

^ one can follow the same algorithm to correct geotiff image's orientation