[mapserver-users] projection = geographer's pain
Monier Clement
clement.monier at v-trafic.com
Mon Oct 27 09:53:35 PDT 2008
Youre right.
I finally got a correct map by following your advices.
Thanks a lot.
_____
De : Roger André [mailto:randre at gmail.com]
Envoyé : lundi 27 octobre 2008 17:14
À : Monier Clement
Cc : mapserver-users at lists.osgeo.org
Objet : Re: [mapserver-users] projection = geographer's pain
Hi Monier,
My understanding of how this works is as follows.
Assuming your data is in epsg:4326, and you wish to display it in epsg:3785:
1) Your LAYER needs to reflect epsg:4326.
PROJECTION
"init=epsg:4326"
END
2) Your layer also needs to have a wms_srs parameter in the METADATA section
to allow for the layer to be requested in epsg:3785, ie
METADATA
"wms_srs" "EPSG:4326 EPSG:3785"
"wms_name" "counties"
"wms_server_version" "1.1.1"
"wms_format" "image/png"
"wms_onlineresource"
"http://localhost/cgi-bin/mapserv?map=/var/www/mapfiles/states/states.map
<http://localhost/cgi-bin/mapserv?map=/var/www/mapfiles/states/states.map&>
&"
END
3) Your request to Mapserver needs to define the extents of the image you
want , in the units of the projection. So a valid request for the layer
above would be:
http://localhost/cgi-bin/mapserv?map=/var/www/mapfiles/states/state.map
<http://localhost/cgi-bin/mapserv?map=/var/www/mapfiles/test/test.map>
&layers=counties
&srs=EPSG%3A3785
&version=1.1.1
&bbox=-20037508.34%2C-
20037508.34%2C-10018754.1704%2C-10018754.1704
&service=WMS
&width=256
&styles=
&format=image%2Fpng
&request=GetMap
&height=25
Hope that helps,
Roger
--
Monier Clement wrote:
Hi,
There is bigger than tiny difference in extents in epsg:4326 and in
epsg:3785. The latter is using meters as an unit.
I had a try with Finland polygon and here are the results:
D:\TEMP>ogrinfo -summary Finland_WGS84.shp Finland_WGS84
Feature Count: 1
Extent: (19.648331, 59.804989) - (31.587299, 70.079422)
D:\TEMP>ogr2ogr -f "ESRI Shapefile" -s_srs epsg:4326 -t_srs epsg:900913
Finland_
Spherical.shp Finland_WGS84.shp
D:\TEMP>ogrinfo -summary Finland_Spherical.shp Finland_Spherical
Feature Count: 1
Extent: (2187242.167179, 8356448.200347) - (3516282.078834, 11094615.004724)
-Jukka-
> Hi,
>
> I got the map extent from shpinfo.
> Beside, I know that there should only be a tiny difference
> between coordinates in latlon-wgs84 (data proj) and "web
> spherical mercator" (map proj).
>
> You'll find the whole test-case files as attachement.
>
> Here's the command line to get the map :
> C:\ms4w\tools\mapserv\shp2img -m
> C:\ms4w\apps\gmap\htdocs\test.map -o test.png -l layer1 -i agga
>
> Thanks
>
> Clément
>
>
> -----Message d'origine-----
> De : Rahkonen Jukka [mailto:Jukka.Rahkonen at mmmtike.fi]
> Envoyé : lundi 27 octobre 2008 12:46
> À : Monier Clement; mapserver-users at lists.osgeo.org Objet :
> VS: [mapserver-users] projection = geographer's pain
>
> 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/mapserver-users/attachments/20081027/a1dc9c44/attachment.htm>
More information about the MapServer-users
mailing list