See an example at whatsmydistrict.org.
brew install postgres
brew install postgis
Clone this repository. The rest of the commands should happen in the directory containing this project.
vagrant plugin install vagrant-berkshelf
vagrant plugin install vagrant-omnibus
vagrant up
vagrant ssh
cd WhatsMyDistrict
sudo bundle install
psql -U postgres
create database districts;
\q
psql -U postgres -d districts < sql/wmd.sql
foreman start
bundle
puma
to start the server at localhost:9292.For a new postgresql install in OS X:
mkdir -p ~/Library/LaunchAgents
cp /usr/local/Cellar/postgresql/9.2.1/homebrew.mxcl.postgresql.plist ~/Library/LaunchAgents/
launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
initdb /usr/local/var/postgres -E utf8
pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start
See also Postgres.app.
createdb -p 5432 -h localhost districts
psql -p 5432 -h localhost -d districts -f /usr/local/share/postgis/postgis.sql
and psql -p 5432 -h localhost -d districts -f /usr/local/share/postgis/spatial_ref_sys.sql
-- thanks to PostGres - PostGIS on OS X Lion.sudo apt-get install postgresql-9.1 postgresql-9.1-postgis postgis libpq
bundle install
$ sudo -u postgres psql
# \password
sorandomwow
sorandomwow
# create database districts;
# \q
sudo -u postgres psql -U postgres -d districts -f `pg_config --sharedir`/contrib/postgis-*/postgis.sql`
sudo -u postgres psql -U postgres -d districts -f `pg_config --sharedir`/contrib/postgis-*/spatial_ref_sys.sql
psql -U postgres -d districts < sql/wmd.sql
cp dotenv.sample .env
foreman start
Remember to either set relevant values in .env
file or to set ENV values.
Run shp2pgsql -c -D -s 4269 -I shapefile.shp tablename > filename.sql
. For example:
$ shp2pgsql -c -D -s 4269 -I VotingPrecinct.shp voting > VotingPrecinct.sql
Shapefile type: Polygon
Postgis type: MULTIPOLYGON[2]
Another example:
~/Downloads/PostOffice
% shp2pgsql -c -D -s 4269 -I PostOffice.shp post_office > PostOffice.sql
Shapefile type: Point
Postgis type: POINT[2]
psql -d database -f file.sql
, for example psql -p 5432 -h localhost -d districts -f VotingPrecinct.sql
.