Issue Opening Merged Planet Imagery

Comments

2 comments

  • Official comment
    Samapriya Roy

    Hi James,

    Since you are already using gdal_merge I wonder if it would be easier to simply split the bands in gdal as well

    an example setup to get a single band out of the mutliband image would be

    gdal_translate -b 1 "path to multiband image.tif" "path to single band b1 image.tif"

    I am not aware of the openCV way of doing that but I have seen similar questions being asked around the openCV stackoverflow forums

     

    Hope that helps.

    Sam

    Comment actions Permalink
  • James Moulton

    Sam,

     

    Your suggestion of using GDAL_Open since the data was merged with GDAL_Merge fixed my issue. I didn't need to go to the trouble of using GDAL_Translate to save each band separately. Just using GDAL_Open was enough to get all 4 bands. However, a couple issues I had to compensate for after opening the file with GDAL were:

    1. GDAL Open reads the 4-band Planet analytical data in as Red, Green, Blue, NIR. And the OpenCV routine reads it in as Blue, Green, Red, NIR. So, I had to account for this difference to ensure I was working with the correct bands.

     

    1. After reading the data in with GDAL_Open, I had to convert the data back to a Numpy array to work with all the OpenCV data calls I have in my code. OpenCV expects the data as a Numpy array whereas the GDAL opens it as a Raster array. I did this using a ReadAsNumpyArray() conversion on the input raster array.

     

    Thanks,

    James

    0
    Comment actions Permalink

Please sign in to leave a comment.