Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I've just started using MapServer to check the topology in my database, and whenever I render a map I have to flip the image vertically and then rotate it quite a bit to get it facing North. I've set the projections to WGS84 but it doesn't seem to have any effect. Any ideas what I'm doing wrong?

The way I'm calling MapServer

http://localhost/cgi-bin/mapserv?map=test.map&layers=all&map_imagetype=JPEG&mode=map&mapext=52.8055+-2.0924+52.8175+-2.0785&map_size=1000+1000

The map file can be found at http://pastie.org/pastes/1647658/text

Here's an image showing how the map gets rendered and also what angle it should be at.. MapServer render

Also, when I try to overlay the image onto Google Maps I can't get any of the roads to line up with the Google ones. I know that my data is correct as I've checked the lon/lat values in the database against Google and they match up perfectly.. it's only when I output via MapServer that it doesn't match up.

Any thoughts would be appreciated!

share|improve this question
    
What is the original projection the data is in? –  Mapperz Mar 8 '11 at 16:04
    
It was originally in the Ordnance Survey format - I used a converter to convert it to WSG84 –  RichW Mar 8 '11 at 16:09
    
A simpler description of the operation is to reverse the x and y coordinates (hint, hint). –  whuber Mar 8 '11 at 16:09
3  
@RichW You and MapServer disagree about the order in which to specify latitude and longitude. You should be able to tell MapServer they are in the other order. –  whuber Mar 8 '11 at 16:33
1  
whuber is correct your Northing and Eastings when converted into in lat/lgn (WGS84) are the wrong way around - Microsoft did the same in SQL Server 2008 on the first beta release. –  Mapperz Mar 8 '11 at 18:22

3 Answers 3

up vote 3 down vote accepted

Assuming that your geometries in PostGIS actually represent the true lat and lon of your locations. e.g. x value = lon and y value = lat:

I see a few weird things:

  1. You have defined an output projection that is geographic, but with units of meters. Is this what you really want to do? I think that with Google, you either use a geographic spatial reference system with units of decimal degrees, or 'World Mercator' e.g. epsg:909913 or epsg:4785

  2. With MapServer, you need to define your map extent in the units of the output projection. You have specified meters as your units, but it looks like you are trying to set an extent in decimal degrees.

  3. In MapServer an extent is expressed as minx miny maxx maxy. When you say:
    mapext=52.8055+-2.0924+52.8175+-2.0785 Are you trying specifying an area in Ethiopia or Staford? I believe that you have your x and y coordinates reversed.

share|improve this answer
    
+1 Ethiopia?! Since the units are meters, we must be off the west coast of Africa :-). According to US government databases, loads of US addresses, industries, waste sites, wells, etc., can be found quite nearby. –  whuber Mar 8 '11 at 23:22
    
You are right. Bad geography. I meant to say that if he was trying to express the extent in decimal degrees, it would be somewhere of the coast of Somalia (maybe actually Kenya). –  DavidF Mar 9 '11 at 4:41
    
Cheers guys, turns out the conversion from lat/lon to postgis' geometry format was in the format lon/lat.. documentation surrounding that was pretty sketchy! Flipped the coordinates round and everything works as expected now. Same goes for the mapserver coordinates.. didn't realise it was lon/lat ;) –  RichW Mar 10 '11 at 10:19

It sounds like you need to check your conversion process from OS data to EPSG:4326.

As whuber wrote in the comments - are coordinates imported into PostGIS in the correct order? I would guess that they are incorrect in the database itself rather than related to MapServer as your map file seems fine (update: or not. See David's answer, although this would be likely to result in no data being displayed at all).

You could set MapServer to rotate your data with the ANGLE parameter, but this would only be hiding the underlying issue.

With regards to the shift when compared with Google base data, you will likely have to set a towgs84 parameter in your projection string during the conversion process - see Projected layer misaligned with Mapserver

share|improve this answer
1  
Good thoughts. These comments might help: (1) rotation won't fix the problem, because a coordinate reversal is a form of reflection. (2) I suspect difficulties in overlaying the maps occur because Google Maps is using a projection and the OP's map is not. –  whuber Mar 8 '11 at 23:18
    
@whuber - on 2) I'd assumed the op was using OpenLayers or similar to overlay the data, in which case it should be automatically reprojected to Web Mercator from EPSG:4326 by MapServer. However how he is overlaying data is unknown. –  geographika Mar 9 '11 at 16:59
    
Yes, I suspected the same, because that would explain why the difference isn't exactly a reflection and a rotation: the different apparent latitudes would cause differential distortion in the projection. That also would account for a mismatch with GM (unless the OP choose an appropriate transverse Mercator :-)). –  whuber Mar 9 '11 at 17:20
    
The conversion from OS to WGS84 was fine as I checked the coordinates after the conversion and they were spot on. It was the conversion to postgis' geometry format that did it as the coordinates were the wrong way round! Not sure what you mean about not using a projection though as I've specified 4326 throughout the map file - although the data looks correct I still have to skew it to make it line up with the google maps data.. –  RichW Mar 10 '11 at 10:21

I have had something like this after performing an higher level (eg ADJUST or SPLINE) image georeferencing in ArcGIS Desktop. Ie I georeferenced the image, image looked fine in ArcGIS. But when I open in Global Mapper (free eval for viewing) or mapserver, its in the wrong location.

Took ages to sort out, but it seems ArcGIS can read some of the additional world type files that the others cant. These are the files that ArcGIS adds in the georect process.

To resolve, I EXPORTED geoferenced image from ArcGIS to a new image, which locks in the georeferencing files in a way Globam Mapper and Map Server can read.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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