277 | | * http://wiki.openstreetmap.org/wiki/Contours |
| 277 | * http://wiki.openstreetmap.org/wiki/Contours#The_PostGIS_approach |
| 278 | |
| 279 | {{{ |
| 280 | apt-get install gdal-bin |
| 281 | mkdir ~/mapnik/srtm |
| 282 | wget http://mapnik-utils.googlecode.com/svn@170/sandbox/testing/hillshading/srtm_generate_hdr.sh |
| 283 | }}} |
| 284 | |
| 285 | Example for Haiti: |
| 286 | {{{ |
| 287 | wget |
| 288 | }}} |
| 289 | |
| 290 | Run this script: |
| 291 | {{{ |
| 292 | #!/bin/bash |
| 293 | PREP_TABLE="1" |
| 294 | for X in *.hgt.zip; do |
| 295 | yes | srtm_generate_hdr.sh $X |
| 296 | rm -f "${X%%.zip}" |
| 297 | |
| 298 | # Import 10m contours |
| 299 | rm -f "${X%%.hgt.zip}.shp" "${X%%.hgt.zip}.shx" "${X%%.hgt.zip}.dbf" |
| 300 | gdal_contour -i 10 -snodata 32767 -a height "${X%%.hgt.zip}.tif" "${X%%.hgt.zip}.shp" |
| 301 | [ "$PREP_TABLE" ] && shp2pgsql -p -I -g way "${X%%.hgt.zip}" contours | psql -q gis |
| 302 | shp2pgsql -a -g way "${X%%.hgt.zip}" contours | psql -q gis |
| 303 | |
| 304 | rm -f "${X%%.hgt.zip}.shp" "${X%%.hgt.zip}.shx" "${X%%.hgt.zip}.dbf" |
| 305 | rm -f "${X%%.hgt.zip}.bil" |
| 306 | rm -f "${X%%.hgt.zip}.hdr" |
| 307 | rm -f "${X%%.hgt.zip}.prj" |
| 308 | rm -f "${X%%.hgt.zip}.tif" |
| 309 | unset PREP_TABLE |
| 310 | done |
| 311 | }}} |
| 312 | |
| 313 | Configure Mapnik: |
| 314 | {{{ |
| 315 | vim ~/mapnik/osm.xml |
| 316 | <Style name="contours10"> |
| 317 | <Rule> |
| 318 | <MaxScaleDenominator>51185</MaxScaleDenominator> |
| 319 | <MinScaleDenominator>1599</MinScaleDenominator> |
| 320 | <LineSymbolizer> |
| 321 | <CssParameter name="stroke">#9cb197</CssParameter> |
| 322 | <CssParameter name="stroke-width">0.5</CssParameter> |
| 323 | </LineSymbolizer> |
| 324 | </Rule> |
| 325 | </Style> |
| 326 | <Style name="contours50"> |
| 327 | <Rule> |
| 328 | <MaxScaleDenominator>204741</MaxScaleDenominator> |
| 329 | <MinScaleDenominator>51185</MinScaleDenominator> |
| 330 | <LineSymbolizer> |
| 331 | <CssParameter name="stroke">#9cb197</CssParameter> |
| 332 | <CssParameter name="stroke-width">0.6</CssParameter> |
| 333 | </LineSymbolizer> |
| 334 | </Rule> |
| 335 | <Rule> |
| 336 | <MaxScaleDenominator>51185</MaxScaleDenominator> |
| 337 | <MinScaleDenominator>1599</MinScaleDenominator> |
| 338 | <LineSymbolizer> |
| 339 | <CssParameter name="stroke">#747b90</CssParameter> |
| 340 | <CssParameter name="stroke-width">0.6</CssParameter> |
| 341 | </LineSymbolizer> |
| 342 | </Rule> |
| 343 | </Style> |
| 344 | <Style name="contours100"> |
| 345 | <Rule> |
| 346 | <MaxScaleDenominator>409483</MaxScaleDenominator> |
| 347 | <MinScaleDenominator>204741</MinScaleDenominator> |
| 348 | <LineSymbolizer> |
| 349 | <CssParameter name="stroke">#9cb197</CssParameter> |
| 350 | <CssParameter name="stroke-width">0.7</CssParameter> |
| 351 | </LineSymbolizer> |
| 352 | </Rule> |
| 353 | <Rule> |
| 354 | <MaxScaleDenominator>204741</MaxScaleDenominator> |
| 355 | <MinScaleDenominator>51185</MinScaleDenominator> |
| 356 | <LineSymbolizer> |
| 357 | <CssParameter name="stroke">#747b90</CssParameter> |
| 358 | <CssParameter name="stroke-width">0.7</CssParameter> |
| 359 | </LineSymbolizer> |
| 360 | </Rule> |
| 361 | <Rule> |
| 362 | <MaxScaleDenominator>51185</MaxScaleDenominator> |
| 363 | <MinScaleDenominator>1599</MinScaleDenominator> |
| 364 | <LineSymbolizer> |
| 365 | <CssParameter name="stroke">#855d62</CssParameter> |
| 366 | <CssParameter name="stroke-width">0.7</CssParameter> |
| 367 | </LineSymbolizer> |
| 368 | </Rule> |
| 369 | </Style> |
| 370 | <Style name="contours-text50"> |
| 371 | <Rule> |
| 372 | <MaxScaleDenominator>51185</MaxScaleDenominator> |
| 373 | <MinScaleDenominator>1599</MinScaleDenominator> |
| 374 | <TextSymbolizer name="height" face_name="DejaVu Sans Book" size="8" fill="#747b90" halo_radius="1" placement="line" /> |
| 375 | </Rule> |
| 376 | </Style> |
| 377 | <Style name="contours-text100"> |
| 378 | <Rule> |
| 379 | <MaxScaleDenominator>102370</MaxScaleDenominator> |
| 380 | <MinScaleDenominator>51185</MinScaleDenominator> |
| 381 | <TextSymbolizer name="height" face_name="DejaVu Sans Book" size="8" fill="#747b90" halo_radius="1" placement="line" /> |
| 382 | </Rule> |
| 383 | <Rule> |
| 384 | <MaxScaleDenominator>51185</MaxScaleDenominator> |
| 385 | <MinScaleDenominator>1599</MinScaleDenominator> |
| 386 | <TextSymbolizer name="height" face_name="DejaVu Sans Book" size="8" fill="#855d62" halo_radius="1" placement="line" /> |
| 387 | </Rule> |
| 388 | </Style> |
| 389 | <Layer name="srtm_10" status="on" srs="+proj=latlong +datum=WGS84"> |
| 390 | <StyleName>contours10</StyleName> |
| 391 | <StyleName>contours-text10</StyleName> |
| 392 | <Datasource> |
| 393 | <Parameter name="type">postgis</Parameter> |
| 394 | <Parameter name="host"></Parameter> |
| 395 | <Parameter name="port"></Parameter> |
| 396 | <Parameter name="user"></Parameter> |
| 397 | <Parameter name="password"></Parameter> |
| 398 | <Parameter name="dbname">gis</Parameter> |
| 399 | <Parameter name="estimate_extent">false</Parameter> |
| 400 | <Parameter name="table">(select way,height from contours WHERE height::integer % 10 = 0 AND height::integer % 50 != 0 AND height::integer % 100 != 0) as "contours-10"</Parameter> |
| 401 | <Parameter name="extent">-180,-89.99,180,89.99</Parameter> |
| 402 | </Datasource> |
| 403 | </Layer> |
| 404 | <Layer name="srtm_50" status="on" srs="+proj=latlong +datum=WGS84"> |
| 405 | <StyleName>contours50</StyleName> |
| 406 | <StyleName>contours-text50</StyleName> |
| 407 | <Datasource> |
| 408 | <Parameter name="type">postgis</Parameter> |
| 409 | <Parameter name="host"></Parameter> |
| 410 | <Parameter name="port"></Parameter> |
| 411 | <Parameter name="user"></Parameter> |
| 412 | <Parameter name="password"></Parameter> |
| 413 | <Parameter name="dbname">gis</Parameter> |
| 414 | <Parameter name="estimate_extent">false</Parameter> |
| 415 | <Parameter name="table">(select way,height from contours WHERE height::integer % 50 = 0 AND height::integer % 100 != 0) as "contours-50"</Parameter> |
| 416 | <Parameter name="extent">-180,-89.99,180,89.99</Parameter> |
| 417 | </Datasource> |
| 418 | </Layer> |
| 419 | <Layer name="srtm_100" status="on" srs="+proj=latlong +datum=WGS84"> |
| 420 | <StyleName>contours100</StyleName> |
| 421 | <StyleName>contours-text100</StyleName> |
| 422 | <Datasource> |
| 423 | <Parameter name="type">postgis</Parameter> |
| 424 | <Parameter name="host"></Parameter> |
| 425 | <Parameter name="port"></Parameter> |
| 426 | <Parameter name="user"></Parameter> |
| 427 | <Parameter name="password"></Parameter> |
| 428 | <Parameter name="dbname">gis</Parameter> |
| 429 | <Parameter name="estimate_extent">false</Parameter> |
| 430 | <Parameter name="table">(select way,height from contours WHERE height::integer % 100 = 0) as "contours-100"</Parameter> |
| 431 | <Parameter name="extent">-180,-89.99,180,89.99</Parameter> |
| 432 | </Datasource> |
| 433 | </Layer> |
| 434 | }}} |