Skip to content

Getting started: WORKFLOW

nvkelso edited this page Jan 23, 2012 · 6 revisions

To generate a full set of GeoJSON from a shapefile we'd use OGR2OGR with a command:

ogr2ogr -f "GeoJSON" /tmp/world.geojson /tmp/world_borders.shp world_borders

But if you have a ton of features, it's better to rip out vector tiles that are in the standard Google Maps mercator tile pyramid scheme. Use TileStache.

If you instead want to subdivide your SHP into chunks based on different geographies, use the Split Layer By Attributes python ArcScript for ArcGIS.

Make sure you've added all frameworks to your path. Example:

export PATH=/Library/Frameworks/GDAL.framework/Programs:$PATH export PATH=/usr/local/bin/

Pay close attention to Users and Roles in PostreSQL (which are different than your general computer account login), the database foundation PostGIS sits on top of. It is persnickety. From the general Terminal shell, I ran:

createuser kelson Shall the new role be a superuser? (y/n) y

Where kelson is my computer account user name. That way my pg role and computer account are synched, which is what Postgres assumes.

This is the same as typing the following from the pgsql prompt:

CREATE ROLE kelson WITH CREATEDB CREATEROLE LOGIN;

Here's a good tutorial: http://www.postgresql.org/docs/8.1/interactive/tutorial-start.html

Make sure you have a database to store files into:

createdb postcarto -T template_postgis

NOTE: The -T "template" flag with "template_postgis" ensures the new DB has the PostGIS data structure.

====

We want to use a PostGIS command called shp2pgsql:

The correct import command format is:

shp2pgsql -c -s 900913 -W "latin1" /-MyGTprojects/redistricting/toDB/merc_released/m_state1.shx state1 postcarto | psql -d postcarto

Where -s 900913 is the spatial reference system (projection).

Where -W “latin1” is the character encoding of SHP files out of ArcMap.

The | psql -d postcarto pipes the results of the first command into the table.

We want to use a built in TileStache script called tileStache-seed.py. It requires a config file, layer flag, bounding box flag, extention type, and zooms.

Example:

tilestache-seed.py -c /-MyGTprojects/redistricting/tiles/dataTiles/config/zooms/zoom6to8_counties.config -l census_2010 -b 36.5 -75.1 39.5 -83.7 -e json 6
Clone this wiki locally