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

Rahkonen Jukka (MML) jukka.rahkonen at maanmittauslaitos.fi
Thu Nov 17 23:44:30 PST 2016


Hi,

Hi,

I do not quite believe that your output pixels are non-square. I rather think that what you see are views of the native 4326 pixels reprojected into 3857.  In Scotland (7536002 N in epsg:3857) projecting data from 4326 to 3857 is making quite a big stretch in Nort-South direction. With your test GetMap request the pixel size in output is about 2.33 millimeters which must mean heavy oversampling.

-Jukka Rahkonen-

Peter Schmitt wrote:
[mapserver-users] Non-square pixels when re-projecting on the fly

>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/20161118/6b9da2ce/attachment.htm>


More information about the MapServer-users mailing list