Giter Club home page Giter Club logo

terrain-classic's Introduction

Terrain Classic

World-wide CartoCSS port of Stamen's classic terrain style.

UPDATE: As of 2023 this code is not longer used to generate Terrain tiles. Stamen's Terrain style has been updated to use vector tiles and is now hosted on Stadia Maps. Learn more: https://stadiamaps.com/stamen/

Stamen's original Terrain style was developed in 2011 as part of Stamen's Citytracking initiative, funded by the Knight Foundation. The old repository can be found here, for historical interest.

The original Terrain style only covered the United States. As part of another Knight Foundation grant in 2015, we expanded Terrain to cover the entire world. The Knight grant also funded prototyping for some totally-different new terrain styles, so to avoid confusion we called this reboot of the old style "Terrain Classic."

Terrain screenshot

Most of the development process for Terrain Classic was based on the toner-carto repo.

Developing

Prerequisites

  • PostgreSQL
  • PostGIS @2.2.0
  • Node.js --version 0.10*
  • GDAL
  • TileMill 1@master (this includes the latest Mapnik): github.com/mapbox/tilemill
  • Imposm 3, which includes dependencies of its own: go, leveldb, and protobuf.

*NOTE: The Node Version Manager script is helpful if you are using a more recent version of Node than 0.10 (which is fairly likely). This is important as TileMill 1@master will only run on Node --version 0.10.

On OS X, installation with Homebrew looks like this:

brew install postgis gdal node go leveldb protobuf pv

# follow instructions to start postgresql

mkdir -p /tmp/imposm
cd /tmp/imposm
export GOPATH=`pwd`
git clone https://github.com/omniscale/imposm3 src/imposm3
go get imposm3
go install imposm3

# bin/imposm3 is your new binary; either add $GOPATH/bin to your PATH or copy
# it to /usr/local/bin (or similar)

Terrain Classic Itself

  • Clone this repo
  • Run make link to sym-link the project into your TileMill project directory
  • Run make db/shared to fetch and transform Natural Earth and OSM coastline data
  • Run make db/CA (or similar; seePLACES in the Makefile for a list of registered extracts and expand it as desired).
  • Run make to generate the project.mml file. (Alternatively, maketerrain-classic-background, terrain-classic-lines, orterrain-classic-labels to work on the variant styles)
  • Start TileMill by running npm start from the TileMill repo
  • Open http://localhost:20009/#/project/terrain-classic

make db/<place> will write to the database specified in .env (with a format that resembles postgres:///terrain, where terrain is the database name). If you experience trouble connecting, try adding credentials, e.g. postgres://user:password@localhost/terrain (it will use $USER with no password otherwise). Barring that, check yourpg_hba.conf to ensure that access is configured correctly.

(We primarily develop on OS X where PostgreSQL from Homebrew works out of the box.)

NOTE: Changes to project settings (i.e. .mml files not .mss stylesheets) in TileMill will not persist the changes. To make changes, edit the relevant .yml file and re-run make [variant] to re-generate the project.mml that TileMill reads.

To test the terrain style with a hillshade overlay, a tessera.json config is provided. Install tessera with npm install tessera and then run npm start in the terrain-classic directory. Open http://localhost:8080/ to view the terrain-classic style composited with Open Terrain hillshades.

Testing with the side-by-side viewer (experimental)

In the root folder run npm install && npm start which will start tessera running at http://localhost:8080

Then, in the side-by-side folder, run a simple webserver such as python -m SimpleHTTPServer. Then go to http://localhost:8000 (or whatever port the webserver is running at) to view the side-by-side viewer.

FAQ

What's the deal with the Makefile? Why is it so complicated?

Magic, mostly. It probably can (and should) be simplified! Consider this another, in-progress "make for data" approach (which actually uses make).

The goal here is to provide an idempotent process for bootstrapping the project that uses as few additional dependencies as possible. make is the age-old solution to this problem, although it takes a more file-focused approach. Put another way, it attempts to efficiently encapsulate otherwise complicated and error-prone operations.

The Makefile here attempts to replicate make's behavior relative to rebuilding files with database tables. In other words, if a Postgres relation already exists, it will be left as-is. If it doesn't exist (has been dropped or hasn't been created), it will be created on-demand.

Why do I have to install pgexplode?

libpq (which underlies PostgreSQL's command-line tools) supports a number of environment variables which can be used to avoid repetition (and avoid errors). However, each component of the connection information is separate, and is more easily and concisely encoded in a URI (i.e. DATABASE_URL). pgexplode is aware of libpq's environment variables and will expand DATABASE_URLs components (which is simpler than managing multiple values and constructing a URL for imposm3 and other tools).

terrain-classic's People

Contributors

almccon avatar clhenrick avatar mojodna avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

terrain-classic's Issues

overlapping street labels

It's subtle, but I just noticed these:

screen shot 2015-10-06 at 5 43 55 pm

It looks like roads labels are drawn twice, first with a wide letter- or word-spacing, and then a second time slightly narrower. At first you don't notice it, or you think there are parentheses around the words.

Not sure how this is happening... they're not all double ways, I don't think. In any case, maybe text-min-distance or label-spacing is the culprit? Or more likely it's caused by attachments in the CartoCSS, where the label is defined in two places and gets drawn twice for the same feature.

Add unicode fallback font

screen shot 2015-08-24 at 5 11 55 pm

Are there unicode versions of PT Sans? Not sure. If not, we need a fallback font.

We're labeling the name tag from OSM which will blindly pick up all local names. So we need to be ready for anything.

Antarctica should be white

Also, Greenland is off-white, but I can live with that. Greenland is colored that way because of the landuse raster, but Antarctica is showing the no data value.

Maybe add a shapefile just for Antarctica? Pull it from Natural Earth?

Street casings for roads at higher zoom levels?

Right now at zoom 18 (max zoom level) smaller roads (non-highways) are being displayed with casings, is this something we want to change for higher zoom levels with the updated terrain tiles?
screen shot 2015-08-27 at 12 21 46 pm

screen shot 2015-08-27 at 12 21 40 pm

Create terrain-classic-lines and terrain-classic-background variants

Currently I've got terrain-classic (which includes everything) and terrain-classic-labels as the only two variants. We also need terrain-classic-lines and terrain-classic-background (which omits labels and lines).

Look at https://github.com/stamen/toner-carto to see how this is done. Also, compare terrain-classic.yml and terrain-classic-labels.yml in this repo, and extend the pattern to the other two variants. Also examine the tessera.json file in this repo to see how we serve up the variants.

For comparison, here are what the deployed styles look like:
http://maps.stamen.com/terrain-background/#13/37.7625/-122.3973
http://maps.stamen.com/terrain-labels/#13/37.7625/-122.3973
http://maps.stamen.com/terrain-lines/#13/37.7625/-122.3973

Error when trying to run 'make db/shared'

Hi!
I have the same issue as stamen/toner-carto#36 .
Installed everything.

export DATABASE_URL='postgis:///terrain-classic'
make .env
The .env file is there.
make link, OK.
make db, OK, it creates the DB.
After that, the database is there and I can connect to it. It's empty.
make db/shared gives me the same errors as @jbcima .

psql:sql/functions/highroad.sql:1: NOTICE:  view "highroad_z15plus" does not exist, skipping
psql:sql/functions/highroad.sql:2: NOTICE:  view "highroad_z14" does not exist, skipping
psql:sql/functions/highroad.sql:3: NOTICE:  view "highroad_z13" does not exist, skipping
psql:sql/functions/highroad.sql:4: NOTICE:  view "highroad_z12" does not exist, skipping
psql:sql/functions/highroad.sql:5: NOTICE:  view "highroad_z11" does not exist, skipping
psql:sql/functions/highroad.sql:6: NOTICE:  view "highroad_z10" does not exist, skipping
psql:sql/functions/highroad.sql:26: ERROR:  relation "**osm_planet_osm_line_z10**" does not exist
LINE 18:       FROM osm_planet_osm_line_z10
                    ^
make: *** [db/functions/highroad] Error 3

Any idea from where it could come from? The README doesn't mention anything else before make db/shared.

If I try to keep going anyway, and do a make db/seattle, I get a

make: *** No rule to make target `data/aries/z4to10.json', needed by `db/aries'.  Stop.

All dependencies installed.
imposm3 version 0.1
Ubuntu 14.04.4 LTS

Thank you!

Add mountain peaks

This is a special case of #17, but thinking about #43, it's a shame that mountains aren't rendered at all! Especially given that this map is about terrain!

OSM has peaks, so it wouldn't be too difficult to grab their styling and modify it. https://github.com/gravitystorm/openstreetmap-carto/blob/3bd384329e2cb6a627f99e034fcfb28e734dcbeb/amenity-points.mss#L945-L957

However, this is probably yet another can of worms that I shouldn't open right at the moment that we're trying to wrap this up.

Add natural feature labels?

Seems like some of these can be pulled in from Toner (eg: oceans and other bodies of water) but Natural Earth also has data for natural features at smaller scales / zoom levels. Could be a nice improvement to the original terrain tiles.

screen shot 2015-08-27 at 11 27 10 am

fade out landcover colors at high zooms

After #23 I think the landcover is looking really good at low zooms.

screen shot 2015-10-22 at 5 28 15 pm

But when you reach the city scale, the colors are way too harsh.

screen shot 2015-10-22 at 5 29 07 pm

I'm not exactly sure how I'm going to fix this, but I've got some ideas.

Make labels only

Any plans to create a make for labels only? If not, any pointers for doing so? I just painstakingly made everything but labels transparent, which is a poor hack... .

show city names at higher zooms

Currently the city names disappear at z11, leaving the map looking pretty empty until street names starting to trickle in. OG Terrain keeps city names on the map until z16! I kind of like it.
screen shot 2015-10-22 at 6 20 17 pm

Small osm_admin boundaries should not render at low zooms

When looking at Seattle I noticed an odd artifact at #10/47.1159/-122.0821. On zooming in it turns out to be a small tribal administrative boundary. We should probably add a query that prevents small admin areas from rendering at low zooms so we don't end up with black specs on the map.

Notice the speck below Prairie Ridge
screen shot 2015-10-22 at 5 19 32 pm

screen shot 2015-10-22 at 5 16 04 pm

Identified in QGIS:
screen shot 2015-10-22 at 5 18 29 pm

Makefile updates

Processes to add to the Makefile include:

  • importing the Aries place data into PostGIS.
  • process Aries from GeoJSON to SHP & reproject (only needed if the data isn't accessible via PostGIS)
  • compile sub-directory of .mss files into single .mml files
  • generate highway shields table in Postgres using sql/highway_shields.sql
  • add ne_10m_admin_1_labels to PostGIS using sql/admin1_labels.sql
    (also requires dl'ing & extracting ne_10m_admin_1_states_provinces)*

* I imported the ne_10m_admin_1_states_provinces data into PostGIS by doing the following:

$ shp2pgsql -s 4326 -I -g geometry \ 
~/data/natural_earth_vector/ne_10m_admin_1_states_provinces_scale_rank.shp \
ne_10m_admin_1_states_provinces terrain_tokyo | psql -d terrain_tokyo

Park boundaries should trump landcover data at higher zooms

Looks like with the new terrain-classic park boundaries aren't being rendered and that the landcover data is displaying at high zoom levels.
screen shot 2015-08-27 at 12 08 31 pm

There must be a rule in cascadenik for the og terrain tiles that decides when to swap landcover data for park boundaries as the polygon layer to composite onto the hillshades.
screen shot 2015-08-27 at 12 08 24 pm

Looks like at zoom 10 park boundaries start showing up, possibly on top of dimmed landcover data? Then at zoom > 10 park boundaries are more definitive.

population values in admin0 files are wrong

I tried using them to adjust the sizes of the admin labels, but the populations are all nuts (I checked only the file admin-0-labels-z5. I thinks that Austria has a larger population than Germany, which is wrong, and which looks wrong on the map.

Why don't we have real populations in these files? Why don't we just use Natural Earth (where did these files come from, anyway?)

Here's me trying to use population < 90 to apply smaller labels. Totally wrong:
screen shot 2015-11-04 at 5 20 47 pm

Labeling typography improvements

We could definitely improve the typography by doing some simple things such as:

  • spacing out the kerning via the text-character-spacing property.
  • using italic fonts in labels such as water bodies, natural features, parks.
  • varying the font-size of place labels based on something like scale-rank from natural earth
  • creating angled labels along a path for features such as mountain ranges and valleys

@almccon & @mojodna does PT Sans Narrow have an italic font? I don't see it when inspecting via font-book. We might want to choose a font that has more options, at least one that has italic and bold-italic.

duplicate shield labels for cities and peaks

It seems to be happening at tile boundaries:

screen shot 2015-11-04 at 5 23 13 pm

Oh, but in #35 we found some that were not on tile boundaries, although those seem to be fixed. But that's something to keep an eye on... I think they're only happening on tile boundaries, but I could be wrong.

Justification in merged_labels is sometimes wrong.

The merged_labels is something I stole from another repo. It looks like the z4 and z5 city label areas don't have the justified column entered correctly.

QGIS screenshot, showing labels that are left justified in green, and those right justified in blue. Many more should be blue than are shown here.

screen shot 2015-06-01 at 1 48 15 pm

Fix gaps between adjacent water polygons

Noticed this while looking at the Hudson River in an New York extract. I'm guessing this is why there was a stroke applied to water polygons? I believe we previously removed at very low zooms but perhaps enabling them at higher zooms will fix this. That or a union in PostGIS?

screen shot 2015-10-22 at 3 39 01 pm

add contour lines from srtm 30m dem data?

So after doing some research it looks like contour lines generated from SRTM 30m data could look decent up to about z15 and after that they start looking a little too jagged without smoothing them out.

I took an extract of an SRTM raster for the Mt Whitney area, extracted part of it, converted to EPSG:3857, then generated contours at 50m intervals. The following screenshots show the contours overlaid on top of the og terrain tiles in QGIS:

zoom 14 (~1:36,000)
screen shot 2015-10-28 at 3 17 52 pm

zoom 15 (~1:18,000)
screen shot 2015-10-28 at 3 13 19 pm

zoom 16 (~1:9,000)
screen shot 2015-10-28 at 3 13 02 pm

zoom 17 (~1:4,500)
screen shot 2015-10-28 at 3 18 51 pm

My general workflow for print cartography is to take the contours after rendering them with GDAL and use illustrator's "smooth lines" to apply bezier curves to them so they don't look so jagged. This could probably get them looking really nice at zooms 16+ but we'd have to figure out how to do it programatically.

overlay US/Canada landuse from old Terrain map?

Here's the extent of the previous source data:
screen shot 2015-06-15 at 5 04 43 pm

It's higher-resolution than what I'm using now for the world. Unfortunately, the categories seem to be fairly different between the two rasters. It would only look weird where the two rasters are up against each other. Unfortunately the old data cuts off in Mexico... otherwise I could maybe use the old data for all of North America and make the transition in Panama somewhere. But it looks like I need to make the transition along the US-Mexico border.

Old data:
screen shot 2015-06-15 at 5 09 19 pm

New data:
screen shot 2015-06-15 at 5 09 22 pm

Actually, it won't look too bad in most places. Maybe just awkward at the border with Baja California

Enable highway shields in other countries

I'm not sure why the default shield isn't showing up, but when I use extracts outside the US I don't get any highway shields, and when I use extracts of other US states, I don't get any of their state shields.

screen shot 2015-10-06 at 5 26 39 pm
screen shot 2015-10-06 at 5 21 46 pm
screen shot 2015-10-06 at 5 39 15 pm

clean up natural earth database import steps

I added code in https://github.com/stamen/terrain-classic/blob/master/Makefile#L266-L281 to load Natural Earth shapefiles into the database, but it needs more rewriting: currently if you already have the NE shapefiles downloaded the Makefile thinks there is nothing to do.

This error occurs if you're trying to set up a new database extract, but you already have NE downloaded for a previous extract.

The makefile needs to test for existence of the db tables, not just the existence of the shapefiles.

add Admin 1 labels

Seems like we should be able to easily port these from Toner? Though perhaps it depends on how we address the dymo placement of labels (ref #4)
screen shot 2015-08-27 at 11 27 10 am

remove the phased-in buildings

It's a nice touch in Toner, but it would be nice to make this map look less like Toner

screen shot 2015-09-18 at 5 57 59 pm

http://localhost:8080/background/#15/37.7775/-122.4386

dymo labels need help

Because the labels files we are using were generated for Helvetica, not the narrower font we want to use for Terrain, the alignment of city labels looks bad.

By default, the labels are centered within the label polygon, and are usually way too far from the city dots.

screen shot 2015-06-19 at 6 27 50 pm

If I try to text-align using the justified field in the data, like so...

  [justified='left'] {
    text-horizontal-alignment: left;
    text-dx: 15;
  }

  [justified='right'] {
    text-horizontal-alignment: right;
    text-dx: -15;
  }

...I can never get things to line up correctly.
screen shot 2015-06-19 at 6 37 09 pm

(these examples include the following debugging code, to see the text polygon in the background)

  ::outline {
    polygon-fill: #fff;
    polygon-opacity: 0.3;
  }

Draw OSM glaciers

Here's Mt. Baker at z9, showing only the landcover data. Nice white-topped mountain:

screen shot 2015-10-26 at 12 47 26 pm

Then at z10 we start drawing national forests, and this ice-covered peak looks solid green:
screen shot 2015-10-26 at 12 47 33 pm

OSM has good glacier features... we should draw them:
screen shot 2015-10-26 at 12 49 44 pm

...but I think I will have to pull out yet another OSM feature in imposm.

change styling of trails / paths

Looks like there is a casing on the trails as they now exist
screen shot 2015-08-27 at 11 57 06 am

Whereas the original terrain tiles are a simple dashed dark gray line
screen shot 2015-08-27 at 11 57 12 am

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.