1

I made a WMS service with MapServer to display a raster data. When I add it as an ArcGIS or a QGIS layer, there is a shift between the original layer and the WMS layer. This should not be a projection issue because the maps and the layer are all in the same coordinate system.

This shift is not static (if I slightly move the map, it will change in X and Y) and less than one pixel. Even if it is not a problem for many application, I need a very precise location of my pixels. I would therefore like to avoid this random shift. I've tried to remove the shift by setting (or not) the extent and the size of the map/layer in my mapfile, but nothing worked. The problem is exactly the same with ArcGIS and QGIS, therefore I am convinced that it comes from mapServer.

MAP

IMAGETYPE png

SIZE 120197 70397

EXTENT 50184.875 26720.668 289726.486 167015.441 # EXTENT LB72 in meters, from gdalinfo

PROJECTION

"init=epsg:31370" 

END

LAYER # Raster layer

NAME         test

STATUS       ON

TYPE         RASTER

METADATA

  "wms_title"    "test" 

END

PROJECTION

  "init=epsg:31370"

END

EXTENT    50184.875 26720.668 289726.486 167015.441 # EXTENT LB72 in meters, from gdalinfo
  • What version did you use for your WMS Service? I had some weird cell re-sample problems before when I tried to request a raster subset from Geoserver using WCS 1.0, but they works fine for WCS 2.0. – MaxG Apr 13 '17 at 13:46
2

I would say that it is difficult to avoid sub-pixel shifts with WMS. First of all you should control the WMS client so that it sends always BBOX, WIDTH, and HEIGHT that suit with the original pixels. If you have original imagery with pixel size of 10 m and you ask for an image with GetMap so that the pixel size is also 10 m but the BBOX begins from the middle of the source pixels then WMS server can't do anything else than resample pixels and slide the origin with 5 m.

The shift may not be as visible if you use average or bilinear resampling instead of the nearest neighbor which is the default http://www.mapserver.org/input/raster.html. But if you plan to work with sub-pixel accuracy then WMS is not the right service for you. Use WCS and download a subset of imagery at the native resolution and use that for processing.

I would be surprised if the shift that you experience is random. If the WMS server works as it is supposed to do the reason for the shift is in the BBOX that your client is generating. Capturing the GetMap requests and having a look at them should give you some more information.

  • thanks for your answers. The shift is indeed not a random one as it is guided by the extent as you mentioned. I will try to find a workaround, but I wanted a "visualisation only" solution so, as far as I understand, WCS is not the best solution in my case (I don't want my raster to be used for analysis because I want to evaluate "human" interpretation) – radouxju Apr 14 '17 at 5:59
0

I have run into this "dancing pixel" scenario while plotting GeoTIFFs via WMS VERSION:1.1.1 call to MapServer version 7.0.6 into OpenLayers. The pixels would shift and resize as I zoom or panned around. It appeared that MapServer would return a set of pixels from the GeoTIFF that fit the bounding box but resample it to fit the current viewport such that only whole pixels were returned to the viewport - no sub-pixels were present. After seeing the current accepted answer I decided to specify the resampling technique MapServer. I added

PROCESSING "RESAMPLE=NEAREST"

to my scale and it solved the issue. It appears that there might be a bug in MapServer that doesn't properly set the default resampling technique.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.