mapbox / make-surface

Vector surfaces creation routines
MIT License
89 stars 18 forks source link

IOError: `/vsimem/work.jpc' not recognised as a supported file format. #45

Closed ian29 closed 9 years ago

ian29 commented 10 years ago

but it's a perfectly good lil .grib2 file: opens nicely in QGIS and gdal handles it well (after adding the .grib2 suffix)

test grib2

http://nomads.ncep.noaa.gov/cgi-bin/filter_gfs_hd.pl?file=gfs.t12z.mastergrb2f00&lev_2_m_above_ground=on&var_TMP=on&leftlon=0&rightlon=360&toplat=90&bottomlat=-90&dir=%2Fgfs.2014112012%2Fmaster

makesurface output:

▶ makesurface gfs.t12z.mastergrb2f00.grib2 gfs.t12z.mastergrb2f00.shp
dec_jpeg2000: Unable to open JPEG2000 image within GRIB file.
Is the JPEG2000 driver available?Traceback (most recent call last):
  File "/usr/local/bin/makesurface", line 9, in <module>
    load_entry_point('makesurface==0.0.1dev', 'console_scripts', 'makesurface')()
  File "/usr/local/lib/python2.7/site-packages/click/core.py", line 610, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python2.7/site-packages/click/core.py", line 590, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python2.7/site-packages/click/core.py", line 782, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python2.7/site-packages/click/core.py", line 416, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python2.7/site-packages/makesurface/scripts/cli.py", line 30, in cli
    makesurface.vectorizeRaster(infile, outfile, classes, classfile, weight, nodata, smoothing, band, carto, grib2)
  File "/usr/local/lib/python2.7/site-packages/makesurface/__init__.py", line 75, in vectorizeRaster
    with rasterio.open(infile, 'r') as src:
  File "/usr/local/lib/python2.7/site-packages/rasterio/__init__.py", line 112, in open
    s.start()
  File "rasterio/_base.pyx", line 67, in rasterio._base.DatasetReader.start (rasterio/_base.c:2105)
  File "_err.pyx", line 67, in rasterio._err.GDALErrCtxManager.__exit__ (rasterio/_err.c:966)
IOError: `/vsimem/work.jpc' not recognised as a supported file format.

gdalinfo output

gdalinfo gfs.t12z.mastergrb2f00.grib2 
ERROR 4: `/vsimem/work.jpc' not recognised as a supported file format.

dec_jpeg2000: Unable to open JPEG2000 image within GRIB file.
Is the JPEG2000 driver available?Driver: GRIB/GRIdded Binary (.grb)
Files: gfs.t12z.mastergrb2f00.grib2
Size is 720, 361
Coordinate System is:
GEOGCS["Coordinate System imported from GRIB file",
    DATUM["unknown",
        SPHEROID["Sphere",6371229,0]],
    PRIMEM["Greenwich",0],
    UNIT["degree",0.0174532925199433]]
Origin = (-0.250000000000000,90.250000000000000)
Pixel Size = (0.500000000000000,-0.500000000000000)
Corner Coordinates:
Upper Left  (  -0.2500000,  90.2500000) (  0d15' 0.00"W, 90d15' 0.00"N)
Lower Left  (  -0.2500000, -90.2500000) (  0d15' 0.00"W, 90d15' 0.00"S)
Upper Right (     359.750,      90.250) (359d45' 0.00"E, 90d15' 0.00"N)
Lower Right (     359.750,     -90.250) (359d45' 0.00"E, 90d15' 0.00"S)
Center      ( 179.7500000,   0.0000000) (179d45' 0.00"E,  0d 0' 0.01"N)
Band 1 Block=720x1 Type=Float64, ColorInterp=Undefined
  Description = 2[m] HTGL="Specified height level above ground"
  Metadata:
    GRIB_COMMENT=Temperature [C]
    GRIB_ELEMENT=TMP
    GRIB_FORECAST_SECONDS=0 sec
    GRIB_PDS_PDTN=0
    GRIB_PDS_TEMPLATE_NUMBERS=0 0 2 0 81 0 0 0 1 0 0 0 0 103 0 0 0 0 2 255 0 0 0 0 0
    GRIB_REF_TIME=  1416484800 sec UTC
    GRIB_SHORT_NAME=2-HTGL
    GRIB_UNIT=[C]
    GRIB_VALID_TIME=  1416484800 sec UTC
ian29 commented 10 years ago

occurrs with and without the --grib2 flag

sgillies commented 10 years ago
gdalinfo gfs.t12z.mastergrb2f00.grib2 
ERROR 4: `/vsimem/work.jpc' not recognised as a supported file format.

dec_jpeg2000: Unable to open JPEG2000 image within GRIB file.
Is the JPEG2000 driver available?Driver: GRIB/GRIdded Binary (.grb)
Files: gfs.t12z.mastergrb2f00.grib2

Ugh. I see what's happening. GDAL throws an error and continues. Rasterio catches that error and stops. Go home GDAL, you're drunk :(

Yuck. I'll come up with something toute de suite.

dnomadb commented 10 years ago

This runs fine for me - it looks as if rasterio on my system uses gdal 1.10.1* (where @ian29's uses 1.11.0).

I also have 1.11.0, but ... anaconda?

sgillies commented 10 years ago

I downloaded that .grib2 file from the API and get the same error as @ian29 did. Here it looks like the problem is a lack of JPEG2000 support in my GDAL (from Homebrew).

ian29 commented 10 years ago

I'm going to try this on an ec3 environment where hopefully we have more control / python setups are less messy

ian29 commented 10 years ago

not seeing this error in ec2land, so i guess i'll just never experience the joy of running makesurface on my computer.

@dnomadb up to you to close or if you want to support rogue/mystery gdal versions

dnomadb commented 9 years ago

No real idea of what to do with this - it is more of a rasterio issue, in any event. Moving the specific error there.