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:

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 »
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 »
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.

Read the rest of this entry »

Geographic data can be separated into 2 types: vector and raster data. We’ve already introduced vector data (points, lines, and polygons) in our previous posts on QGIS. We now need to briefly discuss raster images and how to use them.
In terms of GIS, raster images (often referred to as just “rasters”) are pixel-based images of places on the earth. They are often captured from cameras on satellites or airplanes and the pictures can be taken in color, black and white, or include infrared wavelengths.
Read the rest of this entry »
This post continues a look at the basics of GIS using the mapping program Quantum GIS (QGIS). We’ve already covered how to install and use QGIS in a previous post. In addition, we also introduced shapefiles, including how to download and use them in QGIS. Before moving on to another topic, it is worth demonstrating another example of downloading a shapefile and setting up it’s symbology in QGIS.
Data Download
Shapefiles generally come in three types – points, lines, and polygons. Our previous examples have used line shapefiles but this time we will download a polygon shapefile. For example, we downloaded a countries of the world shapefile found here that looks like this when loaded into QGIS:

Read the rest of this entry »
Our first post on using QGIS introduced the software along with how to download shapefiles, one of the most common GIS formats. Now we will explore how to use QGIS to make a better looking map.
Data Download
This time we are going to download a roads shapefile from the State of Michigan’s Center for Geographic Information. They offer downloads by county so go ahead and select a county and then chose to download the “MI Geographic Transportation” zip file. This zip file contains 3 shapefiles (named stroads, allroads, and railroad) but we will just use the “allroads” shapefile. For our example, we used the roads shapefile from the Washtenaw County transportation file.
Roads Symbology
Open QGIS and add the allroads shapefile.

Read the rest of this entry »
We’ve briefly mentioned QGIS before but it is worth a more in-depth look now. Some of our upcoming projects will require downloading and using GIS data so QGIS is a great program for viewing the data. In their own words,
Quantum GIS (QGIS) is a user friendly Open Source Geographic Information System (GIS) that runs on Linux, Unix, Mac OSX, and Windows. QGIS supports vector, raster, and database formats. QGIS is licensed under the GNU General Public License. QGIS lets you browse and create map data on your computer. It supports many common spatial data formats (e.g. ESRI ShapeFile, geotiff).
Let’s quickly describe how to install QGIS, download data, and make a basic map. This post is primarily for those who have not used GIS software or data before.
QGIS Installation
Download the current release (v0.8.1) of QGIS here and run the installation program. They recommend installing it to a file path without spaces (e.g. C:\QGIS) to enable GRASS functionality which we may use later on.
Running QGIS opens a blank map:

Read the rest of this entry »
The last three posts discussed map tiles in some detail but without getting into programming. First, we described terminology surrounding map tiles. Then we setup a sample TileMap from an image of the world. And finally, we covered some “tile math” examples. Now we will wrap everything up by developing a mapping program that uses map tiles.
The program we created was built off one of our previous projects (see World Mapper parts 1,2,3) and, as always, the XNA framework. This project turned out to be much more complex than any of our previous programs so it would be impossible to cover all the source code in detail. Instead, this post will provide an overview of the program’s structure and then provide the source code for you to download and explore on your own.
Read the rest of this entry »
Before using our Tile Map we created in the last post, a quick discussion on “tile math” might be helpful. More specifically, we need be able to easily switch between tile coordinates and real-world coordinates to create a complete tile mapping program.
We will use this map tile as an example:

Read the rest of this entry »
Our last post introduced the concept of map tiles and the benefits for using them in a desktop application. Before using map tiles in XNA, we need to create a sample “TileMap”. Normally, tile maps would be created automatically using some GIS or Mapping program. To gain a better understanding though, we will manually create a set of map tiles using this world map that we have used before:

The original image from the Wikimedia Commons is over 8 MB in size so we can cut it up in a graphics program and create each tile individually. All tiles will be the same size – 800 pixels wide by 400 pixels tall. Our sample TileMap will have 3 TileSets each a different scale (also referred to as “zoom levels”). They will be numbered from 0 to 2 with 0 being the farthest from ground level.
Read the rest of this entry »