Change image resolution in mapfile

Brent Fraser bfraser at GEOANALYTIC.COM
Wed Jan 25 13:52:49 PST 2006


Steve (and others),

  Several months ago one of our engineers had a few spare cycles, so I posed
a question: "Can mapserver be used to generate large-format ( > 8 inches
wide) maps to a plotter?"

  We selected PDF as the output format (I can't recall why, but it may be
because of the vector rendering symbology issues mentioned).  Here's part of
his results:

==========================
The purpose of investigating mapserver was to determine if it could be used
for creating automated maps at specific scales for plotting to paper.



Given raster and vector data, mapserver can create an output map (jpeg,
tiff, pdf). Given that pdf files can store both vector and raster data, it
was determined that we would use pdf files as our format of choice.



The current version of mapserver (4.6.0) does not support raster images of
more than 256 colours. Some modifications were made to mapserver to create
24 bit colour images in PDF. (Note: These changes were not submitted back to
the public version of mapserver)



Creating a pdf for printing:

In order to create a map at a specified scale and paper size, some
calculations are needed.

The following are steps to calculate values for input to mapserver:

  1.. Decide paper size we want to print. Ex. 12"x12"
  2.. decide scale. Ex. 1:50000
  3.. find out resolution of imagery ex. Landsat - 12.5m/pixel
  4.. calculate coverage in metres that paper size and scale will equate to.
Ex. 50000x(12"x2.54/100) = 15240 m (so coverage is 15240m x 15240 m)
  5.. calculate # of pixels of image that is equivalent to coverage area.
Ex. 15240m / 12.5m/pixel = 1219.2 pixels
  6.. since we can't make an image that is not an integer # of pixels, we
round up to 1220 x 1220 pixels. However, this means the coverage area needs
to be increased by 0.8 pixels. i.e. 12.5m/pixel * 0.8 pixels = 10 m. so the
coverage is now 15250 x 15250 m
  7.. in the mapserver ".map" file, we specify the size of the image as 1220
x 1220 and set the extent xmin ymin xmax ymax (to cover the area of interest
that is 15250 x 15250 metres)
  8.. run mapserver
  9.. Mapserver should produce a map that when printed onto a sheet of paper
that is 12"x12" with no scaling, will be 1:50000 scale.
 The steps that have been described above should produce a map, when printed
with no scaling, of  1:50,000. However, this is not the case. For some
reason, mapserver creates a pdf file that when opened in Adobe acrobat
reader shows that the map is 1.4 times the size of what our calculations
have come out to be. i.e. acrobat says the map is ~ 16.8" x 16.8". This has
something to do with the pdf file being created at 72dpi.



==========================

He had made a few other changes to our copy of mapserver to work-around the
PDF scaling issue, but we were distracted by some paying work so we did not
post the code back to the mapserver community.   If someone (Steve L?  Frank
W?, anyone?) is interested in picking it up to review the changes (and make
improvements to our hacks!), I'll gladly send them the modified 4.6.0
source....

Brent Fraser




----- Original Message ----- 
From: "Stephen Woodbridge" <woodbri at SWOODBRIDGE.COM>
To: <MAPSERVER-USERS at LISTS.UMN.EDU>
Sent: Wednesday, January 25, 2006 2:22 PM
Subject: Re: [UMN_MAPSERVER-USERS] Change image resolution in mapfile


> Well, we are getting requests for large format printed maps being able
> to generate images that will support these efforts is important. Right
> now is is extremely hard to do this. My mapfiles have 150 layers and you
> have to make a custom mapfile for each resolution you want to support
> and change the thickness of all line widths, font sizes, symbol sizes,
> etc, etc. Fonts are a particularly difficult problem because you need to
> render them fatter also with increased DPI.
>
> It would be nice if there were also output controls supported in
> mapserver that would allow you to specify the DPI and have it
> automatically make the correct adjustments to the drawing code.
>
> -Steve W.
>
> Pericles S. Nacionales wrote:
> > The 72, 96, or 300 dpi numbers have no real meaning in digital
> > images--what matters is the dimensions of the image itself.  The dpi
> > stuff matters when sending the image to an output (display or hardcopy
> > prints).  Think of it this way, a 24000x24000-pixel image will come out
> > to be 333.33x333.33 inches in 72dpi display (printout, whatever),
> > 250x250 inches at 96dpi, and 80x80 inches at 300dpi.  Follow the
pattern?
> >
> > You can set your image size parameters (the target DPI, target output
> > size, or the pixel dimensions) in PhotoShop, the Gimp (with gimp-print),
> > any decent image manipulation software, or in the printer settings.
> >
> > Here's a little more info for you, from the world of digital
> > photography: http://www.normankoren.com/pixels_images.html#Imageres
> >
> > Cheers!
> > -Perry
> >
> > krishna S wrote:
> >
> >> I want an exactly 300 dpi map, so do you mean to set the mapsize to
> >> 24000X24000 pixels ....
> >>
> >> Thanks for your reply ..
> >>
> >>
> >



More information about the MapServer-users mailing list