[mapserver-users] Non-square pixels when re-projecting on the fly

Peter Schmitt pschmitt at gmail.com
Thu Nov 17 14:56:16 PST 2016


Hi,

I have a GeoTIFF in EPSG:4326.  I want to re-project on the fly to 3857.
The imagery looks good, but one thing confuses me:  Pixels aren't square
when zoomed in very far with OpenLayers.

Here's my setup (see full mapfile & OpenLayers config at the end):

When the PROJECTION block of the mapfile is set to 4326, I get square
pixels:
http://i.imgur.com/jDQrxKH.png

where the WMS request looks something like:
http://localhost:8080/?SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&FORMAT=image%2Fpng&LAYERS=image_4326&MAP=/mapfile-4326.map&WIDTH=256&HEIGHT=256&CRS=EPSG%3A4326&STYLES=&BBOX=55.8872526884079%2C-2.8125375509262085%2C55.88725805282593%2C-2.8125321865081787


When the PROJECTION block of the mapfile is set to 3857 and I change the
OpenLayers view to have projection: 'EPSG:3857' and set the center to
coordinates in meters, I get rectangular pixels:
http://i.imgur.com/bw4pNPX.png

where the WMS request looks something like:
http://localhost:8080/?SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&FORMAT=image%2FpngLAYERS=image_3857&MAP=/mapfile-3857.map&WIDTH=256&HEIGHT=256&CRS=EPSG%3A3857&STYLES=&BBOX=-313090.24800606444%2C7536002.4584995285%2C-313089.65084178094%2C7536003.055663812

Side-note for anyone finding this thread in the future... When I re-project
a layer with a tileindex, I occasionally get banding at certain zoom levels
unless I add this to my LAYER: `PROCESSING "RESAMPLE=AVERAGE"`

Thanks,
Pete

### Mapserver mapfile-4326.map
MAP
        OUTPUTFORMAT
                NAME png24
                DRIVER "AGG/PNG"
                MIMETYPE "image/png"
                IMAGEMODE RGB
                EXTENSION "png"
        END

        IMAGETYPE PNG24
        IMAGECOLOR 255 255 255

        PROJECTION
                "init=epsg:4326"
        END

        NAME "mosaic_wms_server"

        WEB
                METADATA
                        "ows_title" "mosaics"
                        "ows_onlineresource" "
http://localhost:8080/?MAP=/mapfile-4326.map"
                        "ows_srs" "EPSG:4326"
                        "ows_enable_request" "*"
                        "wms_feature_info_mime_type" "text/html"
                END
        END

        MAXSIZE 4096

        LAYER
                NAME            "image_4326"
                METADATA
                        "ows_title"     "image stored in 4326"
                        "ows_srs"       "EPSG:4326 EPSG:3857"
                END
                DATA       "/path/to/image.tif"
                STATUS          OFF
                TYPE            RASTER
                PROJECTION
                        "+init=epsg:4326"
                END
        END
END

### OpenLayers-3 configuration for 4326:

var map = new ol.Map({
    layers: [
        new ol.layer.Tile({
            title: 'Test 4326',
            source: new ol.source.TileWMS({
                url: 'http://localhost:8080/mapserv',
                params: {
                    'LAYERS': 'image_4326',
                    'MAP': '/mapfile-4326.map'
                }
            })
        })
    ],
    target: 'map',
    view: new ol.View({projection: "EPSG:4326", center:
[-2.8126,55.8868],zoom: 20})
});
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/mapserver-users/attachments/20161117/9d37db57/attachment.html>


More information about the mapserver-users mailing list