VS: [mapserver-users] projection = geographer's pain

Pietro Giannini pgiannini at bytewise.it
Mon Oct 27 09:44:12 EDT 2008


there is something strange... :-)

I normally project data in lat-lon wgs84 coordinates in world mercator.

I declare latlon wgs as
            "epsg:4326"
or
            "+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs"
and world mercator as
            "+proj=merc +lon_0=0 +k=1 +x_0=0 +y_0=0 +ellps=WGS84
+datum=WGS84 +units=m +no_defs"
(http://spatialreference.org/ref/epsg/3395/)

You use another declaration, that is the "google mercator"
(http://spatialreference.org/ref/user/google-projection/) that is slightly
different... I don't know well Proj4, but I believe that this is not the
core of the problem...

I know (maybe I do not know well) that the projection of the map is
different from the projection of the layer bcause the layer data source
(shapefile, postgis...) can be data with coordinates referred to a spatial
reference which can be different from the spatial reference of the map.

This allow mapserver to combine data coming from different source in a
single map.

If not declared, the LAYER inherits the PROJECTION of the map.

So, if yo have data in a projection and you want to project them in
another, all you have to do is correctly declare both PROJECTION section:
in the MAP and in LAYER.

obviously you must to set correctly the EXTENT and the UNIT of the MAP,
according to the PROJECTION of MAP, otherwise you will obtain a wrong part
of the map from the mapserver.
e.g.: if you have a PROJECTION latlon wgs84 the extent of the entire world
is "-180 -90 180 90" and units is "DD", if the projection is world
mercator the extent is "-20000000 -20000000 20000000 20000000" (from my
experience!) and units is "meters".

( If someone can explain me the difference from world mercator and google
mercator, and more generally can explain the parameters of proj4, I'll be
eternally grateful! )

Hope this help
........................................pg



-- 
Pietro Giannini
Bytewise srl - Area GIS
41°50'38.58"N 12°29'13.39"E



On Lun, Ottobre 27, 2008 12:46, Rahkonen Jukka wrote:
> Hi,
>
> Have you double-checked that your map extent correspods with the map
> projection?
> Or if you could send your whole mapfile I am pretty sure that you will get
> a final answer to your problem.
>
> -Jukka Rahkonen-
>
>> -----Alkuperäinen viesti-----
>> Lähettäjä: mapserver-users-bounces at lists.osgeo.org
>> [mailto:mapserver-users-bounces at lists.osgeo.org] Puolesta
>> Monier Clement
>> Lähetetty: 27. lokakuuta 2008 13:39
>> Vastaanottaja: 'Pietro Giannini'; mapserver-users at lists.osgeo.org
>> Aihe: RE: [mapserver-users] projection = geographer's pain
>>
>>
>> Thanks for your answers Roger & Pietro.
>>
>> I've followed your advice by trying these 4 test-cases :
>>
>> 1)
>> Map proj set to :   "init=epsg:3785" (web spherical Mercator,
>> manually added
>> into espg file)
>> Layer proj set to : "init=epsg:4326" (latlon wgs84, proj system of my
>> shapefiles)
>>
>> => got a blank map
>>
>> 2)
>> Map projection set to : "init=epsg:4326"
>> Layer projection set to : "init=epsg:4326"
>>
>> => got a map
>>
>> 3)
>> Map projection set to : "init=epsg:3785"
>> Layer projection set to : "init=epsg:3785"
>>
>> => got the same map as 2)
>>
>> 4)
>> Map projection set to : "init=epsg:4326"
>> Layer projection set to : "init=epsg:3785"
>>
>> => got a blank map
>>
>> I've also tried with another well-known existing epsg
>> proj-system (instead of the manually-added 3785 code), but
>> got the same results.
>> I've made other attempts by replacing "init=3785" by full
>> description proj-string like "+proj=longlat +ellps=WGS84
>> +datum=WGS84 +no_defs  no_defs"
>> or "+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0
>> +x_0=0.0 +y_0=0
>> +k=1.0 +units=m +nadgrids=@null  no_defs"
>> But it didn't change anything...
>>
>> It seems that :
>> - a map is drawn only if the map's and layer's proj-systems
>> are the same.
>> - the output projection is always overridden by the shapefile
>> system, no re-projection is done anyway.
>>
>> Let me know if you have any further leads to solve this issue.
>>
>> Thanks for your help
>>
>> Clément
>>
>> -----Message d'origine-----
>> De : mapserver-users-bounces at lists.osgeo.org
>> [mailto:mapserver-users-bounces at lists.osgeo.org] De la part
>> de Pietro Giannini Envoyé : vendredi 24 octobre 2008 21:40 À 
>> : mapserver-users at lists.osgeo.org Objet : Re:
>> [mapserver-users] projection = geographer's pain
>>
>> I can confirm that projection is often a pain!
>>
>> However, the problem may be in the projection of the layer.
>>
>> The PROJECTION section in a layer declare the projection of
>> the data source of this layer, while the PROJECTION on the
>> map level is the projection wich you want to show the whole
>> map. So you can overlay more data sources in different
>> projection in a single map.
>>
>> Try to set the layer PROJECTION as "init=epsg:4326".
>> Let us know...
>> ciao
>> ........................... pg
>>
>>
>> --
>> Pietro Giannini
>> Bytewise srl - Area GIS
>> 41°50'38.58"N 12°29'13.39"E
>>
>>
>>
>>
>> On Ven, Ottobre 24, 2008 16:55, Monier Clement wrote:
>> > Hi,
>> >
>> >
>> >
>> > I'm running MS4W v2.2.8 (including MapServer 5.2) on windows.
>> >
>> > My datasource is shapefiles with WGS84 projection (epsg:4326).
>> >
>> > I would like MapServer to render these data into a "Web (spherical)
>> > Mercator" projected map (epsg:3785) in order to perfectly
>> overlay the
>> > GoogleMaps tile images (for the moment, my maps are slightly shifted
>> > north.)
>> >
>> >
>> >
>> > I've added this string at the end of the file "epsg" in
>> /ms4w/proj/nad :
>> >
>> > <3785> +proj=merc +a=6378137 +b=6378137 +lat_ts=0.0
>> +lon_0=0.0 +x_0=0.0
>> > +y_0=0 +k=1.0 +towgs84=0,0,0,0,0,0,0 +units=m
>> +nadgrids=@null +no_defs <>
>> >
>> >
>> >
>> > But I don't know how to modify my request and mapfile in
>> order to get the
>> > correct map.
>> >
>> > I've tried many combinations so far but with no success until now.
>> >
>> >
>> >
>> > Do I have to change the projection system of my shapefiles ?
>> >
>> > Is MapServer able to change projection between input and output ?
>> >
>> >
>> >
>> > Request : "&SRS=epsg:3785"
>> >
>> >
>> >
>> > MapFile :
>> >
>> >
>> >
>> > [Map section]
>> >
>> >   METADATA
>> >
>> >     "wms_srs"   "EPSG:4326 EPSG:3785" # is this correct ?
>> >
>> >   END
>> >
>> >
>> >
>> > PROJECTION
>> >
>> >    "init=epsg:3785" # is this correct ?
>> >
>> > END
>> >
>> >
>> >
>> > [Layer section]
>> >
>> >   METADATA
>> >
>> >     "wms_srs"   "EPSG:3785" # is this correct ?
>> >
>> >   END
>> >
>> >   PROJECTION
>> >
>> >    "init=epsg:3785" # is this correct ?
>> >
>> >   END
>> >
>> >
>> >
>> > With these settings, the pictures I got from MapServer are
>> still shifted.
>> >
>> >
>> >
>> > Thanks for your help
>> >
>> >
>> >
>> > Clement
>> >
>> >
>> >
>> > _______________________________________________
>> > mapserver-users mailing list
>> > mapserver-users at lists.osgeo.org
>> > http://lists.osgeo.org/mailman/listinfo/mapserver-users
>> >
>>
>>
>> _______________________________________________
>> mapserver-users mailing list
>> mapserver-users at lists.osgeo.org
>> http://lists.osgeo.org/mailman/listinfo/mapserver-users
>>
>> _______________________________________________
>> mapserver-users mailing list
>> mapserver-users at lists.osgeo.org
>> http://lists.osgeo.org/mailman/listinfo/mapserver-users
>>
> _______________________________________________
> mapserver-users mailing list
> mapserver-users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/mapserver-users
>



More information about the mapserver-users mailing list