-
Notifications
You must be signed in to change notification settings - Fork 1
/
INSTALL
116 lines (79 loc) · 3.31 KB
/
INSTALL
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
TIGER Geocoder
2009/03/12 install instructions:
NOTE: You must have a functional version of shp2pgsql. See below.
Steps:
0. Create database
1. Install postgis into database
2. Load fuzzystrmatch contrib file into database
3. Load Tiger Data
4. Run psql -f create_geocode.sql YOURDB
Each of these steps is outlined in (somewhat) more detail below.
== Creating a database and installing postgis ==
This is really beyond the scope of this document, but
it would probably look something like this:
createdb -U postgres -O someuser -EUTF8 YOURDB
createlang -U postgres -d YOURDB plpgsql
psql -q -U someuser -f /usr/share/pgsql/contrib/lwpostgis.sql YOURDB
psql -q -U someuser -f /usr/share/pgsql/contrib/spatial_ref_sys.sql YOURDB
psql -q -U someuser -f /usr/share/pgsql/contrib/fuzzystrmatch.sql YOURDB
You should also enable constraint_exclusion in your postgresql.conf.
== Loading TIGER data ==
Get TIGER data from: http://www.census.gov/geo/www/tiger/tgrshp2008/tgrshp2008.html
At a bare minimum, you will need these files:
National:
tl_2008_us_state.zip
State:
tl_2008_XX_county.zip
tl_2008_XX_place.zip
County:
tl_2008_XXYYY_cousub.zip
tl_2008_XXYYY_faces.zip
tl_2008_XXYYY_featnames.zip
tl_2008_XXYYY_edges.zip
tl_2008_XXYYY_addr.zip
tl_2008_XXYYY_addrfn.zip
If you want better address normalization in areas you do not intend to geocode,
then it would probably behoove you to get the tl_2008_XX_place.zip for
all states.
There is a script included to load and prepare TIGER shapefiles.
***IT DOES NOT WORK WITH postgis 1.3.5. See below.****
./import/import_tiger_shps.sh
It assumes that you have kept the data in the same hierarchy that the
Census does.
For example (and one that will just work out of the box):
./TIGER2008/41_OREGON/41051_Multnomah_County/tl_2008_41051_edges.zip
You do not need to unzip them, the script will handle that. There are
a number of options, viewable by calling the script with -h.
The script requires shp2pgsql from postgis, however
the version that is included with 1.3.5 does not work
correctly. 1.3.3 is claimed to work. Not sure about 1.3.4. See:
http://code.google.com/p/postgis/issues/detail?id=99&can=1
As of right now, the script has only been tested with a (patched) 1.3.5
and TIGER 2008 data. The import is somewhat slow, as there are problems
with the dumpfiles generated by shp2psql, and we must use inserts.
(This could use some investigation. Hint. Hint.)
The script can also handle reprojections, if you specify an SRID *and*
have ogr2ogr installed.
== Installing the Geocoder ==
There are a series of functions that do the loading. All
of them are loaded by default if you run:
psql -f create_geocode.sql YOURDB
== Putting it all together ==
I use the following script in testing:
#!/bin/bash
(
dropdb -U postgres tiger || exit 1
createdb -U postgres -O username -EUTF8 tiger || exit 1
psql tiger -q -f /usr/share/pgsql/contrib/fuzzystrmatch.sql || exit 1
cp -f /dev/null log
POSTGIS="/usr/share/pgsql/contrib/lwpostgis_upgrade-64.sql
/usr/share/pgsql/contrib/postgis_comments.sql
/usr/share/pgsql/contrib/spatial_ref_sys.sql"
for i in ${POSTGIS}; do
psql tiger -q -f $i
done
./import/import_tiger_shps.sh -X -n '*state*'
./import/import_tiger_shps.sh -M
./import/import_tiger_shps.sh -I
psql -q -f create_geocode.sql tiger
) | tee log 2>&1