<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
</head>
<body>
<font face="Courier New, Courier, monospace">Hi all,<br>
<br>
I'm being pulled out of retirement to fix something I created
years ago. I'm probably doing something stupid but I haven't been
able to sort it out, so ask for some help.<br>
<br>
System: Ubuntu-22.04<br>
GDAL 3.4.1, released 2021/12/27<br>
OpenLayers 5.3.3<br>
MapServer version 7.6.4 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=POINT_Z_M
SUPPORTS=PBF INPUT=JPEG INPUT=POSTGIS INPUT=OGR INPUT=GDAL
INPUT=SHAPEFILE<br>
<br>
Right some of this is pretty old, but I suspect that is not the
current issue.<br>
<br>
1. I extract some data from HYCOM and generate a GTiff<br>
2. Manually generate a VRT to add a color table<br>
3. Have a mapserver mapfile to display it<br>
<br>
Step 1. seems to work fine, but when I do a mapserver query I get
no results<br>
Step 2. seems to look good and if a gdal_translate -of PNG
-outsize 1% 1% source target the image displays<br>
Step 3. just gives me empty transparent tiles in OpenLayers<br>
<br>
Here is the gdalinfo results for the GTif:<br>
<br>
$ gdalinfo -stats -hist HYCOM_tomorrow_mld.tif<br>
Driver: GTiff/GeoTIFF<br>
Files: HYCOM_tomorrow_mld.tif<br>
Size is 4500, 4251<br>
Coordinate System is:<br>
GEOGCRS["WGS 84",<br>
DATUM["World Geodetic System 1984",<br>
ELLIPSOID["WGS 84",6378137,298.257223563,<br>
LENGTHUNIT["metre",1]]],<br>
PRIMEM["Greenwich",0,<br>
ANGLEUNIT["degree",0.0174532925199433]],<br>
CS[ellipsoidal,2],<br>
AXIS["geodetic latitude (Lat)",north,<br>
ORDER[1],<br>
ANGLEUNIT["degree",0.0174532925199433]],<br>
AXIS["geodetic longitude (Lon)",east,<br>
ORDER[2],<br>
ANGLEUNIT["degree",0.0174532925199433]],<br>
ID["EPSG",4326]]<br>
Data axis to CRS axis mapping: 2,1<br>
Origin = (-180.000000000000000,90.000000000000000)<br>
Pixel Size = (0.080000000000000,-0.040000000000000)<br>
Metadata:<br>
AREA_OR_POINT=Area<br>
Image Structure Metadata:<br>
INTERLEAVE=BAND<br>
Corner Coordinates:<br>
Upper Left (-180.0000000, 90.0000000) (180d 0' 0.00"W, 90d 0'
0.00"N)<br>
Lower Left (-180.0000000, -80.0400000) (180d 0' 0.00"W, 80d
2'24.00"S)<br>
Upper Right ( 180.0000000, 90.0000000) (180d 0' 0.00"E, 90d 0'
0.00"N)<br>
Lower Right ( 180.0000000, -80.0400000) (180d 0' 0.00"E, 80d
2'24.00"S)<br>
Center ( 0.0000000, 4.9800000) ( 0d 0' 0.01"E,
4d58'48.00"N)<br>
Band 1 Block=4500x1 Type=Float32, ColorInterp=Gray<br>
Minimum=2.000, Maximum=5000.000, Mean=96.114, StdDev=346.786<br>
0...10...20...30...40...50...60...70...80...90...100 - done.<br>
256 buckets from -7.8 to 5009.8:<br>
1489490 2306537 1907189 2028756 996825 306674 493493 0 196427 0
94515 0 0 33174 0 22423 0 0 11571 0 5892 0 0 0 0 8326 0 0 0 0 0
8045 0 0 0 0 7615 0 0 0 0 6418 0 0 0 0 5695 0 0 0 0 4944 0 0 0 0 0
0 0 0 0 0 0 0 13673 0 0 0 0 0 0 0 0 0 0 0 17543 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 31132 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 30109 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 40660 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 28594 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 1702<br>
NoData Value=-30000<br>
Overviews: 2250x2126, 1125x1063, 563x532, 282x266, 141x133,
71x67<br>
Metadata:<br>
STATISTICS_MAXIMUM=5000<br>
STATISTICS_MEAN=96.114400289494<br>
STATISTICS_MINIMUM=2<br>
STATISTICS_STDDEV=346.78571541402<br>
STATISTICS_VALID_PERCENT=52.78<br>
<br>
My assumption based on this is that I want to scale the 5000 to
250 in the VRT which will be Type=Byte, So here is the VRT file.<br>
<br>
$ cat HYCOM_tomorrow_mld.vrt <VRTDataset
rasterXSize="72000" rasterYSize="68016"><br>
<SRS>GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS
84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0],UNIT["degree",0.0174532925199433],AUTHORITY["EPSG","4326"]]</SRS><br>
<GeoTransform> -180.0 ,0.005 , 0 , 90.0 , 0 , -0.0025
</GeoTransform><br>
<Metadata><br>
</Metadata><br>
<VRTRasterBand dataType="Byte" band="1"><br>
<ColorInterp>Palette</ColorInterp><br>
<ColorTable><br>
<Entry c1="0" c2="0" c3="0" c4="255"/><br>
<br>
[Snip lots of entries]<br>
<br>
<Entry c1="255" c2="255" c3="255" c4="255"/><br>
</ColorTable><br>
<ComplexSource resampling="bilinear"><br>
<SourceFilename
relativeToVRT="1">HYCOM_tomorrow_mld.tif</SourceFilename><br>
<SourceBand>1</SourceBand><br>
<SrcRect xOff="0" yOff="0" xSize="4500" ySize="4251"/><br>
<DstRect xOff="0" yOff="0" xSize="72000"
ySize="68016"/><br>
<ScaleRatio>1</ScaleRatio><br>
<NODATA>0</NODATA><br>
</ComplexSource><br>
</VRTRasterBand><br>
</VRTDataset><br>
<br>
So to scale the data I set ScaleRatio to 0.05, but the PNG image
doesn't look right and setting it to "1" does look correct. I'm
also confused as to what to set NODATA value to. One source
said/implied that the NoData of the source file would get set to
NODATA value in the VRT, but seem to be countered by the GDAL
online docs.<br>
<br>
Here is the gdalinfo for the VRT:<br>
<br>
$ gdalinfo -stats -hist HYCOM_tomorrow_mld.vrt<br>
Driver: VRT/Virtual Raster<br>
Files: HYCOM_tomorrow_mld.vrt<br>
HYCOM_tomorrow_mld.tif<br>
Size is 72000, 68016<br>
Coordinate System is:<br>
GEOGCRS["WGS 84",<br>
DATUM["World Geodetic System 1984",<br>
ELLIPSOID["WGS 84",6378137,298.257223563,<br>
LENGTHUNIT["metre",1]]],<br>
PRIMEM["Greenwich",0,<br>
ANGLEUNIT["degree",0.0174532925199433]],<br>
CS[ellipsoidal,2],<br>
AXIS["geodetic latitude (Lat)",north,<br>
ORDER[1],<br>
ANGLEUNIT["degree",0.0174532925199433]],<br>
AXIS["geodetic longitude (Lon)",east,<br>
ORDER[2],<br>
ANGLEUNIT["degree",0.0174532925199433]],<br>
ID["EPSG",4326]]<br>
Data axis to CRS axis mapping: 2,1<br>
Origin = (-180.000000000000000,90.000000000000000)<br>
Pixel Size = (0.005000000000000,-0.002500000000000)<br>
Corner Coordinates:<br>
Upper Left (-180.0000000, 90.0000000) (180d 0' 0.00"W, 90d 0'
0.00"N)<br>
Lower Left (-180.0000000, -80.0400000) (180d 0' 0.00"W, 80d
2'24.00"S)<br>
Upper Right ( 180.0000000, 90.0000000) (180d 0' 0.00"E, 90d 0'
0.00"N)<br>
Lower Right ( 180.0000000, -80.0400000) (180d 0' 0.00"E, 80d
2'24.00"S)<br>
Center ( 0.0000000, 4.9800000) ( 0d 0' 0.01"E,
4d58'48.00"N)<br>
Band 1 Block=128x128 Type=Byte, ColorInterp=Palette<br>
Minimum=2.000, Maximum=5000.000, Mean=96.114, StdDev=346.786<br>
0...10...20...30...40...50...60...70...80...90...100 - done.<br>
256 buckets from -0.5 to 255.5:<br>
0 0 534720 0 330663 0 149196 0 241797 0 233114 0 285113 0 0
385666 0 0 0 0 574491 0 0 0 0 517919 0 0 0 0 543348 0 0 0 0 455442
0 0 0 0 487763 0 0 0 0 530058 0 0 0 0 433926 0 0 0 0 0 0 0 0 0
1117668 0 0 0 0 0 0 0 0 0 911088 0 0 0 0 0 0 0 0 0 602087 0 0 0 0
0 0 0 0 0 394738 0 0 0 0 0 0 0 0 0 306674 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 493493 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 196427 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 94515 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 33174 0 0 0 0 244342<br>
Overviews: 36000x34016, 18000x17008, 9008x8512, 4512x4256,
2256x2128, 1136x1072<br>
Metadata:<br>
STATISTICS_MAXIMUM=5000<br>
STATISTICS_MEAN=96.114400289494<br>
STATISTICS_MINIMUM=2<br>
STATISTICS_STDDEV=346.78571541402<br>
Color Table (RGB with 256 entries)<br>
0: 0,0,0,255<br>
[snip additional entries]<br>
<br>
And finally the mapfile that is getting used via OpenLayers:<br>
<br>
MAP<br>
NAME "HYCOM_2d_2"<br>
STATUS ON<br>
SIZE 950 600<br>
EXTENT -180 -90 180 90<br>
UNITS DD<br>
IMAGECOLOR "#000000"<br>
IMAGETYPE agg_qn<br>
MAXSIZE 4096<br>
<br>
CONFIG ON_MISSING_DATA "IGNORE"<br>
# CONFIG MS_ERRORFILE "stderr"<br>
# DEBUG 10<br>
<br>
OUTPUTFORMAT<br>
NAME "agg_qn"<br>
DRIVER "AGG/PNG"<br>
EXTENSION "png"<br>
MIMETYPE "image/png"<br>
IMAGEMODE RGBA<br>
FORMATOPTION "INTERLACE=false"<br>
FORMATOPTION "QUANTIZE_NEW=ON"<br>
FORMATOPTION "QUANTIZE_FORCE=ON"<br>
FORMATOPTION "QUANTIZE_DITHER=OFF"<br>
FORMATOPTION "QUANTIZE_COLORS=256"<br>
TRANSPARENT ON<br>
FORMATOPTION "TRANSPARENT=ON"<br>
END<br>
<br>
OUTPUTFORMAT<br>
NAME aggpng24<br>
DRIVER AGG/PNG<br>
MIMETYPE "image/png"<br>
IMAGEMODE RGB<br>
EXTENSION "png"<br>
END<br>
<br>
OUTPUTFORMAT<br>
NAME jpeg<br>
DRIVER AGG/JPEG<br>
MIMETYPE "image/jpeg"<br>
IMAGEMODE RGB<br>
EXTENSION "jpg"<br>
FORMATOPTION "GAMMA=0.75"<br>
FORMATOPTION "QUALITY=75"<br>
END<br>
<br>
WEB<br>
METADATA<br>
labelcache_map_edge_buffer "-20"<br>
"ows_title" "iMaptools - HYCOM data"<br>
"ows_onlineresource"
<a class="moz-txt-link-rfc2396E" href="http://map01.saltwatercentral.com/cgi-bin/mapserv?MAP=/maps/wms/hycom_2d_2.map">"http://map01.saltwatercentral.com/cgi-bin/mapserv?MAP=/maps/wms/hycom_2d_2.map"</a><br>
"ows_srs" "EPSG:4326 EPSG:900913 EPSG:3857"<br>
"ows_contactperson" "Stephen Woodbridge"<br>
"ows_contactorganization" "iMaptools.com"<br>
"ows_contactposition" "Owner"<br>
"ows_contactelectronicmailaddress"
<a class="moz-txt-link-rfc2396E" href="mailto:info@imaptools.com">"info@imaptools.com"</a><br>
"ows_enable_request" "GetMap"<br>
"ows_http_max_age" "3200"<br>
END<br>
END<br>
<br>
PROJECTION "init=epsg:4326" END<br>
<br>
LAYER<br>
NAME "ssh"<br>
STATUS ON<br>
TYPE RASTER<br>
PROJECTION "init=epsg:4326" END<br>
DATA "/maps/wms/data/HYCOM/HYCOM_tomorrow_ssh.vrt"<br>
PROCESSING "NODATA=-30000"<br>
PROCESSING "SCALE=-1.0,1.0"<br>
END<br>
<br>
LAYER<br>
NAME "mlt"<br>
STATUS ON<br>
TYPE RASTER<br>
PROJECTION "init=epsg:4326" END<br>
DATA "/maps/wms/data/HYCOM/HYCOM_tomorrow_mlt.vrt"<br>
#PROCESSING "NODATA=1.2676506002282294e+30"<br>
PROCESSING "NODATA=-30000"<br>
PROCESSING "SCALE=0,250"<br>
END<br>
<br>
LAYER<br>
NAME "query"<br>
STATUS ON<br>
TYPE raster<br>
PROJECTION "init=epsg:4326" END<br>
VALIDATION 'type' '.' END<br>
TOLERANCE 0<br>
TOLERANCEUNITS pixels<br>
DATA "/maps/wms/data/HYCOM/HYCOM_tomorrow_%type%.tif"<br>
PROCESSING "NODATA=-30000"<br>
TEMPLATE "/maps/wms/pixel.value.html"<br>
END<br>
<br>
END<br>
<br>
I've tried various options of including PROCESSING "NODATA=' and
PROCESSING "SCALE=" to no success. And the "ssh" layer which is
nearly identical seems to would fine.<br>
<br>
It get displayed via OpenLayers using a layer definition like:<br>
<br>
hycom_mlt_2: new TileLayer({<br>
title: 'Mixed Layer Depth (0.3degC chg)',<br>
clickable: 'hycom_mlt_2',<br>
type: 'overlay',<br>
visible: false,<br>
source: new TileWMS({<br>
projection: 'EPSG:3857',<br>
urls: getMapUrls('//', map_hosts,
'/cgi-bin/mapserv?map=/maps/wms/hycom_2d_2.map'),<br>
params: {<br>
'LAYERS': 'mlt',<br>
'format': 'image/png',<br>
'version': '1.3.0'<br>
}<br>
})<br>
}),<br>
<br>
<br>
I would appreciate any assistance in figuring out what I'm doing
wrong.<br>
<br>
Thanks,<br>
Steve<br>
</font>
<div id="DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2"><br /><table style="border-top: 1px solid #D3D4DE;"><tr><td style="width: 55px; padding-top: 13px;"><a href="https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=emailclient" target="_blank"><img src="https://s-install.avcdn.net/ipm/preview/icons/icon-envelope-tick-round-orange-animated-no-repeat-v1.gif" alt="" width="46" height="29" style="width: 46px; height: 29px;"/></a></td><td style="width: 470px; padding-top: 12px; color: #41424e; font-size: 13px; font-family: Arial, Helvetica, sans-serif; line-height: 18px;">Virus-free.<a href="https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=emailclient" target="_blank" style="color: #4453ea;">www.avast.com</a></td></tr></table><a href="#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2" width="1" height="1"> </a></div></body>
</html>