Tag: Google Maps

How to geocode a single address in QGIS

Since the last time I wrote about how to use BatchGeocode.com to perform pseudo-geocoding tasks in QGIS, there have been considerable improvements in the multi-platform, free, and open source GIS software. Now, geocoding (turning addresses into coordinates) is more automatic, albeit difficult to setup. (Okay, this has been around June 2009 and I just found out about it in October 2010.)

Once you install all the components, you’ll never have to do this again.

This method can only geocode one address at a time, but it will geocode all of the addresses into a single shapefile.

  1. Download QGIS.
  2. Download and install Python SetupTools. This includes the easy_install function that will download a necessary Python script, simplejson. On Mac you will have to use the Terminal (Applications>Utilities). Email me if you run into problems.
  3. Install simplejson. In the command line (Terminal for Mac; in Windows press Start>Run>”cmd”>Enter), type “easy_install simplejson”.
  4. Download the GeoCode plugin by Alessandro Pasotti via QGIS>Plugins>Fetch Python Plugins. You may have to load additional repositories to see it.
  5. Install geopy. In the command line (like step 3), type “easy_install geopy”.
  6. Specify your project’s projection in File>Project Properties.
  7. Get a Google Maps API key and tell the GeoCode plugin about it (QGIS>Plugins>GeoCode>Settings). You will need a Google account. If you don’t have your own domain name, you can just enter “google.com” when it asks for your domain.
  8. Geocode your first address by clicking on Plugins>GeoCode>Geocode. Type the full address (e.g. 121 N LaSalle Street, Chicago, IL for City Hall).
  9. The geocoded address will then appear in your Layers list as its own shapefile. All addresses geocoded (or reverse geocoded) in this project will appear in the same layer (therefore same attribute table).

Once you install all the components, you’ll never have to do this again. Geocoding will be available each and every time you use QGIS in the future on that workstation.

Tips

  • When you’re done geocoding,  save your results as a shapefile (right click the layer and click “Save as shapefile”). Twice I’ve lost my results after saving the project and quitting QGIS. When I reopened the project, the results layer was still listed, but contained no data.
  • Add a “name” column to the GeoCoding Plugin Results layer’s attribute table (toggle editing first). You can then type in the name of the building or destination at the address you geocoded. Edit the layer’s properties to have that name appear as a label for the point.

A map I made with QGIS showing three geocoded points of interest in Chicago. Data from City of Chicago’s GIS team.

 

Urban data page updated

Like any good website owner and author, I track statistics (or analytics as people like to call them now). The most important information the reports tell me is how people found my site: either through keyword searches, or links from related webpages.

Recently, a visitor came across my site because of a search for “amtrak routes gis.” I suspect they were looking for shapefiles they could load into Geographic Information System software containing Amtrak routes and stations. My blog showed up on the second results page in Google and they came to my post, “Why Amtrak’s not on time,” about the factors that influence the passenger rail company’s timeliness. The page doesn’t have what the visitor wants.

I decided to update my page, “Find urban data,” to aid future visitors. Also, if one person is looking for this information, it’s likely that others want it, too. I found the information, “amtrak routes gis,” in two places and in two formats.

First, the United States Department of Transportation’s Bureau of Transportation Statistics publishes national data in the “National Transportation Atlas.” You can find a shapefile with Amtrak stations. For Amtrak routes you must download the railway network shapefiles and then filter the information for the attributes that describe Amtrak.

The second source is an interactive KML file (more about KML) that you can load into Google Earth, view in Google Maps, or manipulate in another KML-compatible application.

Google Maps, the dynamic GIS system

Earlier this year, Google Maps added a feature to the common maps interface that allows users to identify problems* with map data or presentation. Click on the “Report A Problem” link in the lower right corner of the current map view. Then drag the marker on top of the error, categorize it, then write a description of the problem.

I reported several problems soon after the feature was released. I checked up on the results of one problem I reported. The situation was the lakefront multi-use path along Lake Michigan in Chicago, Illinois. The screenshots below show the map before I reported the problem and the repaired map.

With this addition, Google Maps seems to be encroaching on the territory of Open Street Map (OSM) that uses ONLY public domain (not the same as free) and user-contributed data. But the data users contribute to Google Maps (in the form of reporting problems on the map) become the property of Google and its data providers.

From the OSM Wiki, “The copyright of the whole data set is scattered among all contributors. Some contributors release their contributions to the public domain.” Readers interested in learning more about maps in the public domain should read this Guardian article about the UK’s Ordnance Survey heavy grip on its data.

Disclaimer: I felt prompted to write this post because James Fee on his blog often (1st) writes (2nd) about the (low) quality of the data Google puts in its Maps.

*Users have long been able to report problems, but never in such an easy way or one that tracks reports and notifies the user when Google fixes the error.

Google Maps and Earth is the poor man’s GIS

For over four years, Google’s geography products have become the most popular geographic information systems on the Earth (no, the earth). Google is now as much a platform of GIS for computers and users as ESRI, the number one GIS software maker.

To continue its corporate goal of organizing the world’s information, Google has made sure to also organize the world’s (and other realms) geographic information.

Google’s free tools and products manipulate, map, reproduce and analyze geographic information:

  • Maps – the simplest source of satellite imagery for the public, although Microsoft’s TerraServer was probably first
  • Street View
  • Transit – including travel directions for trips on Transit
  • Ocean
  • Earth desktop software – includes Moon, Mars, Sky
  • My Maps
  • Yellow pages-style business listings
  • Driving and Walking Directions – including automobile traffic overlay
  • Keyhole Markup Language (KML) – a file format based on XML that allows for the easy sharing and portability of data about locations. I wrote about it here.
  • Maps API – this allows developers to include maps in their own applications and websites as well as build features on top of maps

These applications now allow anyone in the world with an internet connection* and a computer to start thinking about the world and neighborhood in which they live in terms of space, distance, the environment, land use, and most important of all the relationships between real life places and these greater themes. But not only will these instruments influence the thinking of individuals and the groups to which they belong, but they will give people tools to create.

What have people created with Google’s GIS tools?

I created a map that shows the locations of open grated metal bridges on bikeways (featured in the bike map) in Chicago. This is important to bicyclists because open grated metal bridges can be hazardous to them, especially those with high centers of gravity or narrow tires on their bikes. Bicyclists will most often encounter these bridges on trips into and out of the Central Business District. This map will help bicyclists find routes that avoid these bridges. Precipitation exacerbates the danger, especially if it’s actively raining, or snow isn’t melting.

UPDATE 12-03-10: I was looking for information on an upcoming Chicago Cyclocross meet and I found a great example of using the tools Google has created for everyone. See a screenshot of the map below:

I’m posting this image to show how easy it is to create a map that tells a story. The story here is a guide on how to be a participant or spectator at the meet. It points out places where people can park, cannot park, and where the restrooms are in relation to parking or the race course. See the full map.

What have you created? Leave a comment below.

Evolution of Google’s GIS toolbox

I believe that Google will continue to expand its array of GIS-related applications, and also expand their existing ones. I would like to see them create new connections between the applications they’ve already created. For example:

  • Google can mimic the attribute table essential in desktop GIS software (like ESRI’s ArcGIS, qGIS, or GRASS) by integrating their Docs web application with My Maps. I want to save my information in a Google Docs spreadsheet (either inputted directly online or uploaded from my computer), then create a custom map and assign a location to each of the records in my spreadsheet. Then, using tools shared between Docs and My Maps, I can automate the creation of colored points and lines for the records based on categories or numbers in my spreadsheet, much like the classification and symbology tools of desktop GIS software. For example, on my “open grated metal bridges” custom map discussed above, I want to create a spreadsheet with a column that has a yes or no value to the question, “Is the bridge treated?” All records with “yes” will have green dots, and all “no” values will have blue dots.
  • The reverse situation could also be made possible by an integration between My Maps and Google Docs. Let’s say I’m a clerk at my church and I need to group the congregants into geographically close clusters for purposes of assigning community service work. I’ve inputted all of their addresses into My Maps and added a point for every house. There’re only 40 houses on the map and I can see see about 5 clusters (to keep it simple I won’t introduce arithmetic means of finding clusters). I use a selection lasso in My Maps and select the points in my first cluster. Using a new Classify function I label these points part of Cluster 1 and color them purple – I also assign Cluster 1 to work at the nearest park. I continue for the remaining four clusters, assigning each cluster to help clean a different park. Once I’ve completed grouping the houses, I tell My Maps to generate for me a spreadsheet that lists the names and phone numbers and clean up time for all the congregants. Now I can quickly call everyone in Cluster 1 and give them their community service assignment which is convenient to where they live.
  • Google should open up its many data layers. Google has many data layers in its table of contents: They recently added real estate data, but they also have the locations of transit stations and bus stops (including timetables and route information), the addresses and phone numbers of businesses (like the Yellow Pages), as well as terrain in some cases and bike trails in others. If the data in these layers were open, map users could perform some basic analysis like counting the number of check cashing businesses within 1 mile for a study of banking behavior in low-income neighborhoods. Or a map users could find the gain in elevation on a bike trail over 4 miles to determine their ride’s difficulty. Another map user could use the transit information to calculate the level of bus service in a neighborhood by counting the number of stops available and the number of buses scheduled.

I’ll have to figure out a way Google can extract revenue from these features if I want to convince Google to produce them, but sometimes the company builds products and features before it figures out how to make money.

Converting shapefiles and KML files

Google Earth Pro is a slightly more advanced version than the free edition of the popular satellite imagery application (okay, it does way more, but many people just use that feature). One major additional feature it includes is the ability to import GIS shapefiles and display their features on top of the imagery, including terrain. It’s useful to have your data as KML (Keyhole Markup Language) because KML (or KMZ) is easier to share and Google Earth standard edition is free. But then again, it’s useful to have your KML files as shapefiles because proper GIS software is more powerful at analyzing data. Also, someone might ask you for your data in shapefile format (but they could easily follow these instructions).

Good data management requires options. Options mean your data won’t be locked into a proprietary format. Data want to be free! Read on for ways to convert your KML and shapefile data:

Converting KML files to shapefiles

Like Google Earth Pro, Quantum GIS (QGIS) can convert KML or KMZ to shapefile, and best of all – it doesn’t cost $400 per year (it’s free!). QGIS is a cross-platform application meaning it will run on Windows, Mac OS X, and Linux.

Use QGIS to convert a KML or KMZ file to shapefile:

  1. Click on Layer > Add Vector Layer
  2. Find your KML or KMZ file.
  3. Right-click your new layer and click “Save as shapefile.”

Zonums provides online conversion tools. Or, use ArcGIS and this plugin to convert KML files to shapefiles.

Converting shapefiles to KML files

The freeware Shp2kml 2.o (Windows only) from Zonums will convert shapefiles to KML files. Want some free, interesting data to try it out? Check my ever expanding repository.

ESRI’s ArcGIS can convert KML files to shapefiles using this plugin and then import the shapefile as a layer onto your map.

Creating KML files online

As I described in this post, BatchGecode will generate a KML file for you by inputting a list of addresses and names. Additionally, Google Earth (part of the rising Google GIS platform) creates KML files. Google’s My Maps feature also allows you to generate KML files (for sharing or download) by clicking and drawing points and lines on a map and inviting you to describe the features you create. Use this to get a map of your church congregation, or a map of people who voted for your candidate.

GeoCommons Finder lets you upload geodata in many formats, save it to your profile, and then download it into multiple formats. You can upload a shapefile (.shp) and its accompany files (shx, dbf, and prj), verify that it read your data correctly,

More choices for converting

Additional software with conversion capabilities:

  • MapWindow (another free software choice; Windows only) – An alternative to QuantumGIS and ArcGIS.
  • ExpertGPS (Windows only, not free) – Ideal for GPS device owners, or for researchers using GPS devices in projects. But it can convert the GPS and shapefile data into KML, shapefiles, or a spreadsheet, amongst other functions.
  • Zonums, creator of the standalone Shp2kml software converter, now offers many online tools for KML users, including one that reverses the conversion and exports shapefiles from KML files. I found the link on FreeGeographyTools.com.
  • OpenGeo Suite – Commercial software with non-profit licenses.
  • uDig – Free GIS software, but I haven’t had good experiences with it on my computers.

GeoCommunity has a good article, with screenshots, on how some of these programs work.

Need to work with General Transit Feed Spec (GTFS) data?