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
Drawing coastlines/borders with save_datasets #464
Comments
You have two options:
It would be great if you could contribute any documentation to add to satpy to improve things for the various issues you've been making. |
Thanks @djhoese. I found the docs on satpy/satpy/writers/__init__.py Lines 183 to 194 in 75e8cb8
coast_dir . Going to try digging more in the source, but any help would be appreciated.
Would be happy to. Once I get my head wrapped around this (and dependent projects), I'll look into contributing docs. |
Ah ok, it is equivalent to the |
Perfect, thank you. I downloaded the GSHHS and WDBII Shapefiles from new_scn.save_datasets(overlay={'coast_dir': '/tmp/shapefiles/', 'color': (0, 0, 0)}) I got much farther this time, however I ran into the following exception:
Looking at https://github.com/pytroll/pycoast/blob/master/pycoast/cw_pil.py#L292-L293 As https://github.com/pytroll/pycoast/blob/master/pycoast/cw_agg.py#L381-L383 Traced it back to this: https://github.com/pytroll/pycoast/blob/master/pycoast/__init__.py#L8-L11 Looks like the import is failing due to the lack of the
Seemed like an error in string formatting for the resultant filename. Manually specifying the filename got me to the end: new_scn.save_datasets(filename='test.tif', overlay={'coast_dir': '/tmp/shapefiles/', 'color': (0, 0, 0)})
|
What data were you trying to save? The default filename format uses the attrs for name and start_time. |
I'm using GOES-16 full disk, channel 10. If I do not specify the new_scn.save_datasets()
|
Ah well then that must be a bug. I'll look in to it. |
I believe I am. Just downloaded the
Is there a better way to verify this? |
Can I see your code from Scene creation to save_datasets? |
And can you do |
Side question: How do you download those files from AWS without an AWS client? |
Yep, very simple (and messy): import os
from satpy import Scene
from glob import glob
from dask.diagnostics import ProgressBar
logging.basicConfig()
logger = logging.getLogger()
logger.setLevel(logging.DEBUG)
BASE_DIR = '.'
all_filenames = [glob(fn.replace('C01', 'C[0-9][0-9]*')[:len(BASE_DIR) + 50] + '*.nc') for fn in sorted(glob(os.path.join(BASE_DIR, 'OR*-RadF-*C*.nc')))]
scenes = [Scene(reader='abi_l1b', filenames=filenames) for filenames in all_filenames]
print("Number of Scenes: ", len(scenes))
# The first scene has all the bands
scene = scenes[0]
scene.load(['C10'])
new_scn = scene.resample(scene.min_area(), resampler='native')
with ProgressBar():
new_scn.save_datasets(filename='test.tif', overlay={'coast_dir': '/tmp/shapefiles/', 'color': (0, 0, 0), 'width': 3, 'level_coast': 1, 'level_borders': 2}) Note that the same code without the
I used the |
Hm I wonder if the native resampling is messing with this. FYI for a single channel you don't need to use the native resampler. That is only for composites trying to use data in different resolutions. Edit: Nope, nevermind. I was able to reproduce. |
Good to know. Just tried without resampling, same error:
|
Note that right now the default enhancements and limitations of pycoast will not let you add coastlines to a single band dataset. See #449 for details and status. So even after I fix this KeyError the single band will still fail. |
Strange, it actually works for me (assuming I specify the |
Interesting...very interesting...I'll play around with it and see what I get. What version of pycoast, trollimage, and satpy are you using? |
All installed via
|
What version of aggdraw? |
Also installed via
I've attached my |
Oh you are colorizing your datasets aren't you? You have a custom enhancement, right? |
Correct, from the efforts in #459. Let me try without. |
OK, without colorizing, I do get the error from #449! |
Ok this all makes sense now. The issue is that pycoast doesn't know what to do with single band (mode='L') data because it assumes that colors provided by the user are RGB. So as mentioned in #449 you either have to convert to RGB before hand or fix pycoast to support this. Since you are colorizing your data they are being converted from L to RGB so you were getting around the issue. |
Makes perfect sense! |
Hi there, I'm looking for a way to draw coastlines and political borders with
save_datasets()
. I see references in other issues to acoast_dir
, but not sure what should go in this directory. Cannot find much in the way of documentation either. Any help would be appreciated!The text was updated successfully, but these errors were encountered: