satpy icon indicating copy to clipboard operation
satpy copied to clipboard

Coast overlays not working for nwcsaf cloudtype

Open ninahakansson opened this issue 2 years ago • 10 comments

Describe the bug When saving nwcsaf-pps images with coast overlays the products disapears and only the coastlines are shown.

To Reproduce

# Your code here
from satpy import Scene
from satpy.utils import debug_on
debug_on()
import glob

filenames = glob.glob("temp/NWCSAF/*.nc*")
scn1 = Scene(filenames=filenames)
scn1.load([ 'cloudtype'])
scn2 = scn1.resample("euron1")
scn2.show( 'cloudtype')
scn2.save_dataset('cloudtype', 'test_ct.png', overlay = {'coast_dir': '/gshhg-gmt-shp/','color': (255, 255, 0), 'width': 1.0, 'resolution': 'i'})

Expected behavior Expected png of cloud type product with coastlines.

Actual results Empty png except for the coastlines: test_ct

Screenshots If applicable, add screenshots to help explain your problem.

Environment Info:

  • OS: [e.g. OSX, Windows, Linux]
  • Satpy Version: [e.g. 0.41 and main branch]
  • PyResample Version:
  • Readers and writers dependencies (when relevant): [run from satpy.utils import check_satpy; check_satpy()]

ninahakansson avatar Mar 28 '23 13:03 ninahakansson

Does the problem occur only for PPS or also for GEO?

gerritholl avatar Mar 28 '23 13:03 gerritholl

So if you remove overlay from your save_dataset call, what do you get?

djhoese avatar Mar 28 '23 14:03 djhoese

So if you remove overlay from your save_dataset call, what do you get?

The expected image for the composite

mraspaud avatar Mar 28 '23 14:03 mraspaud

Is cloudtype an integer product before enhancement? I mean, after resample what is scn2['cloudtype'].dtype? And is it a single band or RGB? If RGB, what adds the colors? A composite or the enhancement?

djhoese avatar Mar 28 '23 15:03 djhoese

Before #2301: colors were added by the composite

After #2301: integer product, colors are added by an enhancement

gerritholl avatar Mar 28 '23 15:03 gerritholl

Ah ok, so the overlay logic doesn't handle palettized images.

djhoese avatar Mar 28 '23 15:03 djhoese

It seam if I add fill_value=0 as kwarg to save_dataet the product is not removed.

ninahakansson avatar Mar 28 '23 15:03 ninahakansson

Just hit this issue when working with some FCI L2 data. Adding fill_value=0 gave the expected output.

Is this a feature then?

TAlonglong avatar Feb 05 '25 16:02 TAlonglong

Storing palletised images with overlays would be tricky. It would mean one needs to add an entry to the colourtable for every colour used.

Turning them into RGB or RGBA and then adding an overlay should work. I think overlays come after enhancements?

gerritholl avatar Feb 05 '25 17:02 gerritholl

Yeah, I understand now.

So what happens is when adding overlays the image is not palletised any longer, but turn into, as you say, RGB og RGBA. But this is what I wanted here, so I'm good.

Anyway, by installing latest 0.54.0 satpy I get the image I want, RGBA with overlays.

Image

TAlonglong avatar Feb 06 '25 06:02 TAlonglong