QGIS to MapServer

Convert a QGIS Project File to a MapServer Map File
2008-09-27



Introduction

QgisToMapServer converts a saved QGIS project file to a map file, ready to be served with MapServer. This makes QGIS a powerful editor for creating map files.

The process for creating a map file is:

  1. Load the layers you want to serve into QGIS
  2. Symbolize each layer, setting color, styles, etc.
  3. Save the QGIS project
  4. Run qgistomapserver
  5. Select a name for the map file
  6. Select the name of the saved project file
  7. Set other options for export
  8. Export the file

QgisToMapServer works with project files created with QGIS version 0.9 or greater.

Features

Why Standalone?

Why use this standalone application instead of the QGIS MapServer plugin? There seems to be a lot of instances where people have encountered problems across platforms when trying to export to MapServer. This application has no dependencies on the QGIS API or libraries. There are no external dependencies apart from those listed in the Requirements section.

QgisToMapServer provides additional features over the QGIS plugin and can be used on a machine without QGIS installed. At its core it is based on the same script (ms_export.py) as the QGIS plugin, however some minor modifications have been made.

Getting QgisToMapServer

License

QgisToMapServer is licensed under version 2.0 of the GPL. See http://www.gnu.org/licenses/old-licenses/gpl-2.0.html for the full license.

Requirements

QgisToMapServer requires the following:

If you have QGIS installed, you likely have all the mandatory requirements covered.

Binary Downloads

While there are no official releases of QgisToMapServer yet, it is quite usable.

Mac

A preview for Mac OS X is available at:

http://spatialserver.net/qgis2ms/download/qgistomapserver.dmg.gz

Uncompress the disk image and mount it by double-clicking on the dmg. You can run the application from the disk image or drag it to your Applications folder to install it.

Windows

A preview for Windows is available at:

http://spatialserver.net/qgis2ms/download/qgistomapserver.zip

Unzip to a directory and run the applcation by double-clicking on qgistomapserver.exe.

Source Download

You can download the current source from the Git repository:

http://spatialserver.net/cgi-bin/gitweb.cgi?p=mapserver_export.git

Choose the snapshot link from the latest revision.

QgisToMapServer should work on any platform that can meet the requirements given above.

Cloning the Repository

You can clone the repository if you want to make source changes and submit patches. To create a local copy, use:

    git clone git://spatialserver.net/mapserver_export.git

Installation

No installation is required. Simply run qgistomapserver.py from the command line or, if applicable, by double-clicking on it in your file explorer.

Future versions will include a binary distribution that will better integrate with your desktop environment.

Using QgisToMapServer

At present, QgisToMapServer is a simple dialog application with no menus or toolbars. The main dialog is shown below:

Description of the Controls

Map file
Name for the map file to create. You can use the Browse button to navigate to the directory where you want to save the map file.
QGIS project file
Name of the save QGIS project file to export
Generate sample map graphic
Checking this box will create a sample output from the generated map file using the shp2img utility
Export LAYER information only
Checking this box will create a map file containing only the layer sections of the map file. Typically you would use this to paste into an existing map file.
Name
Name for the map.
Width
Default width of the image to be generated by MapServer
Height
Default height of the image to be generated by MapServer
Units
Default units for the data in the map
Image type
Type of image to be created by MapServer. AGG is only supported at MapServer 5.x+. Default height of the image to be generated by MapServer
Path to Data
If you specify the path to your data, the value will be used as SHAPEPATH in the map file and all paths matching that will be replaced in the DATA statements for each layer.
Template
Web template to use in generating output (optional)
Header
Web header to use in generating output (optional)
Footer
Web footer to use in generating output (optional)

Creating a Map File

To create a map file you only need specify the following:

If the defaults are adequate you really only need the QGIS project file and the output map name.

Clicking the OK button will create the map file. If you requested a preview image it will be generated as well.

The results dialog includes the preview of the map file output and a brief log of what took place during the conversion process:

Note: the preview images may be left on your disk. They are created based on the map file name you provide and a suffix of map_preview.

sherman at mrcc dot com