Open Source Maps – Data and Software

Since we did the Long Walk last Summer I have been very interested in open source mapping tools. I had really wanted to plot our progress along the South West Coast Path by uploading coordinates from a friend’s GPS unit each night. With the Grand tour of the USA coming up this September my interest has been renewed.
My initial research had lead me to believe that map data is very very expensive. On the face of it, I thought I’d have to spend thousands of pounds in order to plot anything like a decent map of the Devon coastline, let alone the whole of North America or the entire World. To add to the financial pain, most suppliers of map data charge an annual licence fee, rather than a one-off payment. This means that only those who are planning to make large sums of money are going to be able to justify the cost.

Searching around on the internet for things like “free map data” didn’t really yeald much either. The world is full of people trying to sell things, and all of those have higher search engine rankings than the people who are trying to do things for free. In the end I found what I was looking for, though – otherwise there wouldn’t be any point writing an article.
Route of the Figure 1: Route of the “Long Walk” 2004 – Sadly I didn’t get chance to use the GPS output

It turns out that the best source of free map data, contrary to what you might expect, is the CIA. They have released the vmap0 dataset, which covers the entire world and contains a huge number of layers including everything from coastlines to power stations, populated areas, oil wells, vegitation and roads. The vmap0 data is available totally free (I downloaded it from Map Ability), in fact the only cost imposed on the user is the headache of dealing with the antiquated file format and strange naming conventions used.

Vmap0 is a vector dataset, so all features are represented as points, lines or polygons (areas). The only glaring omission from the vmap0 dataset is height data. Typically, height data is provided in a raster format – a grid of integer values in which each value represents the height of an area above sea level. Since vmap0 is vector based its not too much of a shock that height data isn’t included. The USNational Geophysical Data Center (NGDC) has released a raster height dataset called ETOPO2 which can be downloaded free and provides raster height data with a resolution of 2 arc minutes. GTOPO30, developed by the US Geological SurveyNASA and others, has a much higher resolution of 30 arc seconds (around 1km). Both of these datasets are available for free download from the internet.

Using these datasets alone I was able to create some reasonably impressive maps which have a global scope and cost me nothing other than some extra RAM for my Linux server and a reasonable chunk of my time this spring.

Yosemite National Park in California, USA
Figure 2: Yosemite National Park in California, USA

The software I used to create the mapping system is called “Map Server“. I think (judging by several confusing search results) there are several products called “Map Server”, so to avoid confusion, I am using the open source one, originally developed at The University of Minnesota. The software runs under a Windows or Linux web server as a CGI application or a PHP module. Since I have a Linux Server (Clive) sitting in my study on a 24×7 internet connection it seemed sensible for me to use the Linux version. As most of my web page is coded in PHP I chose the PHP module over the CGI.

Before I get on with the remainder of the article, I think I should probably mention some of the requirements for a mapping project such as this one. The data directory on my server is now close to 5Gb, which mapserver must trawl through every time it produces a map. Clive the server is probably below the lowest required specification but manages to create maps like the ones above in less than 30 seconds.

  • CPU: Athlon (original) 700MHz
  • 768Mb (upgraded for this project)
  • Disk: Minimum 5Gb
  • OS: Fedora Core 2
  • Software: Apache, MySQL, C/C++ Compiler

Machines of around that spec will be good for development and single user projects, but if you want to develop a serious application which will generate maps quickly or be used by many people at the same time then you’re going to have to throw something a lot quicker at it.

The remainder of this article gives more details of the vector and raster datasets I’ve used to create my map system, a very technical section on the installation of mapserver and the associated tools for dealing with the data, a page of information on how to convert vmap0 data to a sensible format and a quick tour of the user interface I developed in PHP.

Vector Data – vmap0

The vmap0 dataset is provided in a very strange file format called “VPF”. One of the first tasks is to convert it to a more sensible format which Mapserver will support. I’ll cover the details of conversion in a couple of pages time. On this page I’ll give a quick introduction to the data in the most general sense and some basic hints and tips for downloading and viewing it.

Downloading vmap0

The first step, obviously, is to download the files. I downloaded them from the US National Geospatial-Intelligence Agency who kindly make them available free of charge. Many other websites allow you to download them for a fee or buy a CD for an inflated price. The files are in tar/gzip compressed format but are still very large; four files are available: North America (246Mb), Europe and North Asia (240Mb),South America and Antarctica (168Mb) and South East Asia, Africa and Australasia (229Mb). These files uncompress to just under 2Gb. I have a reasonable broadband deal, but to save me waiting around I ran a simple bash script to download the files while I watched the TV smilie

#!/bin/bashBASE=http://geoengine.nima.mil/ftpdir/archive/vpf_data/

for F in v0noa.tar.gz v0eur.tar.gz v0soa.tar.gz v0sas.tar.gz; do
wget $BASE$F
done

A Guided Tour

The vmap0 data is split into four regions, as mentioned above: North America, Europe and North Asia, South America and Antarctica and SE Asia, Africa and Australasia. We will deal with how these four chunks of data can be combined to create one global dataset on a later page. Each dataset is divided into several directories which contain data like: Boundaries (bnd), elevation (elev), hydrography (hydro), population (pop), transport (trans) and vegitation (veg). These directories contain various files, each of which corresponds to a map layer. Here’s a list of the layers I have used in this project – directory/filename first, followed by a description and data type (point, line or area):

  • bnd/polbnda.aft – Political boundaries (area)
  • bnd/polbndl.lft – Political boundaries (line)
  • bnd/coastl.lft – Coastline (line)
  • bnd/oceansea.aft – Ocean/Sea (area)
  • elev/elevp.pft – Spot elevations (point)
  • hydro/watercrsl.lft – Rivers and streams (line)
  • hydro/inwatera.aft – Lakes and inland water (area)
  • pop/builtupa.aft – Built up areas (area)
  • trans/aerofacp.pft – Airports (point)
  • trans/railrdl.lft – Railway tracks (line)
  • trans/roadl.lft – Roads (line)
  • veg/swampa.aft – Swamp, marsh and bog (area)
  • veg/treesa.aft – Trees (area)

Viewing the Layers

The quickest way to view the data is to use ESRI’s ArcExplorer application, which can be downloaded here. ArcExplorer runs under Windows and Linux, but I describe the Windows version here.

Install and run ArcExplorer, select Theme -> Add Theme from the main menu and browse into the vmap0 data directory. Browse into the appropriate directory, as shown in figure 1, and select a file.

Selecting a data file to display in ArcExplorer
Figure 1: Selecting a data file to display in ArcExplorer

The data file will then be displayed. Figure 2 shows the European political boundaries. Note that you can change colours and suchlike by right clicking the “theme” in the panel on the left hand side of the map view and altering the properties as you see fit.

ArcExplorer with the European political boundary areas dataset displayed
Figure 2: ArcExplorer with the European political boundary areas dataset displayed

You can add more and more layers this way, which can be useful for getting to grips with the layout of the vmap0 dataset. One word of warning, though, is that if you display many layers at the same time you may find the map draws very slowly. I was forced to copy the vmap0 data files from my file server to the C: drive of my Windows machine to get reasonable performance.

The best way to get to grips with the data is to mess about with ArcExplorer until you know what data files you are interested in. After an introduction to raster datasets on the next page, I’ll talk about installing Mapserver and give details of how the vmap0 data files can be converted to a file format that’s supported by Mapserver.

A map generated using various vmap0 datasets including roads, trees, railways, international borders, inland water and rivers
Figure 3: A map generated using various vmap0 datasets including roads, trees, railways, international borders, inland water and rivers

Raster Data

Raster data is essentially made up of a two dimensional array of numbers. Figure 1 shows a typical raster dataset displayed as a greyscale image. Each number in the array is translated into a colour, where black is equivalent to 0 and white corresponds to the maximum value (255 perhaps). Image files and TV pictures are good examples of raster data.

A raster dataset with 14 columns and 11 rows viewed as a greyscale image
Figure 1: A raster dataset with 14 columns and 11 rows viewed as a greyscale image

Raster data formats of various varieties are used for information which isn’t really suited to vector representation. Height data is a good example of this. In order to represent the heights of areas with vector data we’d need to use contour lines, such as you might see on an Ordnance Survey map. Contours are a good vay of representing height data acurately, but they present problems when scaling maps and can confuse other features. Contours also need to be labeled in order to make any sense whatsoever, which isn’t easy to do in Mapserver.

Raster data can be displayed as a simple colour gradient on the map. Changes in height are immediately apparent to the user, as the human eye is very good at detecting even very tiny changes in colour. Height data is by no means the only type of data which lends itself to the raster format: temperature, polution levels, population and cloud cover also look very good as a colour gradient. Satellite data, which is generated in the form of high resolution image files, is another obvious candidate for storage in raster format.

Because raster data is displayed on the map as a colour gradient it seldom makes sense to display more than one raster layer at a time. This is why most mapping applications (Google Maps andMultimap for example) allow the user to view satellite data or other datasets, but never both (though Multimap has some very impressive new technology which allows the user to overlay A to Z data over satellite images).

NASA’s Globe Images

A very simple raster image of the entire earth is available for free download from NASA – it’s shown in figure 2.

The globe data file, shrunk to a more reasonable size
Figure 2: The globe data file, shrunk to a more reasonable size

Figure 2 shows a sized version of the data image, while figure 3 shows it full size. As you can see, its not really at a huge resolution, but it does prove useful for overview maps and suchlike.

A 1:1 sample from the raster file
Figure 3: A 1:1 sample from the raster file

GTOPO30: Global Topography with 30 Arc Second Resolution

The GTOPO30 dataset is made available by the US Geological Survey and is the highest resolution raster height dataset of the entire world that I could find without spending any money. You candownload GTOPO30 here. Using the GTOPO30 files with mapserver is much more complicated than using the Globe image mentioned above.

While the globe data is supplied as a JPEG image, GTOPO30 is distributed in binary files containing arrays of 16bit integers. This means that there is no colour information associated with the data, which gives a strange X-ray effect when displaying it for the first time in mapserver – as in figure 4.

Southern England with the GTOPO30 raster data and some vector data from vmap0 overlaid
Figure 4: Southern England with the GTOPO30 raster data and some vector data from vmap0 overlaid

A series of “classes” must be created, which associate height ranges in the data with colours (more on that later). This can be a bit hit-and-miss and has to be done by hand, which is very annoying. However, after some work I managed to get the data to display nicely – see figure 5.

The area around Las Vegas Nevada, with GTOPO30 data and a nicer colour scheme
Figure 5: The area around Las Vegas Nevada, with GTOPO30 data and a nicer colour scheme

There is more information on using raster data with mapserver and setting up the colour classes in a couple of pages time. The next page gives details of how to install and test Mapserver and the associated utilities.

Installation of Mapserver and Associated Libraries and Utilities

Before you start reading this page there’s something I should point out: This installation took me a very long time and I didn’t document every step I took. For this reason I can’t provide perfect step-by-step instructions on how to install Mapserver or the other applications and libraries I mention below. I have included as much handy information as I can, but in the end I wouldn’t recomend that anyone without some reasonable knowledge of installing things under Linux attempt this… well, by all means attempt it, but expect a bad headache!

As I say, I’ve tried to add as many links to useful sources of data as I can, but by far the best place to look for help is the Mapserver mailing list, which I’ve found very helpful.

Linux and Other Software You’ll Need Before You Start

I have installed Mapserver on my development server, Clive. Clive runs Fedora Core 2. Mapserver works on all Linux distributions, as far as I know, and the instructions I give here will probably work on other vintages of Fedora without any alterations… Maybe.

I use the Apache HTTP server and PHP 4. These were installed before I started playing with Mapserver. If you haven’t got them then I suggest you fetch the RPMs and install them now.

GDAL, OGDI and PROJ

Before you install Mapserver you’ll need to install these untilities.

The GDAL libraries provide a useful interface to various types of map data files and the included utilities ogr2ogr and ogrinfo are vital for working with vmap0. The most up to date versions can be downloaded in tar/gzip format from the project website. GDAL, in turn, requires a number of libraries, most of which can be downloaded in RPM format. OGDI is one of the most important of these; I used the RPMs for version 3.1.4 (ogdi-devel-3.1.4-mh1 and ogdi-3.1.4-mh1). You’ll also need the PROJlibraries (the RPMs I used were: proj-devel-4.4.9-mh1 and proj-4.4.9-mh1). Once you have OGDI et alinstalled you need to build and install GDAL with some special options:

tar -xzf gdal-1.2.5.tar.gz
cd gdal-1.2.5.tar.gz
./configure --with-ogdi
make
su
make install
ln -s /usr/local/lib/libgdal.so.1.7.0 /usr/lib/libgdal.so.1

Make sure you check the filenames for the final “ln” command. Once you have GDAL installed you should be able to use ogr2ogr and ogrinfo – more on this later – and you’re ready to compile Mapsever.

Mapserver

There are two flavours of Mapserver; a standalone CGI binary and a set of PHP libraries. To test that Mapserver is working before overcomplicating things, it’s best to install the standard CGI version first. I downloaded mapserver-4.4.1.tar.gz from the project website. Here’s how I built and installed the mapserv CGI application.

tar -xzf mapserver-4.4.1.tar.gz
cd mapserver-4.4.1
./configure --with-org --with-gdal --with-jpeg --with-proj
make
su
cp -f mapserv /var/www/cgi-bin/mapserv40

Note that the executable is renamed to mapserv40 so that the MapServer tutorial examples will work – for some reason that’s the name they use. The tutorials are the best way to check that Mapserver is up and running. Download them in a ZIP archive and unzip them to somewhere in your web servers document root (/var/www/html/mapserver/tutorial for example). The maps in the tutorial are generated live by the mapserv application, so if the tutorials work then mapserver is working.

Here’s some information on installing the PHP mapscript addon for mapserver…

First we need to recompile mapserver to support PHP:

make clean
./configure --with-ogr --with-gdal --with-jpeg --with-proj --with-php=/usr/include/php/
make
su
cp -f mapserv /var/www/cgi-bin/mapserv40
cp -f mapscript/php3/php_mapscript.so /usr/lib/php4/

Make sure you include the correct path to your PHP source. To install the source I used “apt-get install php-devel”, but you could use the RMP or download the source if you prefer.

To test that your installation has worked correctly, copy the code below to a new PHP file and access the file with your browser (this info was taken from the Mapserver HOWTO document):

<html>
<body><?php
if (PHP_OS == "WINNT" || PHP_OS == "WIN32")
{
dl("php_mapscript.dll");
}
else
{
dl("php_mapscript.so");
}
phpinfo();
?></body>
</html>

Somewhere in the middle of the nicely formatted page you should see a table with information on your mapserver version etc. You shouldn’t see any errors at the top of the page, especially ones saying that a shared object file could not be loaded.

The next page gives details of how to convert the vmap0 data to a format that mapserver can cope with. The pages thereafter deal with coding map files and using Mapserver to generate maps.

Data Conversion

Converting VPF Data to Shape Files

By this point you should have working installaions of mapserver and the GDAL utilities. Here are some instructions for converting the VPF format vmap0 data to ArcView shape files for use with MapServer. Mapserver supports many different file formats, can connect to GIS databases and, apparently, can even use the OGDI/GDAL libraries to read VPF data directly. I haven’t had any luck getting mapserver to work with VPF data though and I feel much more comfortable working with shape files, which are supported by most mapping tools.

You can use the ogrinfo utility to get a summary of the various datasets available for vmap0 North America, for example, as follows. Note that the path to the data on my machine is “/scratch/archive/vmap0/v0noa/vmaplv0/noamer”, the “gltp:/vrf” on the command line snippet below is prefixed to provide protocol information to the ogrinfo command.

[dan@clive dan]$ ogrinfo -summary -ro gltp:/vrf/scratch/archive/vmap0/v0noa/vmaplv0/noamerINFO: Open of `gltp:/vrf/scratch/archive/vmap0/v0noa/vmaplv0/noamer'
using driver `OGDI' successful.
1: libref@libref(*)_line (Line String)
2: libreft@libref(*)_text (Point)
3: tileref@tileref(*)_area (Polygon)
4: tilereft@tileref(*)_text (Point)
5: polbndp@bnd(*)_point (Point)
...snip...
50: cropa@veg(*)_area (Polygon)
51: grassa@veg(*)_area (Polygon)
52: swampa@veg(*)_area (Polygon)
53: treesa@veg(*)_area (Polygon)
54: tundraa@veg(*)_area (Polygon)

You can use the NIMA Muse VPF Importer to get more of an idea what the names mean. “polbndp@bnd(*)_area” is the political boundaries data. I converted this to shape files using ogr2ogr as shown in the following code snippet. Note that I placed all my map data files in a base data directory (/home/dan/mapserv/data) and created subdirectories for vmap0 and GTOPO30 under that. It would be a good idea for you to do similar; it doesn’t matter where you put the data directory, but you should organise all your data files within it in a sensible structure.

[dan@clive dan]$ ogr2ogr vmap0_noa_political_boundaries.shp gltp:/vrf/scratch/archive/vmap0/v0noa/vmaplv0/noamer 'polbnda@bnd(*)_area'

This extracts the data and places it in a shape file called “vmap0_eur_political_boundaries.shp”. Here’s how I converted a few datasets for europe (political boundaries, roads, built up areas, inland water, watercourses and coastline):

[dan@clive vmap0_all]$ ogrinfo -summary -ro gltp:/vrf/scratch/archive/vmap0/v0eur/vmaplv0/eurnasia
[dan@clive vmap0_all]$ ogr2ogr vmap0_eur_political_boundaries.shp gltp:/vrf/scratch/archive/vmap0/v0eur/vmaplv0/eurnasia 'polbnda@bnd(*)_area'
[dan@clive vmap0_all]$ ogr2ogr vmap0_eur_all_roads.shp gltp:/vrf/scratch/archive/vmap0/v0eur/vmaplv0/eurnasia 'roadl@trans(*)_line'
[dan@clive vmap0_all]$ ogr2ogr vmap0_eur_built_up_areas.shp gltp:/vrf/scratch/archive/vmap0/v0eur/vmaplv0/eurnasia 'builtupa@pop(*)_area'
[dan@clive vmap0_all]$ ogr2ogr vmap0_eur_inland_water.shp gltp:/vrf/scratch/archive/vmap0/v0eur/vmaplv0/eurnasia 'inwatera@hydro(*)_area'
[dan@clive vmap0_all]$ ogr2ogr vmap0_eur_watercourses.shp gltp:/vrf/scratch/archive/vmap0/v0eur/vmaplv0/eurnasia 'watrcrsl@hydro(*)_line'
[dan@clive vmap0_all]$ ogr2ogr vmap0_eur_coast.shp gltp:/vrf/scratch/archive/vmap0/v0eur/vmaplv0/eurnasia 'coastl@bnd(*)_line'
[dan@clive vmap0_all]$ ogr2ogr vmap0_eur_place_names.shp gltp:/vrf/scratch/archive/vmap0/v0eur/vmaplv0/rference 'placenam@placenam(*)_point'

IMPORTANT NOTE: ogr2ogr and ogrinfo only worked for me after I’d ensured that there were no capital letters in any file or directory name anywhere under my vmap0 dir (Dave Jarvis gives some clues on how to do this in his excellent Unix Swiss Army Knife article). I also needed to copy the “dht” and “lat” files from the “vmap0noa” directory into the “noamer” and “rference” directories (and into corresponding directories for the other three datasets: sas, soa and eur). Note also that when the output file exists already ogr2ogr throws an annoying and not very informative error similar to: “filenameis not a directory”.

After running ogr2ogr on various datasets I ended up with sets of files for North America (noa), South America, Antarctica and Africa (soa), Europe and North Asia (eur) and South East Asia and Austrilasia (sas). In order to create the world map I had to combine these. I did this by repeating the following commands for all of the datasets:

[dan@clive vmap0_all]$ ogr2ogr vmap0_all_coast.shp vmap0_eur_coast.shp -nln vmap0_all_coast vmap0_eur_coast
ogr2ogr -update -append vmap0_all_coast.shp vmap0_noa_coast.shp -nln vmap0_all_coast vmap0_noa_coast
ogr2ogr -update -append vmap0_all_coast.shp vmap0_soa_coast.shp -nln vmap0_all_coast vmap0_soa_coast
ogr2ogr -update -append vmap0_all_coast.shp vmap0_sas_coast.shp -nln vmap0_all_coast vmap0_sas_coast

The first call to ogr2ogr creates the new shape file and the successive calls append the data for the remaining three regions. As far as I can guess, the “-nln” switch stands for “New Layer Name”.

To increase the speed at which mapserver processes the resulting shape files, you can create a tree file using the shptree untility. This creates a tree structure (much like a 2D binary tree) which prevents mapserver having to query every shape in the file to find the few shapes which are visible. Shptree creates a set of *.qix files which are detected and loaded by mapserver automatcially. The following command can be used to create .qix files for all shape files in a directory – beware though, this might take some time.

[dan@clive vmap0_all]$ for F in `ls *.shp`; do shptree $F; done

GTOPO30 Raster Data

Preparing the GTOPO30 raster height data for use in Mapserver is much easier than messing about with VPF data. The first step is to download the tar/gzipped data files and unzip them. I downloaded them to a subdirectory of my mapserver data directory (/home/dan/mapserv/data/gtopo30).

[dan@clive dan]$ cd mapserv/gtopo30
[dan@clive gtopo30]$ wget -v ftp://edcftp.cr.usgs.gov/pub/data/gtopo30/global/*
[dan@clive gtopo30]$ for F in `ls *.gz`; do tar -xzf $F; done

This creates a directory full of .dem files. I converted these to lower case to save mucking about later on. I prefer lower case under Linux.

[dan@clive gtopo30]$ for F in `ls`; do mv $F `echo $F | tr '[A-Z]' '[a-z]'`; done

The next step is to create a shape file index of the .dem files. Each .dem file represents an area (or tile) of the total map and the shape file index links them together and provides a single point of entry for Mapserver. First I tried the following:

[dan@clive gtopo30]$ gdaltindex gtopo30.shp gtopo30/*.dem

But I found that that didn’t work. After much head scratching I finally worked out what the problem was: The “gdaltindex” program adds the names of the DEM files to the shape file exactly as they are specified on the command line. This doesn’t include any path information if you run “gdaltindex” from the same directory as the data. Therefore it’s best to run the command from your base data directory as follows.

[dan@clive data]$ gdaltindex gtopo30/gtopo30.shp gtopo30/*.dem

By this point you should have various vmap0 vector datasets and some GTOPO30 raster height data to play with. The rest of the article deals with using these datasets to create attractive, interactive maps with mapserver.

MapServer

Quick Intro

MapServer was originally developed at the University of Minnesota and is now a full blown open source project. It has been used by a huge number of companies to add interative mapping functionality to their websites. With only a very small amount of tinkering Mapserver allows the user to zoom and pan around a dynamic map. One example of a basic Mapserver application is the Winnipeg Restaurants website. Doing some more serious development and enhancing the user interface with JavaScript can produce some stunning results – a prime example being the King George Island GIS Project. There are many more examples of Mapserver applications in the Mapserver Gallery.

The list of possible applications for mapserver is endless. The obvious ones being basic mapping tasks like the examples above: displaying maps of an area, showing the branches of a particular shop or displaying weather or population data. It doesn’t take long, however, to come up with more exciting ideas, like on-line tracking of field engineers using a GPS unit and a mobile phone, route planning or tracking the progress of a mobile robot through a maze in real time.

MapServer CGI and Map File Basics

The best way to demonstrate anything is by example, so instead of waffling on about how to use Mapserver and PHP/Mapscript I have written eight simple example maps. Since I don’t have Mapserver installed on my web server (which is located in Texas and isn’t easy to install things on) I am running these examples on my development server (which is much slower, but is within easy reach in Berkshire). It’s possible that this machine will experience problems now and again, so if you find that any of the examples don’t work then send me an email.

The first six examples use the mapserver CGI and template HTML files to generate basic interactive maps. Follow the links below to view the examples. I recomend that you look at them in order…

1: A basic map of the world
2: Using a simple Mercator projection
3: Adding a scale bar and key
4: Layers and layer control
5: Simple symbols
6: Raster data

Enhancing MapServer Applications with PHP Map Script

If you want to start being a bit clever with your maps you may need to start using PHP. There are three ways to use PHP to generate maps: the first is to generate a set of parameters for the Mapserver CGI and the second is to use PHP Mapscript to configure the map as it is being drawn. The third way, which could well both the most powerful and the most complicated, is to use a PHP user interface to generate parameters for a PHP Mapscript application.

Generating parameters with PHP then creating the map using the CGI is useful because it allows you to divorce the hosting of the user interface and the map generation software. However, it also means that you sacrifice the ability to do things like adding features to the map dynamically.

Using PHP/Mapscript is a very powerful way to generate your maps. You can configure almost every aspect of the map file and data before it is displayed. The following two examples show some relatively basic things which simply can not be done using the CGI.

7: PHP Mapscript basics
8: PHP Mapscript and Javascript

Using PHP/Mapscript, however, forces you to host your user interface and GUI on the same server. This may not be a problem for most people, but there are reasons why it can be anoying:

1) Your webserver (in Texas) hasn’t got mapscript installed and you don’t want to host your map application on your development machine (in the UK). OK, that’s a bit flippant, but it’s likely that you’d want to host your website and mapserver on separate machines, even just for safety’s sake or to do load balancing.

2) You want to keep your GUI and map generation code separate, to prevent it becoming too messy.

3) You want to use multiple identical mapserver machines to perform the slow process of generating maps, but you want only one point of contact for the user. This is how people like Google Maps get such blinding speed from their map applications.

So, if you’re really serious about your mapping applicaion, you may want to consider using your PHP user interface code to construct parameters for a separate collection of PHP/Mapscript code. Though I suggest you start small and work your way up to this sort of thing.

Conclusions – Logical Genetics Maps

I hope this article has been useful to you. I’ve tried to address all of the issues which I have found it hard to deal with during the setup and use of Mapserver. If you find that I’ve missed something important or made a mistake somewhere then please drop me a line and let me know.

At the time of writing, I haven’t really finished my holiday tracking application – at least not to a point where I can release it to the world. I have learned a heck of a lot about maps, GIS and Mapserver though. Since I can’t link to the finished application I’ll have to make do with the following screenshots.

Here’s the map of the world. This is the first map which users see when they arrive at the page.

Map of the world
Figure 1: Map of the world

Figure 2 shows the user interface. The user can control the size of the map, zoom and pan using various buttons. There is also a reference map for jumping to other parts of the world.

User interface
Figure 2: User interface

The next figure shows many of the layers which are displayed when zoomed in. These all come from vmap0 and gtopo30, except for the place names, which are taken from various free sources.

A map showing various different layers
Figure 3: A map showing various different layers

The final figure shows the Isle of Arran. The yellow label and triangle are added at runtime using data stored in a mySQL database.

A map of the Isle of Arran.  The yellow triangle is created on the fly by mapscript
Figure 4: A map of the Isle of Arran. The yellow triangle is created on the fly by mapscript

One thought on “Open Source Maps – Data and Software

  1. Hi there,
    nice article.

    I’ve just found that the VPF urls have changed from geoengine.nima.mil to geoengine.nga.mil

    They probably change again sometime, but it would be “for the common good” if you updated the URLs in your article.

    cheers,
    Ian

Leave a Reply

Your email address will not be published. Required fields are marked *