Opened 12 years ago

Closed 12 years ago

#2779 closed defect (fixed)

Shapes and rasters incorrectly displayed on a map with stereographic polar (EPSG:32661) projection

Reported by: gosselinandre Owned by: sdlime
Priority: high Milestone:
Component: MapServer CGI Version: 5.2
Severity: major Keywords: stereographic polar projection
Cc:

Description

My mapfile defines a map with a stereographic polar projection (very close to EPSG:32661). The map extent is defined so as to circumscribe lat>=55, with north pole(lat=90) at map center. The map uses 3 layers: 2 shapefiles covering canadian arctic (one for a land mask, one for 2-deg spaced grid), and a raster showing ocean temperature. All three input layers are based on EPSG:4326.

The result can be seen here : http://ctto-otpc.qc.dfo-mpo.gc.ca/cgi-bin/mapserv?mode=map&map=/var/www/html/wms/bug/bug55.map

The output is incorrect : all features and raster points lying totally inside circle with lat>= 55 are masked out.

When trying to understand the problem, I tried to simply reduce the map extent "ymax" value by the equivalent of some degrees to see if this would make any difference, adjusting the map widht/height size to preserve a correct aspect ratio. Everything else in the original mapfile was preserved. In other words, I chopped a strip off the top of the map belonging to the eastern hemisphere. Here are the results :

chopping off lat < 60 deg : http://ctto-otpc.qc.dfo-mpo.gc.ca/cgi-bin/mapserv?mode=map&map=/var/www/html/wms/bug/bug60.map

chopping off lat < 75 deg : http://ctto-otpc.qc.dfo-mpo.gc.ca/cgi-bin/mapserv?mode=map&map=/var/www/html/wms/bug/bug75.map

chopping off lat < 80 deg : http://ctto-otpc.qc.dfo-mpo.gc.ca/cgi-bin/mapserv?mode=map&map=/var/www/html/wms/bug/bug80.map

The results clearly show that "chopping off" the top of a latitude circle makes visible the features totally lying inside the chopped circle. Otherwise the features disappear. The extreme is case is a map where the extent covers lat >= 0. This map will come up empty.

This appears to me to be a clear bug. This makes it very difficult to generate a classical "polar stereographic" map centered on the north pole and covering bot h hemispheres (the most common case of a stereographic projection). "Stripping off" a band at the top of the map (as I did in the above examples) is a partial work-around, since you evidently loose the data lying in this band in the eastern hemisphere. This is very unfortunate since most of the maps we would like to produce require this projection.

As another fix, I was able to bring back incorrecty masked out shapes using mapscript and the following brute force approach :

-open shape file;
-for each shape in the shapefile object :

  • draw shape using its layer

The fact that the above works seems to indicate that the Mapserver library somewhere tries to speed up the drawing process by "clipping out" what the library thinks are "outliers", but makes a bad choice in the process, thus masking out relevant shapes and raster points. Could it be that the library thinks those lie in the southern hemisphere ? Unfortunately, I am unable to write a similar fix to bring mask to life incorrectly masked out raster pixels.

I am able to reproduce this bug at will, using either Mapserver v 4.10.3 or 5.2.0. My environment is : Linux RedHat? Enterprise 5.2, 64-bit machine. Mapserver was compiled using the tarball and the supplied Makefile. No problem reported during the configure/make/make install stanza.

Regards,

Andre Gosselin Maurice-Lamontagne Institute Mont-Joli Qc Canada Andre.Gosselin@…

Attachments (8)

bug55.map (1.4 KB) - added by gosselinandre 12 years ago.
Mapfile with extent circumscribing lat >= 55 deg
bug60.map (1.4 KB) - added by gosselinandre 12 years ago.
Mapfile with extent circumscribing lat >= 55 deg, top 5 deg stripped off
bug75.map (1.4 KB) - added by gosselinandre 12 years ago.
Mapfile with extent circumscribing lat >= 55 deg, top 20 deg stripped off
bug80.map (1.5 KB) - added by gosselinandre 12 years ago.
Mapfile with extent circumscribing lat >= 55 deg, top 25 deg stripped off
bug55.png (95.2 KB) - added by gosselinandre 12 years ago.
output of bug55.map
bgu60.png (129.1 KB) - added by gosselinandre 12 years ago.
output of bug60.map
bug75.png (166.0 KB) - added by gosselinandre 12 years ago.
output of bug75.map
bug80.png (161.4 KB) - added by gosselinandre 12 years ago.
output of bug80.map

Download all attachments as: .zip

Change History (10)

Changed 12 years ago by gosselinandre

Attachment: bug55.map added

Mapfile with extent circumscribing lat >= 55 deg

Changed 12 years ago by gosselinandre

Attachment: bug60.map added

Mapfile with extent circumscribing lat >= 55 deg, top 5 deg stripped off

Changed 12 years ago by gosselinandre

Attachment: bug75.map added

Mapfile with extent circumscribing lat >= 55 deg, top 20 deg stripped off

Changed 12 years ago by gosselinandre

Attachment: bug80.map added

Mapfile with extent circumscribing lat >= 55 deg, top 25 deg stripped off

Changed 12 years ago by gosselinandre

Attachment: bug55.png added

output of bug55.map

Changed 12 years ago by gosselinandre

Attachment: bgu60.png added

output of bug60.map

Changed 12 years ago by gosselinandre

Attachment: bug75.png added

output of bug75.map

Changed 12 years ago by gosselinandre

Attachment: bug80.png added

output of bug80.map

comment:1 Changed 12 years ago by gosselinandre

Shapefiles and raster data are available here: http://ctto-otpc.qc.dfo-mpo.gc.ca/wms/bug/bugdata.tar.bz2
Sorry for the size (22MB). Map files and output images have been attached to the ticket.

comment:2 in reply to:  description Changed 12 years ago by gosselinandre

Resolution: fixed
Status: newclosed

Replying to gosselinandre:

My mapfile defines a map with a stereographic polar projection (very close to EPSG:32661). The map extent is defined so as to circumscribe lat>=55, with north pole(lat=90) at map center. The map uses 3 layers: 2 shapefiles covering canadian arctic (one for a land mask, one for 2-deg spaced grid), and a raster showing ocean temperature. All three input layers are based on EPSG:4326.

The result can be seen here : http://ctto-otpc.qc.dfo-mpo.gc.ca/cgi-bin/mapserv?mode=map&map=/var/www/html/wms/bug/bug55.map

The output is incorrect : all features and raster points lying totally inside circle with lat>= 55 are masked out.

When trying to understand the problem, I tried to simply reduce the map extent "ymax" value by the equivalent of some degrees to see if this would make any difference, adjusting the map widht/height size to preserve a correct aspect ratio. Everything else in the original mapfile was preserved. In other words, I chopped a strip off the top of the map belonging to the eastern hemisphere. Here are the results :

chopping off lat < 60 deg : http://ctto-otpc.qc.dfo-mpo.gc.ca/cgi-bin/mapserv?mode=map&map=/var/www/html/wms/bug/bug60.map

chopping off lat < 75 deg : http://ctto-otpc.qc.dfo-mpo.gc.ca/cgi-bin/mapserv?mode=map&map=/var/www/html/wms/bug/bug75.map

chopping off lat < 80 deg : http://ctto-otpc.qc.dfo-mpo.gc.ca/cgi-bin/mapserv?mode=map&map=/var/www/html/wms/bug/bug80.map

The results clearly show that "chopping off" the top of a latitude circle makes visible the features totally lying inside the chopped circle. Otherwise the features disappear. The extreme is case is a map where the extent covers lat >= 0. This map will come up empty.

This appears to me to be a clear bug. This makes it very difficult to generate a classical "polar stereographic" map centered on the north pole and covering bot h hemispheres (the most common case of a stereographic projection). "Stripping off" a band at the top of the map (as I did in the above examples) is a partial work-around, since you evidently loose the data lying in this band in the eastern hemisphere. This is very unfortunate since most of the maps we would like to produce require this projection.

As another fix, I was able to bring back incorrecty masked out shapes using mapscript and the following brute force approach :

-open shape file;
-for each shape in the shapefile object :

  • draw shape using its layer

The fact that the above works seems to indicate that the Mapserver library somewhere tries to speed up the drawing process by "clipping out" what the library thinks are "outliers", but makes a bad choice in the process, thus masking out relevant shapes and raster points. Could it be that the library thinks those lie in the southern hemisphere ? Unfortunately, I am unable to write a similar fix to bring mask to life incorrectly masked out raster pixels.

I am able to reproduce this bug at will, using either Mapserver v 4.10.3 or 5.2.0. My environment is : Linux RedHat? Enterprise 5.2, 64-bit machine. Mapserver was compiled using the tarball and the supplied Makefile. No problem reported during the configure/make/make install stanza.

Regards,

Andre Gosselin Maurice-Lamontagne Institute Mont-Joli Qc Canada Andre.Gosselin@…

I was unaware of ticket #2765 when I opened this ticket. The patched proposed in #2765 solves the problem. Please close this ticket.

Andre

Note: See TracTickets for help on using tickets.