Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 259 lines (202 sloc) 15.411 kb
21e72e3 Added shell script for importing shapefiles to postgis
Nathaniel Vaughn Kelso authored
1 #!/bin/sh
2
3 #
4 # README
5 #
d6aedd6 @nvkelso import scripts of included data
nvkelso authored
6 # There are two parts: (1) city and admin labels and (2) airports and roads.
21e72e3 Added shell script for importing shapefiles to postgis
Nathaniel Vaughn Kelso authored
7 # Both are imported into PostGIS to make rendering performant.
8 #
9
10 OGR2OGR=`which ogr2ogr`
11 SHP2PGSQL=`which shp2pgsql`
12 PSQL=`which psql`
13
14 ROOT=$1
15 MERC="${ROOT}/900913"
16 GOOG="+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0.0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs +over"
17
18 #
19 # CITY LABELS
20 #
21 # need to be imported to PostGIS for performance gains
22 #
23
24
25 shp2pgsql -dID -W utf8 mapnik/shp/labels/africa-labels-z10.shp africa_labels_z10
26 shp2pgsql -dID -W utf8 mapnik/shp/labels/africa-labels-z4.shp africa_labels_z4
27 shp2pgsql -dID -W utf8 mapnik/shp/labels/africa-labels-z5.shp africa_labels_z5
28 shp2pgsql -dID -W utf8 mapnik/shp/labels/africa-labels-z6.shp africa_labels_z6
29 shp2pgsql -dID -W utf8 mapnik/shp/labels/africa-labels-z7.shp africa_labels_z7
30 shp2pgsql -dID -W utf8 mapnik/shp/labels/africa-labels-z8.shp africa_labels_z8
31 shp2pgsql -dID -W utf8 mapnik/shp/labels/africa-labels-z9.shp africa_labels_z9
32
33 exit
34
35 shp2pgsql -dID -W utf8 mapnik/shp/labels/africa-points-z10.shp africa_points_z10
36 shp2pgsql -dID -W utf8 mapnik/shp/labels/africa-points-z4.shp africa_points_z4
37 shp2pgsql -dID -W utf8 mapnik/shp/labels/africa-points-z5.shp africa_points_z5
38 shp2pgsql -dID -W utf8 mapnik/shp/labels/africa-points-z6.shp africa_points_z6
39 shp2pgsql -dID -W utf8 mapnik/shp/labels/africa-points-z7.shp africa_points_z7
40 shp2pgsql -dID -W utf8 mapnik/shp/labels/africa-points-z8.shp africa_points_z8
41 shp2pgsql -dID -W utf8 mapnik/shp/labels/africa-points-z9.shp africa_points_z9
42
43 exit
44
45 shp2pgsql -dID -W utf8 mapnik/shp/labels/africa-registrations-z10.shp africa_registrations_z10
46 shp2pgsql -dID -W utf8 mapnik/shp/labels/africa-registrations-z4.shp africa_registrations_z4
47 shp2pgsql -dID -W utf8 mapnik/shp/labels/africa-registrations-z5.shp africa_registrations_z5
48 shp2pgsql -dID -W utf8 mapnik/shp/labels/africa-registrations-z6.shp africa_registrations_z6
49 shp2pgsql -dID -W utf8 mapnik/shp/labels/africa-registrations-z7.shp africa_registrations_z7
50 shp2pgsql -dID -W utf8 mapnik/shp/labels/africa-registrations-z8.shp africa_registrations_z8
51 shp2pgsql -dID -W utf8 mapnik/shp/labels/africa-registrations-z9.shp africa_registrations_z9
52
53 exit
54
55 shp2pgsql -dID -W utf8 mapnik/shp/labels/asia-labels-z10.shp asia_labels_z10
56 shp2pgsql -dID -W utf8 mapnik/shp/labels/asia-labels-z4.shp asia_labels_z4
57 shp2pgsql -dID -W utf8 mapnik/shp/labels/asia-labels-z5.shp asia_labels_z5
58 shp2pgsql -dID -W utf8 mapnik/shp/labels/asia-labels-z6.shp asia_labels_z6
59 shp2pgsql -dID -W utf8 mapnik/shp/labels/asia-labels-z7.shp asia_labels_z7
60 shp2pgsql -dID -W utf8 mapnik/shp/labels/asia-labels-z8.shp asia_labels_z8
61 shp2pgsql -dID -W utf8 mapnik/shp/labels/asia-labels-z9.shp asia_labels_z9
62
63 exit
64
65 shp2pgsql -dID -W utf8 mapnik/shp/labels/asia-points-z10.shp asia_points_z10
66 shp2pgsql -dID -W utf8 mapnik/shp/labels/asia-points-z4.shp asia_points_z4
67 shp2pgsql -dID -W utf8 mapnik/shp/labels/asia-points-z5.shp asia_points_z5
68 shp2pgsql -dID -W utf8 mapnik/shp/labels/asia-points-z6.shp asia_points_z6
69 shp2pgsql -dID -W utf8 mapnik/shp/labels/asia-points-z7.shp asia_points_z7
70 shp2pgsql -dID -W utf8 mapnik/shp/labels/asia-points-z8.shp asia_points_z8
71 shp2pgsql -dID -W utf8 mapnik/shp/labels/asia-points-z9.shp asia_points_z9
72
73 exit
74
75 shp2pgsql -dID -W utf8 mapnik/shp/labels/asia-registrations-z10.shp asia_registrations_z10
76 shp2pgsql -dID -W utf8 mapnik/shp/labels/asia-registrations-z4.shp asia_registrations_z4
77 shp2pgsql -dID -W utf8 mapnik/shp/labels/asia-registrations-z5.shp asia_registrations_z5
78 shp2pgsql -dID -W utf8 mapnik/shp/labels/asia-registrations-z6.shp asia_registrations_z6
79 shp2pgsql -dID -W utf8 mapnik/shp/labels/asia-registrations-z7.shp asia_registrations_z7
80 shp2pgsql -dID -W utf8 mapnik/shp/labels/asia-registrations-z8.shp asia_registrations_z8
81 shp2pgsql -dID -W utf8 mapnik/shp/labels/asia-registrations-z9.shp asia_registrations_z9
82
83 exit
84
85 shp2pgsql -dID -W utf8 mapnik/shp/labels/australia-new-zealand-labels-z10.shp australia_new_zealand_labels_z10
86 shp2pgsql -dID -W utf8 mapnik/shp/labels/australia-new-zealand-labels-z4.shp australia_new_zealand_labels_z4
87 shp2pgsql -dID -W utf8 mapnik/shp/labels/australia-new-zealand-labels-z5.shp australia_new_zealand_labels_z5
88 shp2pgsql -dID -W utf8 mapnik/shp/labels/australia-new-zealand-labels-z6.shp australia_new_zealand_labels_z6
89 shp2pgsql -dID -W utf8 mapnik/shp/labels/australia-new-zealand-labels-z7.shp australia_new_zealand_labels_z7
90 shp2pgsql -dID -W utf8 mapnik/shp/labels/australia-new-zealand-labels-z8.shp australia_new_zealand_labels_z8
91 shp2pgsql -dID -W utf8 mapnik/shp/labels/australia-new-zealand-labels-z9.shp australia_new_zealand_labels_z9
92
93 exit
94
95 shp2pgsql -dID -W utf8 mapnik/shp/labels/australia-new-zealand-points-z10.shp australia_new_zealand_points_z10
96 shp2pgsql -dID -W utf8 mapnik/shp/labels/australia-new-zealand-points-z4.shp australia_new_zealand_points_z4
97 shp2pgsql -dID -W utf8 mapnik/shp/labels/australia-new-zealand-points-z5.shp australia_new_zealand_points_z5
98 shp2pgsql -dID -W utf8 mapnik/shp/labels/australia-new-zealand-points-z6.shp australia_new_zealand_points_z6
99 shp2pgsql -dID -W utf8 mapnik/shp/labels/australia-new-zealand-points-z7.shp australia_new_zealand_points_z7
100 shp2pgsql -dID -W utf8 mapnik/shp/labels/australia-new-zealand-points-z8.shp australia_new_zealand_points_z8
101 shp2pgsql -dID -W utf8 mapnik/shp/labels/australia-new-zealand-points-z9.shp australia_new_zealand_points_z9
102
103 exit
104
105 shp2pgsql -dID -W utf8 mapnik/shp/labels/australia-new-zealand-registrations-z10.shp australia_new_zealand_registrations_z10
106 shp2pgsql -dID -W utf8 mapnik/shp/labels/australia-new-zealand-registrations-z4.shp australia_new_zealand_registrations_z4
107 shp2pgsql -dID -W utf8 mapnik/shp/labels/australia-new-zealand-registrations-z5.shp australia_new_zealand_registrations_z5
108 shp2pgsql -dID -W utf8 mapnik/shp/labels/australia-new-zealand-registrations-z6.shp australia_new_zealand_registrations_z6
109 shp2pgsql -dID -W utf8 mapnik/shp/labels/australia-new-zealand-registrations-z7.shp australia_new_zealand_registrations_z7
110 shp2pgsql -dID -W utf8 mapnik/shp/labels/australia-new-zealand-registrations-z8.shp australia_new_zealand_registrations_z8
111 shp2pgsql -dID -W utf8 mapnik/shp/labels/australia-new-zealand-registrations-z9.shp australia_new_zealand_registrations_z9
112
113 exit
114
115 shp2pgsql -dID -W utf8 mapnik/shp/labels/europe-labels-z4.shp europe_labels_z4
116 shp2pgsql -dID -W utf8 mapnik/shp/labels/europe-labels-z5.shp europe_labels_z5
117 shp2pgsql -dID -W utf8 mapnik/shp/labels/europe-labels-z6.shp europe_labels_z6
118 shp2pgsql -dID -W utf8 mapnik/shp/labels/europe-labels-z7.shp europe_labels_z7
119 shp2pgsql -dID -W utf8 mapnik/shp/labels/europe-labels-z8.shp europe_labels_z8
120 shp2pgsql -dID -W utf8 mapnik/shp/labels/europe-labels-z9.shp europe_labels_z9
121
122 exit
123
124 shp2pgsql -dID -W utf8 mapnik/shp/labels/europe-points-z4.shp europe_points_z4
125 shp2pgsql -dID -W utf8 mapnik/shp/labels/europe-points-z5.shp europe_points_z5
126 shp2pgsql -dID -W utf8 mapnik/shp/labels/europe-points-z6.shp europe_points_z6
127 shp2pgsql -dID -W utf8 mapnik/shp/labels/europe-points-z7.shp europe_points_z7
128 shp2pgsql -dID -W utf8 mapnik/shp/labels/europe-points-z8.shp europe_points_z8
129 shp2pgsql -dID -W utf8 mapnik/shp/labels/europe-points-z9.shp europe_points_z9
130
131 exit
132
133 shp2pgsql -dID -W utf8 mapnik/shp/labels/europe-registrations-z4.shp europe_registrations_z4
134 shp2pgsql -dID -W utf8 mapnik/shp/labels/europe-registrations-z5.shp europe_registrations_z5
135 shp2pgsql -dID -W utf8 mapnik/shp/labels/europe-registrations-z6.shp europe_registrations_z6
136 shp2pgsql -dID -W utf8 mapnik/shp/labels/europe-registrations-z7.shp europe_registrations_z7
137 shp2pgsql -dID -W utf8 mapnik/shp/labels/europe-registrations-z8.shp europe_registrations_z8
138 shp2pgsql -dID -W utf8 mapnik/shp/labels/europe-registrations-z9.shp europe_registrations_z9
139
140 exit
141
142 shp2pgsql -dID -W utf8 mapnik/shp/labels/north-america-labels-z10.shp north_america_labels_z10 # utf8: Invalid or incomplete multibyte or wide character ERROR: missing data for column "geonameid", CONTEXT: COPY north_america_labels_z10, line 295: "07 8 "
143 shp2pgsql -dID -W utf8 mapnik/shp/labels/north-america-labels-z4.shp north_america_labels_z4
144 shp2pgsql -dID -W utf8 mapnik/shp/labels/north-america-labels-z5.shp north_america_labels_z5
145 shp2pgsql -dID -W utf8 mapnik/shp/labels/north-america-labels-z6.shp north_america_labels_z6
6deba09 @nvkelso more SHP to PostGIS wrangling
nvkelso authored
146 shp2pgsql -dID -W utf8 mapnik/shp/labels/north-america-labels-z7.shp north_america_labels_z7 # oops?
21e72e3 Added shell script for importing shapefiles to postgis
Nathaniel Vaughn Kelso authored
147 shp2pgsql -dID -W utf8 mapnik/shp/labels/north-america-labels-z8.shp north_america_labels_z8 # utf8: Invalid or incomplete multibyte or wide character ERROR: missing data for column "geonameid", CONTEXT: COPY north_america_labels_z8, line 270: "07 8 "
148 shp2pgsql -dID -W utf8 mapnik/shp/labels/north-america-labels-z9.shp north_america_labels_z9 # utf8: Invalid or incomplete multibyte or wide character ERROR: missing data for column "geonameid". CONTEXT: COPY north_america_labels_z9, line 276: "07 8 "
149
150 exit
151
152 shp2pgsql -dID -W utf8 mapnik/shp/labels/north-america-points-z10.shp north_america_points_z10 # ERROR: missing data for column "asciiname", CONTEXT: COPY north_america_points_z10, line 295: "8 "
153 shp2pgsql -dID -W utf8 mapnik/shp/labels/north-america-points-z4.shp north_america_points_z4
154 shp2pgsql -dID -W utf8 mapnik/shp/labels/north-america-points-z5.shp north_america_points_z5
155 shp2pgsql -dID -W utf8 mapnik/shp/labels/north-america-points-z6.shp north_america_points_z6
6deba09 @nvkelso more SHP to PostGIS wrangling
nvkelso authored
156 shp2pgsql -dID -W utf8 mapnik/shp/labels/north-america-points-z7.shp north_america_points_z7 # oops?
21e72e3 Added shell script for importing shapefiles to postgis
Nathaniel Vaughn Kelso authored
157 shp2pgsql -dID -W utf8 mapnik/shp/labels/north-america-points-z8.shp north_america_points_z8 # ERROR: missing data for column "asciiname", CONTEXT: COPY north_america_points_z8, line 270: "8 "
158 shp2pgsql -dID -W utf8 mapnik/shp/labels/north-america-points-z9.shp north_america_points_z9 # ERROR: missing data for column "asciiname", CONTEXT: COPY north_america_points_z9, line 276: "8 "
159
160 exit
161
162 shp2pgsql -dID -W utf8 mapnik/shp/labels/north-america-registrations-z10.shp north_america_registrations_z10
163 shp2pgsql -dID -W utf8 mapnik/shp/labels/north-america-registrations-z4.shp north_america_registrations_z4
164 shp2pgsql -dID -W utf8 mapnik/shp/labels/north-america-registrations-z5.shp north_america_registrations_z5
165 shp2pgsql -dID -W utf8 mapnik/shp/labels/north-america-registrations-z6.shp north_america_registrations_z6
166 shp2pgsql -dID -W utf8 mapnik/shp/labels/north-america-registrations-z7.shp north_america_registrations_z7
167 shp2pgsql -dID -W utf8 mapnik/shp/labels/north-america-registrations-z8.shp north_america_registrations_z8
168 shp2pgsql -dID -W utf8 mapnik/shp/labels/north-america-registrations-z9.shp north_america_registrations_z9
169
170 exit
171
172 shp2pgsql -dID -W utf8 mapnik/shp/labels/south-america-labels-z10.shp south_america_labels_z10
173 shp2pgsql -dID -W utf8 mapnik/shp/labels/south-america-labels-z4.shp south_america_labels_z4
174 shp2pgsql -dID -W utf8 mapnik/shp/labels/south-america-labels-z5.shp south_america_labels_z5
175 shp2pgsql -dID -W utf8 mapnik/shp/labels/south-america-labels-z6.shp south_america_labels_z6
176 shp2pgsql -dID -W utf8 mapnik/shp/labels/south-america-labels-z7.shp south_america_labels_z7
177 shp2pgsql -dID -W utf8 mapnik/shp/labels/south-america-labels-z8.shp south_america_labels_z8
178 shp2pgsql -dID -W utf8 mapnik/shp/labels/south-america-labels-z9.shp south_america_labels_z9
179
180 exit
181
182 shp2pgsql -dID -W utf8 mapnik/shp/labels/south-america-points-z10.shp south_america_points_z10
183 shp2pgsql -dID -W utf8 mapnik/shp/labels/south-america-points-z4.shp south_america_points_z4
184 shp2pgsql -dID -W utf8 mapnik/shp/labels/south-america-points-z5.shp south_america_points_z5
185 shp2pgsql -dID -W utf8 mapnik/shp/labels/south-america-points-z6.shp south_america_points_z6
186 shp2pgsql -dID -W utf8 mapnik/shp/labels/south-america-points-z7.shp south_america_points_z7
187 shp2pgsql -dID -W utf8 mapnik/shp/labels/south-america-points-z8.shp south_america_points_z8
188 shp2pgsql -dID -W utf8 mapnik/shp/labels/south-america-points-z9.shp south_america_points_z9
189
190 exit
191
192 shp2pgsql -dID -W utf8 mapnik/shp/labels/south-america-registrations-z10.shp south_america_registrations_z10
193 shp2pgsql -dID -W utf8 mapnik/shp/labels/south-america-registrations-z4.shp south_america_registrations_z4
194 shp2pgsql -dID -W utf8 mapnik/shp/labels/south-america-registrations-z5.shp south_america_registrations_z5
195 shp2pgsql -dID -W utf8 mapnik/shp/labels/south-america-registrations-z6.shp south_america_registrations_z6
196 shp2pgsql -dID -W utf8 mapnik/shp/labels/south-america-registrations-z7.shp south_america_registrations_z7
197 shp2pgsql -dID -W utf8 mapnik/shp/labels/south-america-registrations-z8.shp south_america_registrations_z8
198 shp2pgsql -dID -W utf8 mapnik/shp/labels/south-america-registrations-z9.shp south_america_registrations_z9
199
200 exit
201
6deba09 @nvkelso more SHP to PostGIS wrangling
nvkelso authored
202 #
203 # MISSING NATURAL EARTH THEMES
204 #
205
21e72e3 Added shell script for importing shapefiles to postgis
Nathaniel Vaughn Kelso authored
206 shp2pgsql -dID -W Windows-1252 mapnik/shp/ne_10m_admin_0_boundary_lines_land.shp ne_10m_admin_0_boundary_lines_land
6deba09 @nvkelso more SHP to PostGIS wrangling
nvkelso authored
207 #shp2pgsql -dID -W Windows-1252 mapnik/shp/admin_0_countries_110m-points.shp admin_0_countries_110m_points
21e72e3 Added shell script for importing shapefiles to postgis
Nathaniel Vaughn Kelso authored
208 shp2pgsql -dID -W Windows-1252 mapnik/shp/continents.shp continents
209
6deba09 @nvkelso more SHP to PostGIS wrangling
nvkelso authored
210 exit
211
21e72e3 Added shell script for importing shapefiles to postgis
Nathaniel Vaughn Kelso authored
212 #
213 # ROADS
214 #
6deba09 @nvkelso more SHP to PostGIS wrangling
nvkelso authored
215 # Note: The UPPERCASE column names in the SHP's DBF are converted to lowercase in PostGIS conversion
21e72e3 Added shell script for importing shapefiles to postgis
Nathaniel Vaughn Kelso authored
216 #
217
218 mkdir -p mapnik/shp/roads_merc/
219 rm -f mapnik/shp/roads_merc/*
220
221 for SHP in `ls -a mapnik/shp/roads/*.shp`
222 do
223 DIR=`dirname ${SHP}`
224 BASE=`basename ${SHP}`
225
226 TABLE=`perl -e '$ARGV[0] =~ /^((?:\d+)m)_(.*)\.shp$/; print "$2_$1";' ${BASE}`
227 # TABLE=`echo ${BASE} | awk '{split($0, parts, "."); print parts[1]}'`
228
229 echo "[${TABLE}] reproject"
230
231 ${OGR2OGR} -f "ESRI Shapefile" -t_srs ${GOOG} ${MERC}/900913_${BASE} ${DIR}/${BASE}
232
233 echo "[${TABLE}] prepare sql"
234
235 ${SHP2PGSQL} -s 900913 -W WINDOWS-1252 -c -I ${MERC}/900913_${BASE} ${TABLE} > ${MERC}/900913_${TABLE}.sql
236
237 echo "[${TABLE}] import sql"
238
239 ${PSQL} -U naturalearth < ${MERC}/900913_${TABLE}.sql
240
241 done
242
243 shp2pgsql -dID -W Windows-1252 mapnik/shp/roads/z6_europe.shp roads_z6_europe
244 shp2pgsql -dID -W Windows-1252 mapnik/shp/roads/z6_global_extra.shp roads_z6_global_extra
245 shp2pgsql -dID -W Windows-1252 mapnik/shp/roads/z6_global.shp roads_z6_global
246 shp2pgsql -dID -W Windows-1252 mapnik/shp/roads/z6_north_america.shp roads_z6_north_america
247 shp2pgsql -dID -W Windows-1252 mapnik/shp/roads/z7_europe_extra.shp roads_z7_europe_extra
248 shp2pgsql -dID -W Windows-1252 mapnik/shp/roads/z7_europe.shp roads_z7_europe
249 shp2pgsql -dID -W Windows-1252 mapnik/shp/roads/z7_global_extra.shp roads_z7_global_extra
250 shp2pgsql -dID -W Windows-1252 mapnik/shp/roads/z7_global.shp roads_z7_global
251 shp2pgsql -dID -W Windows-1252 mapnik/shp/roads/z7_north_america_extra.shp roads_z7_north_america_extra
252 shp2pgsql -dID -W Windows-1252 mapnik/shp/roads/z7_north_america.shp roads_z7_north_america
253 shp2pgsql -dID -W Windows-1252 mapnik/shp/roads/z8_europe_extra.shp roads_z8_europe_extra
254 shp2pgsql -dID -W Windows-1252 mapnik/shp/roads/z8_europe.shp roads_z8_europe
255 shp2pgsql -dID -W Windows-1252 mapnik/shp/roads/z8_global_extra.shp roads_z8_global_extra
256 shp2pgsql -dID -W Windows-1252 mapnik/shp/roads/z8_global.shp roads_z8_global
257 shp2pgsql -dID -W Windows-1252 mapnik/shp/roads/z8_north_america_extra.shp roads_z8_north_america_extra
258 shp2pgsql -dID -W Windows-1252 mapnik/shp/roads/z8_north_america.shp roads_z8_north_america
Something went wrong with that request. Please try again.