How We Do It: Making Shapefiles More Accessible with Open Source Tools
The CivicApps data catalog has a ton of great resources, many of which are shapefiles, a proprietary format from the Environmental Systems Research Institute (ESRI). While these formats are familiar to those who work in GIS and other mapping areas, they often present challenges to developers looking to use them for data visualization or other applications.
This article gives an overview on taking ESRI shapefiles and converting them to easy-to-use GeoJSON, while translating the state plane x & y coordinates to the more familiar lat/long combinations.
What you'll need:
- A shapefile encoded with state plane coordinates
- An installation of QGIS, an open-source GIS environment
Step 1: Find a dataset
Browse the CivicApps catalog (www.civicapps.org/datasets) and find a shapefile you’d like to use. For this example we’ll use the Portland metro area zip codes dataset, found here.
Step 2: Extract the archive
The ZIP file you’ll download will contain a number of files related to the ESRI format. One file of interest here is the metadata XML file, which contains a number of interesting details about the shape file.
Step 3: Open the shape file in QGIS
When you open QGIS, you’ll get a blank workspace. To open our shapefile, go to: Layer > Add Vector Layer in the toolbar.
Click “Browse” and select the zipcode_metro.shp file. This will open the shape file in QGIS.
Step 4: Convert to GeoJSON
Once you’ve got the shape file open, go to Layer > Save As... in the toolbar. Under “Format”, select “GeoJSON”. To convert the state plane coordinates to lat/long, click the “Layer CRS” drop down under “Encoding” and choose “Selected CRS”.
The CRS, or “coordinate reference system”, will be used to transform our state plane coordinates into lat/long pairs. To filter the options, type in “NAD83” (more info here) and select NAD83 under the Geographic Coordinates Systems group at the top of the “Coordinate Systems of the world” list.
Once all your selections have been made, hit ‘OK’ and your geoJSON will be saved!
Hopefully this short guide will help make government data more accessible to you, if you're unfamiliar with the world of GIS. Take a look at the CivicApps data catalog to see what's available, and enjoy your new access to geographical data!