Pre-chipped datasets: How to convert geotiff chips from 32 to 8 bits per band #1781
-
Hi there! I have a pre-chipped dataset (RGB images and their masks) to import via The problem is that these chips are 32 bit multiband geotiff files, so they can't be read -a maximum of 8 bits per channel is currently supported. Do you have any recipes to batch convert these chips to 8 bits per band, so they can be used with Rastervision ? Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
Hmm, I'm not sure if this is the case. What error are you running into? |
Beta Was this translation helpful? Give feedback.
-
Hi @AdeelH ! Thanks for looking into this. So, I setup my pre-chipped dataset like this:
No problem there. Then when I try to read any of the images...
I get this kind of error:
That error seems to come from this operation:
According to this, that error is to be expected because the Python Imaging Library is only able to open 8 bit per channel in multi-channel images. Mine are 32 bit per channel so I need to convert them, and making sure that the output is compatible with the RV pipeline. I've seen -and tried- a few recipes online, but my results so far don't look like usable RGB files. So, I wonder if you have solved something like this before :) |
Beta Was this translation helpful? Give feedback.
Oh, I was not aware of that limitation of PIL. I suppose we should use rasterio if the file is a TIFF.
You could try modifying the source to do that as a workaround if that's convenient for you. (A PR would be welcome as well!)
Another option would be to convert them to numpy arrays. You could write a simple script that reads in each image and saves it in the numpy file format.