This site contains excerpts and examples of topics covered in the book. Available Now at Pragmatic Bookshelf!!
[View Contents] [Forum]
Here in Alaska we have over 130 volcanoes with more than 50 being active in about the last 250 years. Presently Mt. Redoubt is in an eruptive phase and has been since March 22. Ash from the volcano has fallen in a number of communities and areas throughout the state. A couple of weeks or so ago the reports from the Alaska Volcano Observatory indicated the ash was falling within 30 miles of the volcano. I decided to do a quick analysis to see what areas might be affected.
One of the hurdles in developing a QGIS plugin with Python is just getting the basics down. Getting the plugin setup so it is recognized by QGIS and properly adds it’s menu and toolbar items can be a bit of a chore, especially the first time.
To make the process easier, I put together a web tool to generate a plugin that can be used as a starting point. The tool creates a fully functional plugin that can be loaded in QGIS 1.x. The generated plugin contains an icon and a simple dialog with Ok and Cancel buttons.
In this example we are going to begin to build a standalone GIS application using Python and the QGIS libraries. We'll start simple by creating an application to load and display a shapefile. In later posts we'll enhance the application to provide some map tools and other features.
To build the application we need the following tools installed:
In our previous GMT examples we used a single command to create a simple globe and create an annotated map. In this example we will create a base map and then use the overlay feature of GMT to plot the location of volcanoes throughout the world.
The first step is to create the base map using pscoast:
pscoast -JN0/26 -R-180/180/-90/90 -W -G220/220/220 -S0/192/255 \ -N1 -B60g10 :."World Volcanoes": --PAPER_MEDIA=archA -K > world_volcanoes.eps
Sometimes the "out-of-the-box" GIS applications don't fulfill your need. While writing your own application isn't something to enter into lightly, sometimes it is the best solution.
A custom application might be the answer when you need:
The key to a successful custom application is to leverage the available toolkits and libraries---in other words let someone else do the hard work for you.
Some open source resources for writing your own applications are:
Eventually, most of us are interested in getting our GIS data from the desktop to the web. If you use Quantum GIS (QGIS) there are a couple of handy plugins/tools that allow you to do just that.
There are two ways to convert a QGIS project file to a MapServer map file:
If you are using a newer version of QGIS, you may find that the icons do not match those found in Desktop GIS. You can revert to the "classic" icons in newer versions of QGIS by going to Edit|Options, choosing the General tab, and then selecting "classic" from the Icon theme drop-down box.
If you want to work through the examples in Chapter 3. Working With Vector Data, the bird observation data can be downloaded here:
http://desktopgisbook.com/files/desktop_gis_birds.zip
For the backdrop, use the world mosiac raster which is available from the Data page.
Suppose you want to extract features from a vector layer to create a smaller subset. This can be very handy if you have a large dataset and need just a portion of it for your current project. If your data happens to be in one of the formats supported by OGR, you can use ogr2ogr to create a new layer.
First let's look at extracting by a simple bounding box. Say we want to pull Canada, United States, and Mexico from the world_borders shapefile. This can easily be done with a small bounding box that crosses each of the countries:
For this example, we’ll create a map of Alaska and annotate it. If you looked at the Simple Globe example you'll recall that the -R switch controls the extent of a GMT map. Alaska ranges from about 172 degrees east longitude to 130 degrees west. Using 360 degrees for the entire globe, this translates to a region extending from 172 degrees to 230 degrees. For the Alaska map we will use the Albers Equal Area Conic projection. Looking at the syntax for pscoast reveals that this requires the use of the -Jb switch. In this case, we use the lowercase “b” to indicate that we will specify the size of the map using a scale. First lets look at the command used to create the map:
pscoast -Jb-154/50/55/65/1:12000000 -R172/230/51/72 -B10g5/5g5 -W1p/0/0/0 \ -I1/2p/0/192/255 -I2/2p/0/192/255 -I3/1p/0/192/255 -I4/1p/0/192/255 \ -G220/220/220 -S0/192/255 -L210/54/54/1000 -P -N1/1p/0/0/0 -Dl >gmt_alaska_coast.eps
This looks like quite a complex command, but it’s really not too bad once you get past all the numbers and slashes.
Recent comments
11 weeks 1 day ago
12 weeks 16 hours ago
18 weeks 1 day ago
44 weeks 4 days ago
45 weeks 1 day ago
1 year 1 week ago
1 year 2 weeks ago
1 year 5 weeks ago
1 year 11 weeks ago
1 year 11 weeks ago