Skip to main content

I used python rioxarray_open.rasterio to load the Sentinel2 pixels values and plot the results in QGIS.


pixel_value = rioxarray.open_rasterio("root/32DPD_20220101T102431_B04.jp2")
pixel_value = pixel_value.squeeze()
gdf_pixel_value = pixel_value.to_dataframe().reset_index()

For testing, I just load a sub-region of the band - 100*100pixels. The result I got was promising, with 10,000 values (digital numbers). But after I plot it in QGIS, it is strange. Different values should have different grayscales/colors, but you could see that every four neighbor pixels are exactly the same color.


I changed the symbology with “unique value” to better distinguish the grayscales. Now you can clearly see that four different pixels share the same color:


Why would this happen? Many thanks in advance!


See below:


Hi,

Please beware that I cannot say much about how rioxarray_open.rasterio reads jp2 files, but one thing that strikes me as a possible cause of error is the measure: B04 (red band) is provided at 10m resolution, while in your case it seems the values were read at 20m.

You can use EOBrowser to check that the values you get with Sentinel-2 are different at 10m scale (for 10m bands, of course).

Sentinel Hub QGIS plugin shows differences in B04 at 10m resolution as well:


hi, thanks for your quick reply. I understand the resolution of B04 is 10m. In the screenshot I actually showed 2x2 pixels in 20mx20m which means each pixel is still 10m.

Each Digital Number represents one pixel (10x10) and should show one grayscale(or say color), while here we see four pixels (20x20) shows one color. So I was confusing 🥲


Yes, I understand. What I wanted to say is that perhaps what was actually read (in your case) was 20x20 m resolution, and then “upscaled” to 10x10. I don’t know how rioxarray_open.rasterio reads JP2 data, but as jpeg2000 is wavelet transformed data, it would be possible that only penultimate “level” was read.


With EOBrowser and my QGIS screenshot I wanted to show that retrieving data from Sentinel Hub (at appropriate resolution!) you get data at 10m pixels (when requesting 10m bands, of course).


I just downloaded another original/unprocessed Sentinel data to have a look at its Band08’s pixel size. It’s strange that the size is indeed 10m at EO Browser but in qgis it is still showing 20m… It seems like it’s the problem from the Sentinel bands themselves.


I doubt that.


I’ve checked B02 and B08 of a “random” jp2 file from Sentinel-2 (tile 22KGG dated 2021-08-30) and both B02 and B08 show 10m pixel sizes in QGIS.



Which tile are you looking at?


yes, I am also confused. Here is the example, with band02 from “S2A_MSIL1C_20220210T102151_N0400_R065_T32UNU_20220210T141713.SAFE”:



Are you sure you are not just looking at 20m resolution data provided with L2A?


find . | grep B04
./S2B_MSIL2A_20220220T113229_N0400_R137_T27LZK_20220220T135509.SAFE/GRANULE/L2A_T27LZK_A025903_20220220T113227/IMG_DATA/R60m/T27LZK_20220220T113229_B04_60m.jp2
./S2B_MSIL2A_20220220T113229_N0400_R137_T27LZK_20220220T135509.SAFE/GRANULE/L2A_T27LZK_A025903_20220220T113227/IMG_DATA/R20m/T27LZK_20220220T113229_B04_20m.jp2
./S2B_MSIL2A_20220220T113229_N0400_R137_T27LZK_20220220T135509.SAFE/GRANULE/L2A_T27LZK_A025903_20220220T113227/IMG_DATA/R10m/T27LZK_20220220T113229_B04_10m.jp2

Bands B02, B03, and B04 (maybe others as well, haven’t checked) have 10/20/60m counterparts in the .SAFE files.


the path looks look this: 😳 it is L1C. And only these bands are showing in the folder, no R60/20/10m folders. I downloaded the tile from sci.hub



./S2A_MSIL1C_20220210T102151_N0400_R065_T32UNU_20220210T141713.SAFE/GRANULE/L1C_T32UNU_A034668_20220210T102159/IMG_DATA/T32UNU_20220210T102151_B02.jp2



I really don’t know how to help you…


Your file in my QGIS:



Perhaps check your QGIS version? This is mine:


the strange thing is that, from the “information” window, the pixel size is 10m actually: 🥲


the QGIS I used is the latest version:


But still, thank you so much! You have already been so nice. It’s always good to have another person to check with the data. Thanks!


I hope you find out that is going on. 💪


Reply