stamen / terrain-classic

World-wide CartoCSS port of Stamen's classic terrain style
ISC License
144 stars 35 forks source link

Add mountain peaks #44

Open almccon opened 8 years ago

almccon commented 8 years ago

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.

clhenrick commented 8 years ago

Ohhhh that's a terrific idea!!

-Chris L Henrick

http://chrishenrick.com https://clhenrick.github.io https://chenrickmfadt.wordpress.com/

Github: @clhenrick https://github.com/clhenrick Twitter: @chrislhenrick https://twitter.com/chrislhenrick

“Whenever I see an adult on a bicycle, I no longer despair for the future of the human race.” — H.G. Wells

On Tue, Oct 27, 2015 at 2:05 PM, Alan McConchie notifications@github.com wrote:

This is a special case of #17 https://github.com/stamen/terrain-classic/issues/17, but thinking about

43 https://github.com/stamen/terrain-classic/issues/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.

— Reply to this email directly or view it on GitHub https://github.com/stamen/terrain-classic/issues/44.

clhenrick commented 8 years ago

@almccon if you'd like I could give this a go. I assume the right way to proceed would be to first create a new table for mountain_peaks in imposm3_mapping.json and then rebuild a db from an OSM extract?

clhenrick commented 8 years ago

In Switzerland there are a ton of peaks. I'm wondering if there is a way to filter them by a rank? Perhaps using the elevation?

screen shot 2015-11-03 at 10 11 38 am

clhenrick commented 8 years ago

I'm wondering if the OSM data might be too big for mountain peaks? Perhaps it's worth looking into other sources as well if filtering by elevation doesn't help:

Natural Earth even has an elevation points layer in the 1:10m Physical Labels which could also be a good starting point: http://www.naturalearthdata.com/downloads/10m-physical-vectors/10m-physical-labels/

clhenrick commented 8 years ago

FYI I'd like to pull in the elevation for mountain peaks from OSM but am running into an odd TileMill error when attempting to do so: screen shot 2015-11-03 at 9 36 42 am screen shot 2015-11-03 at 9 37 08 am screen shot 2015-11-03 at 9 36 49 am

almccon commented 8 years ago

Argh, I forgot about that problem. You could check some of those OSM features to see if there's anything else we could use to filter. But I doubt there is.

We can't really filter by elevation because it would suppress interesting lower peaks like Mount Diablo, but do nothing for Switzerland. For another map we are working on we used an elevation cut off at 1000m, which prevents peaks in most cities, but that's not a very satisfying fix.

Is there a way we can use CartoCSS to require a wider spacing between labels?

Last thought: maybe this is a bigger task for the OpenTerrain data pipeline where we could auto-calculate "prominence" for all peaks... But definitely not an immediate solution.

On Nov 3, 2015, at 07:13, Chris Henrick notifications@github.com wrote:

In Switzerland there are a ton of peaks. I'm wondering if there is a way to filter them by a rank? Perhaps using the elevation?

— Reply to this email directly or view it on GitHub.

clhenrick commented 8 years ago

Agreed. Plus there is a ton of junk in the ele tag in OSM so we'd have to filter out all the garbage to get actual height values.

When I did attempt to clean that column and did a min / max query everything seemed to be below 1000m?

select min(height_meters), max(height_meters) 
from osm_mountain_peaks where height_meters not in ('', 'fixme') 
and height_meters not ilike '%pkt%' and height_meters not ilike '-%'; 

 min |    max     
-----+------------
 0   | 999.648926
(1 row)

When attempting to up the shield-min-distance CartoCSS property nothing seemed to change.

Maybe we can at least through in Natural Earth elevation points for the time being?

clhenrick commented 8 years ago

Oh to get the correct min / max height would be this ridiculous SQL query:

select min(height_meters::numeric), max(height_meters::numeric) 
from osm_mountain_peaks where height_meters not in ('', 'fixme') 
and height_meters not ilike '%pkt%' 
and height_meters not ilike '%-%' 
and height_meters not ilike '%m%' 
and height_meters not ilike '%;%' 
and height_meters not ilike '%–%'; 

 min | max  
-----+------
   0 | 4634
(1 row)
almccon commented 8 years ago

Yeah, let's shelve the OSM peaks for now, and see what we can get from NE or other sources.

On Nov 3, 2015, at 07:40, Chris Henrick notifications@github.com wrote:

Agreed. Plus there is a ton of junk in the ele tag in OSM so we'd have to filter out all the garbage to get actual height values.

When I did attempt to clean that column and did a min / max query everything seemed to be below 1000m?

terrain_switzerland=# select min(height_meters), max(height_meters) from osm_mountain_peaks where height_meters not in ('', 'fixme') and height_meters not ilike '%pkt%' and height_meters not ilike '-%';

min | max
-----+------------ 0 | 999.648926 (1 row) When attempting to up the shield-min-distance CartoCSS property nothing seemed to change.

Maybe we can at least through in Natural Earth elevation points for the time being?

— Reply to this email directly or view it on GitHub.

clhenrick commented 8 years ago

Adding the natural earth elevation points is a good quick fix:

screen shot 2015-11-03 at 1 34 26 pm

almccon commented 8 years ago

Love it! :mount_fuji:

clhenrick commented 8 years ago

I'm also going to give the world's 100 tallest peaks (elevation >= 7200) a bold italic font, cause ya know they're special :)

clhenrick commented 8 years ago

[zoom>=6][elevation>=8000]{...}

screen shot 2015-11-03 at 1 49 25 pm

almccon commented 8 years ago

Nice! They're special, but they're also all in the Himalayas, yes?

Could we also figure out the highest peak on each continent? I guess that's simple enough to do by hand, even.

Oh and make sure we have Denali not Mt. McKinley!

clhenrick commented 8 years ago

Ah, good point!

almccon commented 8 years ago

Also there's the usual scalerank field, which we can fiddle with as needed.

almccon commented 8 years ago

I love Natural Earth!

clhenrick commented 8 years ago

Totally!

clhenrick commented 8 years ago

Attempting to add custom text for Denali. Seems like adding custom text doesn't work for shield-name though. For example when I do:

      [name='Mt. McKinley'] {
        shield-name: "'Denali'";
      }

TileMill gets angry:

screen shot 2015-11-03 at 2 30 42 pm

Thinking we'll just have to alter the data in the table? Or maybe submit a PR to the NE repo?

almccon commented 8 years ago

Well I already did this: https://github.com/nvkelso/natural-earth-vector/issues/154

If we want to modify the natural earth file we can host the modified version in Stamen's fork of NE, like we do with a few other files.

But there should be a way to get CartoCSS to override... lemme see if I can find other references to how I've done that before.

clhenrick commented 8 years ago

Not the most "dry" way to do it but this seemed to work:

#mountain_peaks_ne {
    [zoom>=6][comment =~'.*highest.*'],
    [zoom>=6][name =~'.*Vinson.*'],
    [zoom>=7][elevation>=2000],
    [zoom>=8][elevation>=1500],
    [zoom>=9][elevation>=1000],
    [zoom>=10][elevation>=500],
    [zoom>=11][elevation>0] {
      shield-name: [name] + ' '  + [elevation] + 'm';
      shield-face-name: @text_font_italic;
      shield-size: @text_font_size_xxsm;
      shield-file: url('icons/triangle-18.svg');
      shield-transform: scale(0.5,0.5);
      shield-unlock-image: true;
      shield-avoid-edges: true;
      shield-fill: @label_color_physical;
      shield-halo-fill: @label_color_physical_halo;
      shield-halo-radius: 1;
      shield-halo-opacity: 0.7;
      shield-min-distance: 2;
      shield-placement-type: simple;
      shield-placements: 'NW,SE,N,S,E,W,NE,SW';
      shield-text-dy: 5;
      shield-text-dx: 5;
      shield-min-distance: 1000;
      shield-wrap-width: 30;
      shield-line-spacing: -2;

      [comment =~'.*highest.*'],
      [name =~'.*Vinson.*'] {
        shield-face-name: @text_font_bold_italic; // special call out to the tallest peaks on each continent!
        shield-transform: scale(0.65,0.65);
      }

      [zoom>=8] {
        shield-size: @text_font_size_xsm;        
      }

      [zoom>=10] {
        shield-size: @text_font_size_sm;
        shield-transform: scale(0.8,0.8);
        shield-text-dy: 7;
        shield-text-dx: 7;
      }
    }
}

// Replace out dated name of Denali
#mountain_peaks_ne {
  [name='Mt. McKinley'] {
    shield-name: "'Denali" + ' '  + [elevation] + 'm';
    shield-face-name: @text_font_italic;
    shield-size: @text_font_size_xxsm;
    shield-file: url('icons/triangle-18.svg');
    shield-transform: scale(0.5,0.5);
    shield-unlock-image: true;
    shield-avoid-edges: true;
    shield-fill: @label_color_physical;
    shield-halo-fill: @label_color_physical_halo;
    shield-halo-radius: 1;
    shield-halo-opacity: 0.7;
    shield-min-distance: 2;
    shield-placement-type: simple;
    shield-placements: 'NW,SE,N,S,E,W,NE,SW';
    shield-text-dy: 5;
    shield-text-dx: 5;
    shield-min-distance: 1000;
    shield-wrap-width: 30;
    shield-line-spacing: -2;
  }
}
clhenrick commented 8 years ago

screen shot 2015-11-03 at 2 46 45 pm

almccon commented 8 years ago

that's good!

Looks like you've still got an apostrophe in there: 'Denali

clhenrick commented 8 years ago

thanks, ah you're right!

almccon commented 8 years ago

I love these!

Spotted a case where it's dropping the special character in "Crêt de la Neige". Grr, character encodings. Might need to file this under #32.

screen shot 2015-11-04 at 11 46 03 am

almccon commented 8 years ago

Also, some duplicated labels at 10/45.6222/2.8894 screen shot 2015-11-04 at 11 50 07 am

And at 10/46.1013/7.5490 screen shot 2015-11-04 at 11 48 46 am ...and in that one, I wonder if there's a way we could force the line break before the elevation, so the mountain name doesn't break?

clhenrick commented 8 years ago

thanks! hmm, I think we would need a special character in order to do it with CartoCSS I think? But then we would add with another character in the label we don't need...

clhenrick commented 8 years ago

@almccon this is all I'm seeing on another computer with a fresh clone of the github repo: screen shot 2015-11-04 at 3 21 10 pm

almccon commented 8 years ago

Weird! No idea what's happening there. Are you getting other peak names, or are they all gone?

clhenrick commented 8 years ago

yeah totally weird. Not getting peak names at all, and only some place names.

-Chris L Henrick

http://chrishenrick.com https://clhenrick.github.io https://chenrickmfadt.wordpress.com/

Github: @clhenrick https://github.com/clhenrick Twitter: @chrislhenrick https://twitter.com/chrislhenrick

“Whenever I see an adult on a bicycle, I no longer despair for the future of the human race.” — H.G. Wells

On Wed, Nov 4, 2015 at 4:29 PM, Alan McConchie notifications@github.com wrote:

Weird! No idea what's happening there. Are you getting other peak names, or are they all gone?

— Reply to this email directly or view it on GitHub https://github.com/stamen/terrain-classic/issues/44#issuecomment-153871408 .

almccon commented 8 years ago

Well, I'll leave this open until we figure out what's happening on your end. It works for me, and I've enabled it on several of my extracts (using make db/shared) but I haven't tried creating a fresh one yet.

Do you have osm peaks in your imposm script? I think you never checked them in, so you might want to check to see if your imposm3_mapping.json matches the latest version in github.

clhenrick commented 8 years ago

I'm not sure what you mean by "you never checked them in"

-Chris L Henrick

http://chrishenrick.com https://clhenrick.github.io https://chenrickmfadt.wordpress.com/

Github: @clhenrick https://github.com/clhenrick Twitter: @chrislhenrick https://twitter.com/chrislhenrick

“Whenever I see an adult on a bicycle, I no longer despair for the future of the human race.” — H.G. Wells

On Wed, Nov 4, 2015 at 6:08 PM, Alan McConchie notifications@github.com wrote:

Well, I'll leave this open until we figure out what's happening on your end. It works for me, and I've enabled it on several of my extracts (using make db/shared) but I haven't tried creating a fresh one yet.

Do you have osm peaks in your imposm script? I think you never checked them in, so you might want to check to see if your imposm3_mapping.json matches the latest version in github.

— Reply to this email directly or view it on GitHub https://github.com/stamen/terrain-classic/issues/44#issuecomment-153898695 .

almccon commented 8 years ago

Oh, well, when I first pulled down your changes for the mountain peaks, the yml files included references to a mountain_peaks table from OSM, but also a mountain_peaks_ne table from NE. The OSM table didn't exist for me, and I don't remember seeing any changes in imposm3_mapping.json that would have generated that table. That's the part that I think was missing.

It doesn't matter now, because we dropped the reference to mountain_peaks. But I thought that could be a sign that your imposm mapping is out of sync?

(just grasping at straws that might explain why your peak names are disappearing... )

clhenrick commented 8 years ago

​Oh yeah, I added the peaks from OSM in the imposm mapping JSON file at 5437573. https://github.com/stamen/terrain-classic/commit/54375735ee624d0303c1c3da9da53e863b37abaf

​I had to recreate the database to include the OSM peaks but it worked.​ I'm going to try recreating the repo again to see if I can get tessera to work, but other than that I'm not sure why it's misbehaving for me.

-Chris L Henrick

http://chrishenrick.com https://clhenrick.github.io https://chenrickmfadt.wordpress.com/

Github: @clhenrick https://github.com/clhenrick Twitter: @chrislhenrick https://twitter.com/chrislhenrick

“Whenever I see an adult on a bicycle, I no longer despair for the future of the human race.” — H.G. Wells

almccon commented 8 years ago

Ahh, my bad for missing that commit!