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

africa projection yields CRSError when saving dataset #776

Closed
gerritholl opened this issue May 17, 2019 · 3 comments · Fixed by #780
Closed

africa projection yields CRSError when saving dataset #776

gerritholl opened this issue May 17, 2019 · 3 comments · Fixed by #780

Comments

@gerritholl
Copy link
Collaborator

Describe the bug

The built-in "africa" projection gives a CRSError when saving the dataset.

To Reproduce

from satpy import Scene
from glob import glob
from satpy.utils import debug_on
debug_on()
fn_sev = glob("/media/nas/x21308/scratch/SEVIRI/*201904151000*")
sc = Scene(reader="seviri_l1b_hrit", filenames=fn_sev)
sc.load(["IR_108"])
afr = sc.resample("africa")
afr.save_dataset("IR_108", filename="africa.tiff")

Expected behavior
I expect no errors and a file africa.tiff with the scene resampled onto the Africa projection.

Actual results

/media/nas/x21324/miniconda3/envs/py37d/lib/python3.7/site-packages/pyspectral/config.py:75: YAMLLoadWarning: calling yaml.load() without Loader=... is deprecated, as the default Loader is unsafe. Please read https://msg.pyyaml.org/load for full details.                                                                                                                              
  config = recursive_dict_update(config, yaml.load(fp_))                                                                                                                                                                                                                                                                                                                                    
[DEBUG: 2019-05-17 20:27:28 : satpy.scene] Setting 'PPP_CONFIG_DIR' to '/home/gholl/checkouts/geotools/etc/'                                                                                                                                                                                                                                                                                
[DEBUG: 2019-05-17 20:27:28 : satpy.readers] Reading ['/media/nas/x21324/miniconda3/envs/py37d/lib/python3.7/site-packages/satpy/etc/readers/seviri_l1b_hrit.yaml']                                                                                                                                                                                                                         
[DEBUG: 2019-05-17 20:27:29 : satpy.readers.yaml_reader] Assigning to seviri_l1b_hrit: ['/media/nas/x21308/scratch/SEVIRI/H-000-MSG4__-MSG4________-HRV______-000021___-201904151000-__', '/media/nas/x21308/scratch/SEVIRI/H-000-MSG4__-MSG4________-HRV______-000014___-201904151000-__', '/media/nas/x21308/scratch/SEVIRI/H-000-MSG4__-MSG4________-HRV______-000012___-201904151000-__',
 '/media/nas/x21308/scratch/SEVIRI/H-000-MSG4__-MSG4________-HRV______-000023___-201904151000-__', '/media/nas/x21308/scratch/SEVIRI/H-000-MSG4__-MSG4________-HRV______-000001___-201904151000-__', '/media/nas/x21308/scratch/SEVIRI/H-000-MSG4__-MSG4________-HRV______-000015___-201904151000-__', '/media/nas/x21308/scratch/SEVIRI/H-000-MSG4__-MSG4________-HRV______-000002___-201904
151000-__', '/media/nas/x21308/scratch/SEVIRI/H-000-MSG4__-MSG4________-HRV______-000022___-201904151000-__', '/media/nas/x21308/scratch/SEVIRI/H-000-MSG4__-MSG4________-HRV______-000003___-201904151000-__', '/media/nas/x21308/scratch/SEVIRI/H-000-MSG4__-MSG4________-HRV______-000016___-201904151000-__', '/media/nas/x21308/scratch/SEVIRI/H-000-MSG4__-MSG4________-HRV______-00000
5___-201904151000-__', '/media/nas/x21308/scratch/SEVIRI/H-000-MSG4__-MSG4________-HRV______-000024___-201904151000-__', '/media/nas/x21308/scratch/SEVIRI/H-000-MSG4__-MSG4________-HRV______-000004___-201904151000-__', '/media/nas/x21308/scratch/SEVIRI/H-000-MSG4__-MSG4________-HRV______-000009___-201904151000-__', '/media/nas/x21308/scratch/SEVIRI/H-000-MSG4__-MSG4________-HRV_
_____-000010___-201904151000-__', '/media/nas/x21308/scratch/SEVIRI/H-000-MSG4__-MSG4________-HRV______-000008___-201904151000-__', '/media/nas/x21308/scratch/SEVIRI/H-000-MSG4__-MSG4________-HRV______-000018___-201904151000-__', '/media/nas/x21308/scratch/SEVIRI/H-000-MSG4__-MSG4________-HRV______-000020___-201904151000-__', '/media/nas/x21308/scratch/SEVIRI/H-000-MSG4__-MSG4__
______-HRV______-000007___-201904151000-__', '/media/nas/x21308/scratch/SEVIRI/H-000-MSG4__-MSG4________-HRV______-000006___-201904151000-__', '/media/nas/x21308/scratch/SEVIRI/H-000-MSG4__-MSG4________-HRV______-000013___-201904151000-__', '/media/nas/x21308/scratch/SEVIRI/H-000-MSG4__-MSG4________-HRV______-000011___-201904151000-__', '/media/nas/x21308/scratch/SEVIRI/H-000-MS
G4__-MSG4________-HRV______-000019___-201904151000-__', '/media/nas/x21308/scratch/SEVIRI/H-000-MSG4__-MSG4________-HRV______-000017___-201904151000-__', '/media/nas/x21308/scratch/SEVIRI/H-000-MSG4__-MSG4________-IR_016___-000003___-201904151000-__', '/media/nas/x21308/scratch/SEVIRI/H-000-MSG4__-MSG4________-IR_016___-000007___-201904151000-__', '/media/nas/x21308/scratch/SEVI
RI/H-000-MSG4__-MSG4________-IR_016___-000005___-201904151000-__', '/media/nas/x21308/scratch/SEVIRI/H-000-MSG4__-MSG4________-IR_016___-000006___-201904151000-__', '/media/nas/x21308/scratch/SEVIRI/H-000-MSG4__-MSG4________-IR_016___-000008___-201904151000-__', '/media/nas/x21308/scratch/SEVIRI/H-000-MSG4__-MSG4________-IR_016___-000001___-201904151000-__', '/media/nas/x21308/s
cratch/SEVIRI/H-000-MSG4__-MSG4________-IR_016___-000004___-201904151000-__', '/media/nas/x21308/scratch/SEVIRI/H-000-MSG4__-MSG4________-IR_016___-000002___-201904151000-__', '/media/nas/x21308/scratch/SEVIRI/H-000-MSG4__-MSG4________-IR_039___-000003___-201904151000-__', '/media/nas/x21308/scratch/SEVIRI/H-000-MSG4__-MSG4________-IR_039___-000001___-201904151000-__', '/media/n
as/x21308/scratch/SEVIRI/H-000-MSG4__-MSG4________-IR_039___-000006___-201904151000-__', '/media/nas/x21308/scratch/SEVIRI/H-000-MSG4__-MSG4________-IR_039___-000002___-201904151000-__', '/media/nas/x21308/scratch/SEVIRI/H-000-MSG4__-MSG4________-IR_039___-000005___-201904151000-__', '/media/nas/x21308/scratch/SEVIRI/H-000-MSG4__-MSG4________-IR_039___-000007___-201904151000-__'
, '/media/nas/x21308/scratch/SEVIRI/H-000-MSG4__-MSG4________-IR_039___-000008___-201904151000-__', '/media/nas/x21308/scratch/SEVIRI/H-000-MSG4__-MSG4________-IR_039___-000004___-201904151000-__', '/media/nas/x21308/scratch/SEVIRI/H-000-MSG4__-MSG4________-IR_087___-000004___-201904151000-__', '/media/nas/x21308/scratch/SEVIRI/H-000-MSG4__-MSG4________-IR_087___-000002___-20190
4151000-__', '/media/nas/x21308/scratch/SEVIRI/H-000-MSG4__-MSG4________-IR_087___-000001___-201904151000-__', '/media/nas/x21308/scratch/SEVIRI/H-000-MSG4__-MSG4________-IR_087___-000008___-201904151000-__', '/media/nas/x21308/scratch/SEVIRI/H-000-MSG4__-MSG4________-IR_087___-000007___-201904151000-__', '/media/nas/x21308/scratch/SEVIRI/H-000-MSG4__-MSG4________-IR_087___-0000
06___-201904151000-__', '/media/nas/x21308/scratch/SEVIRI/H-000-MSG4__-MSG4________-IR_087___-000005___-201904151000-__', '/media/nas/x21308/scratch/SEVIRI/H-000-MSG4__-MSG4________-IR_087___-000003___-201904151000-__', '/media/nas/x21308/scratch/SEVIRI/H-000-MSG4__-MSG4________-IR_097___-000007___-201904151000-__', '/media/nas/x21308/scratch/SEVIRI/H-000-MSG4__-MSG4________-IR_
097___-000002___-201904151000-__', '/media/nas/x21308/scratch/SEVIRI/H-000-MSG4__-MSG4________-IR_097___-000003___-201904151000-__', '/media/nas/x21308/scratch/SEVIRI/H-000-MSG4__-MSG4________-IR_097___-000001___-201904151000-__', '/media/nas/x21308/scratch/SEVIRI/H-000-MSG4__-MSG4________-IR_097___-000008___-201904151000-__', '/media/nas/x21308/scratch/SEVIRI/H-000-MSG4__-MSG4_
_______-IR_097___-000004___-201904151000-__', '/media/nas/x21308/scratch/SEVIRI/H-000-MSG4__-MSG4________-IR_097___-000005___-201904151000-__', '/media/nas/x21308/scratch/SEVIRI/H-000-MSG4__-MSG4________-IR_097___-000006___-201904151000-__', '/media/nas/x21308/scratch/SEVIRI/H-000-MSG4__-MSG4________-IR_108___-000008___-201904151000-__', '/media/nas/x21308/scratch/SEVIRI/H-000-M
SG4__-MSG4________-IR_108___-000006___-201904151000-__', '/media/nas/x21308/scratch/SEVIRI/H-000-MSG4__-MSG4________-IR_108___-000003___-201904151000-__', '/media/nas/x21308/scratch/SEVIRI/H-000-MSG4__-MSG4________-IR_108___-000005___-201904151000-__', '/media/nas/x21308/scratch/SEVIRI/H-000-MSG4__-MSG4________-IR_108___-000007___-201904151000-__', '/media/nas/x21308/scratch/SEV
IRI/H-000-MSG4__-MSG4________-IR_108___-000004___-201904151000-__', '/media/nas/x21308/scratch/SEVIRI/H-000-MSG4__-MSG4________-IR_108___-000002___-201904151000-__', '/media/nas/x21308/scratch/SEVIRI/H-000-MSG4__-MSG4________-IR_108___-000001___-201904151000-__', '/media/nas/x21308/scratch/SEVIRI/H-000-MSG4__-MSG4________-IR_120___-000005___-201904151000-__', '/media/nas/x21308/
scratch/SEVIRI/H-000-MSG4__-MSG4________-IR_120___-000002___-201904151000-__', '/media/nas/x21308/scratch/SEVIRI/H-000-MSG4__-MSG4________-IR_120___-000001___-201904151000-__', '/media/nas/x21308/scratch/SEVIRI/H-000-MSG4__-MSG4________-IR_120___-000008___-201904151000-__', '/media/nas/x21308/scratch/SEVIRI/H-000-MSG4__-MSG4________-IR_120___-000006___-201904151000-__', '/media/
nas/x21308/scratch/SEVIRI/H-000-MSG4__-MSG4________-IR_120___-000007___-201904151000-__', '/media/nas/x21308/scratch/SEVIRI/H-000-MSG4__-MSG4________-IR_120___-000003___-201904151000-__', '/media/nas/x21308/scratch/SEVIRI/H-000-MSG4__-MSG4________-IR_120___-000004___-201904151000-__', '/media/nas/x21308/scratch/SEVIRI/H-000-MSG4__-MSG4________-IR_134___-000003___-201904151000-__
', '/media/nas/x21308/scratch/SEVIRI/H-000-MSG4__-MSG4________-IR_134___-000005___-201904151000-__', '/media/nas/x21308/scratch/SEVIRI/H-000-MSG4__-MSG4________-IR_134___-000006___-201904151000-__', '/media/nas/x21308/scratch/SEVIRI/H-000-MSG4__-MSG4________-IR_134___-000004___-201904151000-__', '/media/nas/x21308/scratch/SEVIRI/H-000-MSG4__-MSG4________-IR_134___-000008___-2019
04151000-__', '/media/nas/x21308/scratch/SEVIRI/H-000-MSG4__-MSG4________-IR_134___-000002___-201904151000-__', '/media/nas/x21308/scratch/SEVIRI/H-000-MSG4__-MSG4________-IR_134___-000001___-201904151000-__', '/media/nas/x21308/scratch/SEVIRI/H-000-MSG4__-MSG4________-IR_134___-000007___-201904151000-__', '/media/nas/x21308/scratch/SEVIRI/H-000-MSG4__-MSG4________-VIS006___-000
006___-201904151000-__', '/media/nas/x21308/scratch/SEVIRI/H-000-MSG4__-MSG4________-VIS006___-000008___-201904151000-__', '/media/nas/x21308/scratch/SEVIRI/H-000-MSG4__-MSG4________-VIS006___-000001___-201904151000-__', '/media/nas/x21308/scratch/SEVIRI/H-000-MSG4__-MSG4________-VIS006___-000005___-201904151000-__', '/media/nas/x21308/scratch/SEVIRI/H-000-MSG4__-MSG4________-VI
S006___-000007___-201904151000-__', '/media/nas/x21308/scratch/SEVIRI/H-000-MSG4__-MSG4________-VIS006___-000003___-201904151000-__', '/media/nas/x21308/scratch/SEVIRI/H-000-MSG4__-MSG4________-VIS006___-000002___-201904151000-__', '/media/nas/x21308/scratch/SEVIRI/H-000-MSG4__-MSG4________-VIS006___-000004___-201904151000-__', '/media/nas/x21308/scratch/SEVIRI/H-000-MSG4__-MSG4
________-VIS008___-000003___-201904151000-__', '/media/nas/x21308/scratch/SEVIRI/H-000-MSG4__-MSG4________-VIS008___-000007___-201904151000-__', '/media/nas/x21308/scratch/SEVIRI/H-000-MSG4__-MSG4________-VIS008___-000004___-201904151000-__', '/media/nas/x21308/scratch/SEVIRI/H-000-MSG4__-MSG4________-VIS008___-000001___-201904151000-__', '/media/nas/x21308/scratch/SEVIRI/H-000-
MSG4__-MSG4________-VIS008___-000006___-201904151000-__', '/media/nas/x21308/scratch/SEVIRI/H-000-MSG4__-MSG4________-VIS008___-000002___-201904151000-__', '/media/nas/x21308/scratch/SEVIRI/H-000-MSG4__-MSG4________-VIS008___-000008___-201904151000-__', '/media/nas/x21308/scratch/SEVIRI/H-000-MSG4__-MSG4________-VIS008___-000005___-201904151000-__', '/media/nas/x21308/scratch/SE
VIRI/H-000-MSG4__-MSG4________-WV_062___-000005___-201904151000-__', '/media/nas/x21308/scratch/SEVIRI/H-000-MSG4__-MSG4________-WV_062___-000008___-201904151000-__', '/media/nas/x21308/scratch/SEVIRI/H-000-MSG4__-MSG4________-WV_062___-000004___-201904151000-__', '/media/nas/x21308/scratch/SEVIRI/H-000-MSG4__-MSG4________-WV_062___-000007___-201904151000-__', '/media/nas/x21308
/scratch/SEVIRI/H-000-MSG4__-MSG4________-WV_062___-000003___-201904151000-__', '/media/nas/x21308/scratch/SEVIRI/H-000-MSG4__-MSG4________-WV_062___-000002___-201904151000-__', '/media/nas/x21308/scratch/SEVIRI/H-000-MSG4__-MSG4________-WV_062___-000001___-201904151000-__', '/media/nas/x21308/scratch/SEVIRI/H-000-MSG4__-MSG4________-WV_062___-000006___-201904151000-__', '/media
/nas/x21308/scratch/SEVIRI/H-000-MSG4__-MSG4________-WV_073___-000005___-201904151000-__', '/media/nas/x21308/scratch/SEVIRI/H-000-MSG4__-MSG4________-WV_073___-000002___-201904151000-__', '/media/nas/x21308/scratch/SEVIRI/H-000-MSG4__-MSG4________-WV_073___-000008___-201904151000-__', '/media/nas/x21308/scratch/SEVIRI/H-000-MSG4__-MSG4________-WV_073___-000006___-201904151000-_
_', '/media/nas/x21308/scratch/SEVIRI/H-000-MSG4__-MSG4________-WV_073___-000003___-201904151000-__', '/media/nas/x21308/scratch/SEVIRI/H-000-MSG4__-MSG4________-WV_073___-000007___-201904151000-__', '/media/nas/x21308/scratch/SEVIRI/H-000-MSG4__-MSG4________-WV_073___-000004___-201904151000-__', '/media/nas/x21308/scratch/SEVIRI/H-000-MSG4__-MSG4________-WV_073___-000001___-201
904151000-__', '/media/nas/x21308/scratch/SEVIRI/H-000-MSG4__-MSG4________-_________-PRO______-201904151000-__', '/media/nas/x21308/scratch/SEVIRI/H-000-MSG4__-MSG4________-_________-EPI______-201904151000-__']                                                                                                                                                                          
[INFO: 2019-05-17 20:27:29 : hrit_msg] No IMPF configuration field found in prologue.
[DEBUG: 2019-05-17 20:27:29 : hrit_msg] Computing actual satellite position
[WARNING: 2019-05-17 20:27:29 : satpy.readers] Don't know how to open the following files: {'/media/nas/x21308/scratch/SEVIRI/seviri_201904151000.tar'}
[DEBUG: 2019-05-17 20:27:29 : satpy.composites] Looking for composites config file seviri.yaml
[DEBUG: 2019-05-17 20:27:29 : satpy.composites] Looking for composites config file visir.yaml
[DEBUG: 2019-05-17 20:27:30 : hrit_msg] Calibration time 0:00:00.008037
[DEBUG: 2019-05-17 20:27:30 : hrit_msg] Calibration time 0:00:00.008324
[DEBUG: 2019-05-17 20:27:30 : hrit_msg] Calibration time 0:00:00.008061
[DEBUG: 2019-05-17 20:27:30 : hrit_msg] Calibration time 0:00:00.007718
[DEBUG: 2019-05-17 20:27:30 : hrit_msg] Calibration time 0:00:00.007428
[DEBUG: 2019-05-17 20:27:30 : hrit_msg] Calibration time 0:00:00.007761
[DEBUG: 2019-05-17 20:27:30 : hrit_msg] Calibration time 0:00:00.007632
[DEBUG: 2019-05-17 20:27:30 : hrit_msg] Calibration time 0:00:00.007225
[DEBUG: 2019-05-17 20:27:30 : satpy.scene] Setting 'PPP_CONFIG_DIR' to '/home/gholl/checkouts/geotools/etc/'
[DEBUG: 2019-05-17 20:27:30 : satpy.scene] Resampling DatasetID(name='IR_108', wavelength=(9.8, 10.8, 11.8), resolution=3000.403165817, polarization=None, calibration='brightness_temperature', level=None, modifiers=())                                                                                                                                                                  
[INFO: 2019-05-17 20:27:40 : satpy.resample] Using default KDTree resampler
[DEBUG: 2019-05-17 20:27:40 : satpy.resample] Computing kd-tree parameters
[DEBUG: 2019-05-17 20:27:41 : satpy.resample] Resampling None
[DEBUG: 2019-05-17 20:27:41 : satpy.writers] Reading ['/media/nas/x21324/miniconda3/envs/py37d/lib/python3.7/site-packages/satpy/etc/writers/geotiff.yaml']
[DEBUG: 2019-05-17 20:27:41 : satpy.writers] Enhancement configuration options: [{'name': 'stretch', 'method': <function stretch at 0x7f66af321b70>, 'kwargs': {'stretch': 'linear'}}]
[DEBUG: 2019-05-17 20:27:41 : trollimage.xrimage] Applying stretch linear with parameters {}
[DEBUG: 2019-05-17 20:27:41 : trollimage.xrimage] Perform a linear contrast stretch.
[DEBUG: 2019-05-17 20:27:41 : trollimage.xrimage] Calculate the histogram quantiles:
[DEBUG: 2019-05-17 20:27:41 : trollimage.xrimage] Left and right quantiles: 0.005 0.005
Traceback (most recent call last):
  File "rasterio/_crs.pyx", line 253, in rasterio._crs._CRS.from_dict
  File "rasterio/_err.pyx", line 194, in rasterio._err.exc_wrap_ogrerr
rasterio._err.CPLE_BaseError: OGR Error code 7

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "mwe10.py", line 9, in <module>
    afr.save_dataset("IR_108", filename="africa.tiff")
  File "/media/nas/x21324/miniconda3/envs/py37d/lib/python3.7/site-packages/satpy/scene.py", line 1241, in save_dataset
    **save_kwargs)
  File "/media/nas/x21324/miniconda3/envs/py37d/lib/python3.7/site-packages/satpy/writers/__init__.py", line 812, in save_dataset
    return self.save_image(img, filename=filename, compute=compute, fill_value=fill_value, **kwargs)
  File "/media/nas/x21324/miniconda3/envs/py37d/lib/python3.7/site-packages/satpy/writers/geotiff.py", line 273, in save_image
    **gdal_options)
  File "/media/nas/x21324/miniconda3/envs/py37d/lib/python3.7/site-packages/trollimage/xrimage.py", line 271, in save
    **format_kwargs)
  File "/media/nas/x21324/miniconda3/envs/py37d/lib/python3.7/site-packages/trollimage/xrimage.py", line 321, in rio_save
    crs = rasterio.crs.CRS(data.attrs['area'].proj_dict)
  File "/media/nas/x21324/miniconda3/envs/py37d/lib/python3.7/site-packages/rasterio/crs.py", line 70, in __init__
    self._crs = _CRS.from_dict(data)
  File "rasterio/_crs.pyx", line 255, in rasterio._crs._CRS.from_dict
rasterio.errors.CRSError: The PROJ4 dict could not be understood. OGR Error code 7

Environment Info:

  • OS: Suse 15.0
  • Satpy Version: 0.15.1+38.gc7161c08
  • PyResample Version: 1.11.2
@djhoese
Copy link
Member

djhoese commented May 17, 2019

FYI here is what's in the area file. @sfinkens @mraspaud see anything suspicious?

africa:
  description: Africa - Global 1km USGS Landuse database
  projection:
    proj: laea
    a: 6370997.0
    lat_0: 5.0
    lon_0: 20.0
  shape:
    height: 9276
    width: 8350
  area_extent:
    lower_left_xy: [-4458000.0, -4795000.0]
    upper_right_xy: [3891000.0, 4480000.0]

@gerritholl
Copy link
Collaborator Author

The same happens with africa_10km.

@sfinkens
Copy link
Member

@djhoese @gerritholl No, I don't see anything suspicous. Cartopy doesn't seem to have a problem with that projection.

Pytroll Contributor's Week - Spring 2019 - Madison, WI automation moved this from In progress to Done May 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging a pull request may close this issue.

3 participants