Closed yhahn closed 11 years ago
No longer actionable; this api has changed significantly. We'll do another push to support this when it's documented in Mapnik core.
https://github.com/BenMoores/mapnik-trunk/wiki/RasterColorizer are valid docs (I would move them to mapnik trac right now but it is down) and I've now applied to mapnik core just now (https://github.com/mapnik/mapnik2/commit/3b8c06ff8a945913b4aac6d3631cea090e1cb107), so re-opening.
Also, bens patchs to cascadenik are here that we can grab for css style ideas: https://github.com/BenMoores/Cascadenik/commits/mapnik2
whoops, meant to re-open this when I commented.
All right, let's start thinking about what this might look like then.
Here's a first iteration, borrowing from how CSS Animation Keyframes are represented. I think it's a +1 as far as clarity and flexibility and a -1 because, unlike core CSS, we already have nested styles, and this, on the surface and certainly to a degree in the parser, will be overloading that concept.
hmm, looks like this was spuriously closed, re-opening.
@tmcw - great sketchup. you think it is ready to apply to test? Also, perhaps we could move this syntax discussion to an issue at https://github.com/mapnik/carto-spec.
@rcoup - I can't track down the original css sketches we had based on mozilla's css3 - any comments from your end?
note: raster colorization depends on being able to operate on one band, so to get this to work the user would likely need to pass band=1
to the advanced options for the layer referencing a gdal raster.
came up with https://gist.github.com/1260522 as a slightly different alternative. Not better, just different :)
-default
. mode
/color
within a stop can be considered strict shortcuts/aliases for rastercolorizer-mode
and rastercolorizer-color
.::stop[123.4]
seems slightly more obvious about what the numbers mean - if it was 0 {} 1 {} 2 {}
it doesn't seem clear whether they're values/indexes/something-else instead. Also keeps with the [attribute]
style we're using elsewhere for data values.[band=1]
selector. I'm thinking this should be 1-based?Thoughts?
@rcoup: unfortunately the ::thing
pattern is already established in Carto as attachment syntax and wouldn't be dual-purposable for this without making the parsing structure more complex.
I wonder about the selector syntax - that also already exists in Carto, but are bands the only way that one could filter through rasters? It sounds like, from the docs and Dane's comment, that selecting a band would have to be on the level of adding and editing the datasource, not within the stylesheet.
@tmcw: fair enough, I just felt that an attachment was kinda a good way to think of a stop :)
A datasource points to (for example) a TIF file, but whether it's added to the map as an image (eg. aerial photos), or whether a single band is rendered via a RasterSymbolizer (eg. Digital Elevation Model) seems more up to the stylesheet imo.
Mapnik doesn't support the concept of Raster Attribute Tables or has any other methods of filtering rasters that I know of, and I haven't seen any plans to implement that stuff.
A datasource points to (for example) a TIF file, but whether it's added to the map as an image (eg. aerial photos), or whether a single band is rendered via a RasterSymbolizer (eg. Digital Elevation Model) seems more up to the stylesheet imo.
Sort of; there's certainly already some interaction between the two levels in Carto and elsewhere. For instance, one can use a filter in a carto expression like #world[name="USA"]
and also provide the filter as a SQLite or Postgres select - Carto doesn't attempt to optimize datasources in any kind of magical way in that case. From the Mapnik perspective, it seems that band selection is staying in the datasource level, and thus having this seem like a stylesheet-level setting might be odd, since this'll mean that the stylesheet can create a bunch of datasources if you have 12-band hyperspectral stuff. Just as a 'have we done this before' thing, it'd mean a pretty big break from the current system, which treats the MML datasources as literals rather than things manipulable by the stylesheet.
Okay, first chunk of work in https://github.com/mapbox/carto/commit/1dcafcc
You can see the style of attributes I'm trying out here: http://ds.io/rWUjcn . I think it's pretty compact, but there's still a lot to do
am using TileMill Version 0.9.0 (v0.9.0-141-g1b9a2ab) is any of this supported within that? sorry if this post is in wrong location.
@brudy48 none of this ticket is implemented yet, so it's not available in any TileMill version.
I have reviewed this, tested, and @hrwgc has taken it for its paces. There are a few bugs I'll open other tickets about, but overall I think we should move this to master and let it live.
I do like the idea of being able to set bands at the style level, but like @tmcw notes this just will not work right now given that bands are a concept of the GDAL datasource only in Mapnik. Since I don't see any obvious ways of changing that now, I think we should just live with the major caveat here that colorizing will not work (predictably/at all) unless you've explicitly set the band at the datasource level (In the case of TileMill this would mean passing band=1
to the advanced layer options).
Longer term - say at Mapnik 3.x when Mapnik can make breaking changes, I could see adding first class support for rasters to Mapnik's filter syntax. At that point perhaps all these bits could be re-written and use better syntax. But, until then, or if that never happens, the current approach is definitely functional.
follow up issue at #251
Just got word of this work a few moments ago: https://github.com/BenMoores/mapnik-trunk/wiki/RasterColorizer. It should land in trunk next week. Ben is also going to be updating Cascadenik to work with this, so we should have tmcw or kkaefer work in lock step or even bounce ideas off with ben.