OpenGeo: Open-source Web Mapping

In my previous Web Waypoints article (August 2012), I describe how to publish a web map using HTML and JavaScript coding, accessing the Google Maps API and Fusion Tables. As powerful as these web mapping tools and data storage mechanisms are, there’s a potential dark side to them: Google can deprecate them at any time (i.e., mark the software as obsolete; the disclaimer on Fusion Tables is that they are “experimental”).

A safer (and better) alternative is to use free, open-source web mapping software that has a solid development foundation via academia or well-funded, nonprofit organizations. A good example of the latter is OpenGeo, a provider of open-source GIS software that includes the PostGIS spatial database and the GeoServer web mapping server system. OpenGeo is the geospatial division of OpenPlans, a non-profit technology-based advocacy organization established by Mark Gorton, creator of the LimeWire internet file-sharing software. He’s also the principal of Lime Brokerage, LLC—the money flow behind much of the advocacy.

The OpenGeo technology “stack” is composed of three levels: the spatial database, the web server “middleware,” and the user interface (Figure 1). These are all open-source products that interconnect via web protocols I have discussed in previous articles.

In this article I’ll outline the steps of installing and using OpenGeo to web-publish Esri shapefiles. For those of you with a basic aversion to learning new programming languages like JavaScript, OpenGeo is your ticket. It’s all point and click—although you can beef it up with custom JavaScripting if you want.

To begin, download the OpenGeo installation software for your particular operating system at http://opengeo.org/products/suite/register. Although you can purchase support services for OpenGeo, the download is 100% free and even comes with 30 days of initial support. The installation process is well documented in the download package—just click on the default options at every step.

Once you install the OpenGeo software, double-click on its desktop icon (Figure 2) to bring up the OpenGeo Suite Dashboard (Figure 3).

There are many configuration options available, but for now we’re going to use OpenGeo out of the box to import and publish an Esri shapefile. Although shapefiles are a buggy-whip format in the world of GIS, they are ubiquitous and producible from certain CAD software as well as any capable GIS package (whether Esri or not). An excellent open-source GIS package is Quantum GIS (www.qgis.org) that can read AutoCAD DXF files and export them as shapefiles.
 

Importing a Shapefile into GeoServer


GeoServer is the web mapping server software that is the main workhorse for OpenGeo. It ingests one or more formats of GIS data and serves it out in various web mapping service standards. Out of the box, GeoServer is a fully-functioning web map server. But if you decide to whip up some JavaScripting on top of GeoServer, you can come up with your own customized web map viewer that rivals commercial offerings. This time around, however, we’re going to take a shortcut and use OpenGeo’s general purpose GIS data viewer, GeoExplorer.

You first need to start the OpenGeo web mapping engine by clicking on the Start button on the dashboard (Figure 4). Once the moving parts of OpenGeo are running, open GeoExplorer by clicking on its dashboard icon (Figure 5).

GeoExplorer displays a conventional GIS viewer in an internet browser (Google Chrome or Mozilla Firefox are the best browser choices for GeoExplorer, although the preview version of Internet Explorer 10 seems to work fine as well). Layers are in the left-side table of contents and various tool buttons are located above the map viewing frame (Figure 6).

Normally, layers displayable in GeoExplorer must be loaded into GeoServer first. However, we’re going to shortcut this process and use the Upload layers option (Figure 7), which permits direct importing of data in either shapefile or GeoTIFF format through GeoExplorer. Because the import data must be in a single file, shapefile component sub-files need to be put into a zip file archive. As well, all the sub-files as created by an Esri ArcGIS Export to Shapefile command must be in the zip archive: the .shp, .shx, .dbf, and .prj files and also the .sbn and .sbx index files (that normally are only maintained by ArcGIS). Leave out any of these, and you’ll get an error message. The Upload layers dialogue is in Figure 8.

The only required input is the shapefile zip archive. When you select the Upload button and, as long as your zip archive contains all the necessary files, an Uploading your data progress bar will appear (Figure 9). Once the shapefile data begins processing, the progress bar will disappear.

Data from the shapefile loading process is imported into the PostGIS spatial database that is a component of the OpenGeo software. It takes a little while for the shapefile to import into PostGIS, and there aren’t any messages that announce when this process is complete. For the example shapefile I used (~43,000 parcels in the City of Boulder, Colorado), the import processing took about two minutes.

To add the shapefile data as a layer to GeoExplorer (it would be nice if GeoExplorer did this automatically, but after all, this is free software), you need to now select the Add layers button (Figure 10).

While the import processing has completed, you’ll see the dialogue frame in Figure 11.

The title of the layer is taken from the .shp shapefile name. This can be changed, as we’ll see shortly. Click on the Boulder_Parcels layer to select it, then click on the Add layers button at the bottom of the window. Because it’s the only layer we’re going to add at this point, click on Done, and the map displays as Figure 12.

It’s a pretty map, if you like green opaque parcel polygons. You can change various properties of any layer by right-clicking its name in the layers frame. The GeoExplorer documentation, accessible from the OpenGeo dashboard, is an excellent reference for all the operations and settings you can make to Geo-Explorer layers.
 

Adding More Layers


The default basemap that appears in GeoExplorer is MapQuest’s Open StreetMap (http://developer.mapquest.com/web/products/open/tools/guide#osm). It’s fine, except there’s no aerial imagery. To display either Google or Microsoft Bing imagery, select the Add layers option again (Figure 13), and choose the appropriate source. For Google, the choices appear as in Figure 14.

Any combination of the layers can be selected and added to the Layer contents frame by clicking Add layers, then selecting Done as in Figures 10 and 11.

Changing the Boulder parcel symbology to non-filled, red-outlined polygons and referencing it to the Google Hybrid layer results in the map in Figure 15.

Clicking the Identify menu button from the top menu bar will bring up information on the selected feature, as in Figure 16.

Customizing GeoExplorer so that attributes that are themselves links (like the Hyperlink field in the attribute list) is certainly possible but outside the scope of this article. Be assured that GeoExplorer can be tweaked to your specifications, but it does involve some deeper programming than what we’ve covered to date.

One thing you will notice is that over time the map display magically speeds up. The GeoServer map server is configured by default to build “tile caches”—pre-rendered images of web mapping services. Caches are analogous to screenshots: They are map snapshots taken at specified scales, cut into 256 x 256 pixel tiles for fast display. In this way, the map server doesn’t have to re-compute the vector overlay layers.

Tile caching is the secret to fast web map displays. The downside is that any changes to any layer (e.g., new subdivisions, parcel splits, etc.) necessitate re-creating the tile cache for that particular map area. Each time you view a GeoExplorer map area, a tile cache is created on the fly, betting on the chance that you’ll probably display that particular combination of scaled layers again.

Because we’re in a web services environment, you can bring in layers from other web map servers, such as the Public Land Survey System layers from BLM at  http://www.geocommunicator.gov/wmsconnector/com.esri.wms.Esrimap?ServiceName=BLM_MAP_PLSS . Just enter the http://... URL when you choose the Add a New Server layer choice (Figure 17).

You can edit your own GeoServer map layers (that is, the shapefile and other vector layers you import, not the basemap imagery layers or layers from other servers). Editing, among other operations requires a login authentication (Figure 18). The default login credentials are User = “admin”; Password = “geoserver”.

When your map is all layered up and styled to your tastes, you can save it and then publish it via the Map toolbar option (Figure 19). Publishing a map creates a URL that can be pasted into a browser address bar or that can be inserted as an HTML iframe element, as explained in the last Web Waypoints article.
 

Putting It on the Web

At the end of the day you’ve got a nice GIS viewer for shapefile data … but it’s accessible only from your local computer system. Here’s where the power of the internet cloud can be harnessed for you. As an aside, a true cloud instance is not just renting a web-accessible application and data storage. If you have to pay for a “cloud service” even when you’re not using it, that’s not a cloud. Cloud services should be just like your toaster: It consumes electricity and adds to your bill only when it’s being used.
Two options to serve your OpenGeo software and data in the cloud are available through Amazon Web Services’ Elastic Compute Cloud (EC2). Option one is to obtain an Amazon EC2 Windows or Linux instance and then install the OpenGeo software on it, much as you did on your local computer. This is a good experience for DIY types.

Option two involves subscribing to OpenGeo’s Cloud Edition that provides a ready-to-go OpenGeo dashboard available over the internet. No muss, no fuss—just sign up with your credit card. There is a full spectrum of pricing options, ranging from 13¢ per hour up to $1,150 per month (with a $1000 setup fee). The low-end pricing is great for experimentation and small shops, while the upper pricing tiers are suitable for corporations (or hosting your data for client access). Details are available at http://opengeo.org/products/suite/cloud/

OpenGeo also has excellent tutorials and training videos on the web (the latter at YouTube). Getting and using your mapping data on the web has never been easier.

Assistance in the preparation of this article was provided by OpenGeo, at http://opengeo.org/.

Rudy Stricklan, RLS, GISP is a member of the editorial board of this magazine and principal consultant with Mapping Automation, LLC. 


» Back to our January 2013 Issue

Website design and hosting provided by 270net Technologies in Frederick, Maryland.