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

netCDF output fails for WCS in 7.4.1 #5968

Closed
constantinius opened this issue Jan 10, 2020 · 6 comments · Fixed by #5977
Closed

netCDF output fails for WCS in 7.4.1 #5968

constantinius opened this issue Jan 10, 2020 · 6 comments · Fixed by #5977

Comments

@constantinius
Copy link
Contributor

@constantinius constantinius commented Jan 10, 2020

netCDF output fails for the below map-file (referencing a vrt of 3 tiffs) with the following exception message:

<?xml version="1.0" encoding="UTF-8"?>
<ows:ExceptionReport xmlns:ows="http://www.opengis.net/ows/2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.0.1" xml:lang="en-US" xsi:schemaLocation="http://www.opengis.net/ows/2.0 http://schemas.opengis.net/ows/2.0/owsExceptionReport.xsd">
  <ows:Exception exceptionCode="NoApplicableCode" locator="mapserv">
    <ows:ExceptionText>msWCSWriteFile20(): General error message. msSaveImage() failed
msSaveImageGDAL(): General error message. Failed to create output netCDF file.
Unable to create netCDF file /vsimem/wcsout/5e1848d0_1b8_0./mosaic_MER_FRS_1P_reduced_RGB_20200110090535.nc (Error code 2): No such file or directory .</ows:ExceptionText>
  </ows:Exception>
</ows:ExceptionReport>

I test it using this command: mapserv -nh QUERY_STRING="map=test.map&version=2.0.1&service=WCS&request=GetCoverage&coverageid=mosaic_MER_FRS_1P_reduced_RGB&format=application/x-netcdf"

The same error (or very similar, at least) happens for WCS 1.0, so this has nothing to do with WCS 2.0:

# mapserv -nh QUERY_STRING="map=test.map&version=1.0.0&service=WCS&request=GetCoverage&coverage=mosaic_MER_FRS_1P_reduced_RGB&format=application/x-netcdf&crs=EPSG:4326&bbox=-3.75,32.19025,28.263455,46.268645&width=100&height=100"
<?xml version='1.0' encoding="UTF-8" ?>
<ServiceExceptionReport version="1.2.0"
xmlns="http://www.opengis.net/ogc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.opengis.net/ogc http://schemas.opengis.net/wcs/1.0.0/OGC-exception.xsd">
  <ServiceException>msSaveImageGDAL(): General error message. Failed to create output netCDF file.
Unable to create netCDF file /vsimem/msout/5e1872a0_1c8_0.nc (Error code 2): No such file or directory .
  </ServiceException>
</ServiceExceptionReport>

This is my setup:

# mapserv -v
MapServer version 7.4.1 OUTPUT=PNG OUTPUT=JPEG OUTPUT=KML SUPPORTS=PROJ SUPPORTS=AGG SUPPORTS=FREETYPE SUPPORTS=CAIRO SUPPORTS=SVG_SYMBOLS SUPPORTS=RSVG SUPPORTS=ICONV SUPPORTS=FRIBIDI SUPPORTS=WMS_SERVER SUPPORTS=WMS_CLIENT SUPPORTS=WFS_SERVER SUPPORTS=WFS_CLIENT SUPPORTS=WCS_SERVER SUPPORTS=SOS_SERVER SUPPORTS=FASTCGI SUPPORTS=THREADS SUPPORTS=GEOS SUPPORTS=PBF INPUT=JPEG INPUT=POSTGIS INPUT=OGR INPUT=GDAL INPUT=SHAPEFILE
# gdalinfo --version
GDAL 2.4.2, released 2019/06/28

On 7.0.7 (and GDAL 2.2.3, released 2017/11/20) the same request works and produces an output file.

MAP
  IMAGETYPE "png"
  NAME "MS"
  SIZE -1 -1
  STATUS ON
  UNITS METERS

  OUTPUTFORMAT
    NAME "netCDF"
    MIMETYPE "application/x-netcdf"
    DRIVER "GDAL/netCDF"
    EXTENSION ".nc"
    IMAGEMODE BYTE
    TRANSPARENT FALSE
    FORMATOPTION "FILENAME=mosaic_MER_FRS_1P_reduced_RGB_20200110090535.nc"
  END # OUTPUTFORMAT

  LEGEND
    KEYSIZE 20 10
    KEYSPACING 5 5
    LABEL
      SIZE 10
      OFFSET 0 0
      SHADOWSIZE 1 1
    END # LABEL
    STATUS OFF
  END # LEGEND

  QUERYMAP
    SIZE -1 -1
    STATUS OFF
    STYLE HILITE
  END # QUERYMAP

  SCALEBAR
    INTERVALS 4
    LABEL
      SIZE 10
      OFFSET 0 0
      SHADOWSIZE 1 1
    END # LABEL
    SIZE 200 3
    STATUS OFF
    UNITS MILES
  END # SCALEBAR

  WEB
    METADATA
      "ows_updateSequence"	"20131219T132000Z"
      "ows_onlineresource"	"*"
      "ows_enable_request"	"*"
    END # METADATA
  END # WEB

  LAYER
    DATA "test.vrt"
    EXTENT -3.75 32.19025 28.263455 46.268645
    METADATA
      "wcs_label"	"mosaic_MER_FRS_1P_reduced_RGB"
      "wcs_nilvalues_reasons"	"http://www.opengis.net/def/nil/OGC/0/unknown"
      "wcs_bandcount"	"3"
      "wcs_size"	"1021 449"
      "red_band_description"	"Red Channel"
      "wcs_formats"	"image/tiff image/jp2 application/x-netcdf application/x-hdf image/png"
      "wcs_green_interval"	"0 255"
      "wcs_srs"	"EPSG:4326 EPSG:3857 EPSG:3035"
      "wcs_band_names"	"red green blue"
      "wcs_imagemode"	"BYTE"
      "wcs_resolution"	"0.031355 -0.031355"
      "red_band_uom"	"W.m-2.Sr-1"
      "wcs_nilvalues"	"0"
      "blue_band_uom"	"W.m-2.Sr-1"
      "wcs_rangeset_name"	"RGB"
      "wcs_interval"	"0.000000 255.000000"
      "blue_band_definition"	"http://www.opengis.net/def/property/OGC/0/Radiance"
      "ows_enable_request"	"*"
      "wcs_green_label"	"green"
      "wcs_rangeset_label"	"RGB"
      "wcs_blue_label"	"blue"
      "blue_band_description"	"Blue Channel"
      "red_band_definition"	"http://www.opengis.net/def/property/OGC/0/Radiance"
      "ows_srs"	"EPSG:4326 EPSG:3857 EPSG:3035"
      "green_band_uom"	"W.m-2.Sr-1"
      "ows_title"	"mosaic_MER_FRS_1P_reduced_RGB"
      "wcs_red_interval"	"0 255"
      "wcs_extent"	"-3.75 32.19025 28.263455 46.268645"
      "green_band_definition"	"http://www.opengis.net/def/property/OGC/0/Radiance"
      "wcs_red_label"	"red"
      "wcs_significant_figures"	"3"
      "wcs_blue_interval"	"0 255"
      "green_band_description"	"Green Channel"
    END # METADATA
    NAME "mosaic_MER_FRS_1P_reduced_RGB"
    PROJECTION
      "proj=longlat"
      "datum=WGS84"
      "no_defs"
    END # PROJECTION
    STATUS OFF
    TILEITEM "location"
    TYPE RASTER
    UNITS METERS
  END # LAYER

END # MAP
@rouault
Copy link
Contributor

@rouault rouault commented Jan 10, 2020

Yes, this must be related to the fact the netCDF driver in recent versions of GDAL reports DCAP_VIRTUALIO support, but this is actually just for reading, not writing. MapServer shoud likely be patched to ignore DCAP_VIRTUALIO when the driver is netCDF

@constantinius
Copy link
Contributor Author

@constantinius constantinius commented Jan 10, 2020

Ah, that makes sense, so it was basically since version 2.4 of GDAL, right? (OSGeo/gdal#786)

@rouault
Copy link
Contributor

@rouault rouault commented Jan 10, 2020

so it was basically since version 2.4 of GDAL

yes

@constantinius
Copy link
Contributor Author

@constantinius constantinius commented Jan 10, 2020

How would you determine if we are dealing with a netCDF driver? Just check the drivers short name? We may need to check the GDAL version as-well, right?
I think these are the lines in question: https://github.com/mapserver/mapserver/blob/master/mapgdal.c#L185-L189

@rouault
Copy link
Contributor

@rouault rouault commented Jan 10, 2020

Just check the drivers short name?

yes

We may need to check the GDAL version as-well, right?

Seems more complicated than needed

I think these are the lines in question: https://github.com/mapserver/mapserver/blob/master/mapgdal.c#L185-L189

I also think so

rouault added a commit to rouault/mapserver that referenced this issue Jan 17, 2020
rouault added a commit that referenced this issue Jan 17, 2020
WCS output / msSaveImageGDAL(): fix support of netCDF output (#5968)
rouault added a commit that referenced this issue Jan 17, 2020
@constantinius
Copy link
Contributor Author

@constantinius constantinius commented Jan 19, 2020

Thank you very much, Even!

rouault added a commit to rouault/mapserver that referenced this issue Sep 4, 2020
rouault added a commit to rouault/mapserver that referenced this issue Sep 4, 2020
rouault added a commit to rouault/mapserver that referenced this issue Sep 4, 2020
MapServer-backport-bot pushed a commit to MapServer-backport-bot/MapServer that referenced this issue Sep 4, 2020
rouault added a commit that referenced this issue Sep 4, 2020
…-branch-7-6

[Backport branch-7-6] WCS 1.1 and 2.0: fix support of netCDF output (complementary fix to refs #5968)
rouault added a commit that referenced this issue Sep 4, 2020
WCS 1.1 and 2.0: fix support of netCDF output (complementary fix to refs #5968)
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

Successfully merging a pull request may close this issue.

2 participants