A Personal Map of NYC


Since moving to New York I've been working to collect a series of running and biking routes to outline the city. It's good motivation to explore new parts of town, and a good excuse to play with GIS software.  Here's how to quickly assemble a custom map for yourself using GRASS GIS, a free open-source GIS application (https://grass.osgeo.org/).

Getting Started with GRASS GIS

As a base layer for my map (and mostly because it's a cool dataset), I started my map with the NYC PLUTO dataset, which is a geospatial dataset of every building in New York City.

If you're not familiar with GRASS, you can load it as follows:

  1. Launch GRASS
  2. Specify the working directory
  3. Create a new GRASS location -- give it a name and then specify the map projection by reading the projection from a WKT. pjrf file, and then specify the file MNMapPLUTO.prj
  4. Start a GRASS session
  5. Use v.in.ogr (File > Import Vector Data) and then select the file MNMapPLUTO.shp
  6. Import it with the default settings
  7. After the import is complete, in the Layer Manager, right click the new layer and choose "Zoom to Selected Maps"

Importing GPX track into GRASS GIS

The GRASS function v.in.lines imports lists of coordinates as vector lines. There's probably a way to import GPX files directly, but this is pretty fool-proof.

A quick python script can will convert GPX files to a pipe-delimited list of coordinates.

Project Date: 2016
Technologies: Grass GIS


import sys
with open(sys.argv[1]) as f:
    for line in f:
        if (line.find("lat")>0):
            print lon+"|"+lat

Execute it against a file and capture the output by calling py gpx_to_list.py my_run.gpx > my_run.txt. Write a quick bash script to run it against a list of files.

Once you've converted any files you want to import, bring them into GRASS GIS using v.in.lines.  All you need to specify is the input file name and the output layer name.

Cleaning Up the Map

In the layer properties menu (right-click a layer) you can customize things like layer fill and stroke for polygons, or line weight, color, and style for the vector lines.