Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RGB with 3 bands failed #428

Open
Mikiya83 opened this issue Dec 20, 2019 · 6 comments
Open

RGB with 3 bands failed #428

Mikiya83 opened this issue Dec 20, 2019 · 6 comments

Comments

@Mikiya83
Copy link

Sorry to spam issues recently.

I have a problem to display an RGB GTiff. Docs i can found talks about "range type", and coverage type seems to replace it but options are not exactly the same....
I created an "RGB" coverage type with field 0 as "Red" (UInt16), 1 as "Green" (UInt16) , 2 as "Blue" (UInt16). I tried with fields index 1,2,3 also, without succeed.
I merged 3 Landsat bands (4 3 2) with gdalmerge to have an RGB Gtiff with 3 bands.
I register this Gtiff as coverage with coverage type "RGB". In admin panel, i can see "bands count = 3", "field index =0", "bands interpretation = fields".
When i open it with openev, it's in RGB as expected, but when i open it in Web Client, it's only a white image :(

Whad did i miss ?

Thanks again

@constantinius
Copy link
Member

This may be due to the fact that the values are scaled quite differently. Pure RGB values are between 0 and 255, but Landsat has a Uint 16 data type which has a very different range of values.

You can adjust the rendering range using the values range parameter in the browse type fields.

For this to work you need to properly set up a coverage type, a product type with a browse type:

To create a product type do the following (link it to the RGB coverage type as-well):

python manage.py producttype create MyProductType -c RGB

Now create a browse type (with default name):

python manage.py browsetype create MyProductType \
        --red "Red" \
        --green "Green" \
        --blue "Blue" \
        --red-range 1 3000 \
        --green-range 1 3000 \
        --blue-range 1 3000 \
        --red-nodata 0 \
        --green-nodata 0 \
        --blue-nodata 0

You can adjust the ranges in the admin client afterwards to play around and see what appropriate values are.

Now create a product with the aforementioned product type:

python manage.py product register -t MyProductType -i MyProduct

When you re-register your coverage

python manage.py coverage register \
    # ... your values from before
     --replace \
     --product MyProduct

Now you should be able to see the rendered product in the Web Client.

@Mikiya83
Copy link
Author

Mikiya83 commented Dec 20, 2019

Ok i see the idea.
But i just try it in this order :

  • gdal_merge.py -o /data/lc8_rgb.tif -separate -co PHOTOMETRIC=RGB -co COMPRESS=DEFLATE /data/LC08_L1TP_195030_20191113_20191202_01_T1_B4.TIF /data/LC08_L1TP_195030_20191113_20191202_01_T1_B3.TIF /data/LC08_L1TP_195030_20191113_20191202_01_T1_B2.TIF

  • python manage.py producttype create MyProductType -c RGB

  • python manage.py browsetype create MyProductType \ --red "Red" \ --green "Green" \ --blue "Blue" \ --red-range 1 3000 \ --green-range 1 3000 \ --blue-range 1 3000 \ --red-nodata 0 \ --green-nodata 0 \ --blue-nodata 0

  • python manage.py product register -t MyProductType -i MyProduct

  • python manage.py coverage register --data /data/lc8_rgb.tif --meta-data /data/LC08_L1TP_195030_20191113_20191202_01_T1_ANG.txt --meta-data /data/LC08_L1TP_195030_20191113_20191202_01_T1_MTL.txt --coverage-type RGB --identifier myImgId --product MyProduct

RGB coverage type is from json file in autotest, i just change "red" identifier to "Red", ect....

And i still get a white image, i just notice some pink or blue pixels at the border.

layer

rgb

PS : i also tried to adjust max range in browsetype according to max values get by gdalinfo -mm, without succeed.

@Mikiya83
Copy link
Author

Mikiya83 commented Jan 6, 2020

Does the name of the properties in browsetype ( --green "Green" for example) has to match exactly with values in field "identifier" in the RGB coverage type ? I cannot get a colored image for now.

@constantinius
Copy link
Member

Yes, this has to be the exact identifier. So it should be Green as you already do.

You are using the web client interface, so I'm not sure if you actually see the correct layers.

Maybe you can try to use QGis or a similar client?

@Mikiya83
Copy link
Author

Mikiya83 commented Feb 13, 2020

Hi
I try multiple combinations of images and everytime i use Int16 (or UInt16), i can't get a working image by WMS requests in web client or QGIS client. The only solution i find is to translate it to Byte values, but i lost info so it's not a very good one. I even try to import a single band (for example B02 for a Sentinel2 image, or B02 of Landsat8), and it's not working.
Do you have any idea ? Thanks

@constantinius
Copy link
Member

constantinius commented Feb 14, 2020

@Mikiya83

I'm sorry for your troubles setting this up. Currently both the webclient and the services documentation are in transition, so I guess it is frustrating to get the service running.

First off: the webclient images you show are from the old version. This lacks some features and you will likely not get any decent results from that. Using the QGIS as a WMS client is more suitable, as you can actually select all the available layers so it is better to use that.

To help out I think I need more information of what you actually did.

I'll try to quickly explain the concepts involved, so maybe you have a better understanding of how to solve the issue.

I'll begin top down with the "Type" models: there is the CoverageType and the ProductType (and also the CollectionType if you use Collections). Each Coverage is associated with a CoverageType as is each Product with a ProductType (and also Collection with CollectionType, you get the idea).

The Coverage serves as a more raw data source and the CoverageType as a description of said data.

The Product combines multiple Coverages to a single entity and adds additional information in the shape of Browses and Masks. Browses are important here, as they give you a "view" into the coverage data which may not be visual. Here you have basically two options:

  • Use pre-generated grayscale, RGB or RGBA images and register them to the Product (using browse register)
  • Define a BrowseType on your ProductType with rules to dynamically generate said Browses from the Coverage data.

Example:

Say for instance you have a ProductType "PT" that has four CoverageTypes with each a single band: CT1 (band: red), CT2 (green), CT3 (blue) and CT4 (nir) all in Uint 16.

For the ProductType you can create three BrowseTypes:

  • one for true color RGB called TRUE_COLOR with the bands red, green, and blue (you need to specify the ranges depending on your data. For Sentinel 2 it is something like 0-10000)
  • one for false color called FALSE_COLOR: nir, red, green (also with the scaling applied)
  • one for NDVI called NDVI: here we use a single band output with the expression set to (nir - red) / (nir + red) (i think ;-) ). As it is an Index, the range should here be from -1 to 1.

Now you register a Product "P1 " associated with the above ProductType and register four Coverages: C1, C2, C3 and C4

In WMS you should now see the root layer P1 with a couple of sub layers: P1__outlines, P1__outlined, P1__TRUE_COLOR, P1__FALSE_COLOR and P1__NDVI (and possibly more).

If you access one of these: P1__TRUE_COLOR, P1__FALSE_COLOR and P1__NDVI in QGIS, you should see something visible.

You can now also create a CollectionType "CT1" referencing the ProductType above. Now you can create a collection CO1 and insert the P1 Product from above (and many more). Now there should be the same layers as above just with CO1.

Please let me know if was helpful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants