Welcome to Spatial Horizons

earth

Spatial Horizons explores geographic technologies with the purpose of designing and creating our own mapping applications. Browse our articles and tutorials or read our where to start page for examples of what we do. Sign up for our RSS feed to receive all our latest updates.

We've taken some time off recently but look for Spatial Horizons to return better than ever in 2008.

hr

Recent Blog Posts

New Version Coming Soon

February 9th, 2008

Spatial Horizons was launched in 2006 to provide instruction and inspiration to readers interested in applications of geographic information systems (GIS). Our focus was to provide unique examples of geographic technologies in action. For example, we learned how to use C# to read location information from a GPS device. We also took advantage of Microsoft’s new game development platform, XNA, to demonstrate how to build more powerful mapping applications.

Update: In 2008, Spatial Horizons is currently on hiatus while we work on other projects. The future is uncertain but we hope to return in some form in 2009. Stay tuned…

OpenLayers (1) - 10 Minute Tutorial

December 16th, 2007

This post introduces OpenLayers as a easy way to embed dynamic maps in a web page. First-time visitors are encouraged to read our previous posts on setting up MapServer and CGI MapServer for background information.

OpenLayers is a javascript library for creating maps on a web page. In their own words,

OpenLayers is a pure JavaScript library for displaying map data in most modern web browsers, with no server-side dependencies. OpenLayers implements a (still-developing) JavaScript API for building rich web-based geographic applications, similar to the Google Maps and MSN Virtual Earth APIs, with one important difference — OpenLayers is Free Software, developed for and by the Open Source software community. - http://www.openlayers.org/

Setting up OpenLayers is incredibly easy if you want to display data from other existing sources on the web. See their Quick Tutorial page for lots of sample HTML showing how to add a basic map in a web page. In this tutorial, we will focus on how to create a map that uses our own data from MapServer.
Read the rest of this entry »

Using MapServer (3) - CGI MapServer

December 9th, 2007

This post is the third in a series on using MapServer. First-time visitors are encouraged to read part 1 to learn how to download and install MapServer on their computer. Additionally, the data layers used in this tutorial are available to download in this post.

We’ve already introduced MapServer and showed how to create a mapfile using GIS data. We will now introduce MapServer’s CGI functionality as a way to generate a map image. Later we will build on what we’ve learned to create a map using OpenLayers, a web mapping interface.

Introducing Mapserv.exe

At the heart of MapServer is a single file referred to as “mapserv”. With the MS4W package, it is a single executable found at C:\ms4w\Apache\cgi-bin\mapserv.exe. This file is the map production engine that uses a mapfile to generate a map image.

Mapserv.exe is usually accessed internally by MapServer-based packages such as ka-map or Mapscript. But it can also be called directly from a web browser as long as some required parameters are included.
Read the rest of this entry »

Sample Dataset - World Map

December 9th, 2007

A number of our posts have covered downloading and using GIS data but it should be more beneficial to readers if a single post contained all the instructions needed to acquire the data layers in each dataset. Our first such dataset, named “World Map”, has already been introduced but will be discussed in more depth here for the sake of new readers.

CGI MapServer Map
Read the rest of this entry »

Using MapServer (2) - Generating Map Tiles

November 14th, 2007

This post is the second in a series on using MapServer. First-time visitors are encouraged to read part 1 which details how to download, setup, and create a web mapping site using MapServer. Additionally, the topic of map tiles has already been introduced in a previous series.

Once the MapServer for Windows (MS4W) package with ka-Map is installed on your local machine, some new mapping functionality becomes available. One area that interests us is the ability to automatically generate a set of map tiles.

ka-Map Configuration

The first step in creating a set of map tiles is to configure ka-Map to point to a valid MapServer mapfile (see here for more on a mapfile). Navigate to this directory: C:\ms4w\apps\ka-map-1.0\include and open the file named config.php in any text editor.

This configuration file contains several parameters which you should be familiar with before creating our map tiles. We won’t change any of their values yet but it is important to understand what they do. First, on lines 73 and 74, the pixel size of each tile to be generated is defined:

$tileWidth = 256;
$tileHeight = 256;

Lines 106 through 110 define the most important parameters:

$aszGMap = array (
         'title' => 'GMap 75',
         'path' => '../../gmap/htdocs/gmap75.map',
         'scales' => array( 40000000, 25000000, 12000000, 
                                 7500000, 3000000, 1000000 ),
         'format' =>'PNG'
 );

Read the rest of this entry »

Using SharpMap (4)

November 7th, 2007

This post concludes our tutorial introducing SharpMap and how to use it in a mapping application. We were planning to explore it in some more depth by demonstrating some additional functionality, but we are working on another project that will be discussed in the near future. In short, SharpMap has tremendous potential as a lightweight component for adding mapping capabilities to desktop and web applications.

Our sample application’s source code is available to download below. It includes everything needed to compile and run the application using Visual C# Express. The SharpMap library, included in the download, is released under the GNU Lesser General Public License. For more information on that, see here.

SharpMap Demo Application

Download Source Code

Using SharpMap (3)

October 28th, 2007

Our third post in this series (part 1, part 2) on SharpMap continues the development of a basic mapping application programmed in C#. We will now add some more functionality to the program.

SharpMap with Coloring

Zooming By Percentages

The SharpMap.Map class has a Zoom property that stores the map’s current width in the units of the map. To understand this better, add this line of code to the RefreshMap function we’ve already created:

MessageBox.Show(_sharpMap.Zoom.ToString());

Read the rest of this entry »

Using SharpMap (2)

October 20th, 2007

Our previous post introduced SharpMap and how to use it in a C# program. We built a form and used a PictureBox control to display maps generated by SharpMap. We left off with a rather bland looking map of the world:

SharpMap Program

Adding Layer Styles

Adding colors to our countries layer is straightforward. In our form’s constructor, we simply define colors using the Style class:

countriesLayer.Style.Fill = Brushes.LightGreen;
countriesLayer.Style.EnableOutline = true;
countriesLayer.Style.Outline = Pens.DarkGreen;

We also switched the map’s background color:

_sharpMap.BackColor = Color.LightBlue;

Read the rest of this entry »

Using SharpMap (1)

October 14th, 2007

In our ongoing effort to explore various methods for developing mapping applications, we need to consider incorporating existing libraries instead of writing code ourselves. One such solution is SharpMap. SharpMap is an emerging open source mapping engine that provides functionality to access GIS data, such as shapefiles, and generate map images. In their own words,

SharpMap is an easy-to-use mapping library for use in web and desktop applications. It provides access to many types of GIS data, enables spatial querying of that data, and renders beautiful maps. The engine is written in C# and based on the .Net 2.0 framework. SharpMap is released under GNU Lesser General Public License. [quote source]

So let’s go ahead and program a simple mapping application in C# that uses SharpMap. As with our other tutorials, this example is rather primitive on purpose to highlight specifically how easy it use to use SharpMap. Readers are encouraged to use this tutorial as a basis for creating much richer applications.

Read the rest of this entry »

Using QGIS (5) - Export to MapServer

October 6th, 2007

Our last post for now on QGIS will cover an interesting feature added in the recent versions. A new “Export to MapServer Map” command creates a MapServer configuration file (simply called a “mapfile”) from an existing QGIS map. That mapfile can be used to then display the data on a website or use it in a desktop application. The desktop option is what we will take a look at because we will now have an easy way to create a mapfile that we can use with some of our MapServer/XNA tutorials we demonstrated in the past.

Python Installation

The Export to MapServer tool will only work if the Python programming language is installed on your computer. The latest version (2.5.1) of Python is required so we first need to download and install it here.

Open a QGIS Map

After the installation, go ahead and open a QGIS map. We will continue to use the world map project created in the previous posts. As a reminder, we have two layers in our map - a vector layer showing country outlines and a raster background image.

QGIS Map

Read the rest of this entry »