Subscribe to this thread
Home - General / All posts - Tanaka contours

4,754 post(s)
#09-Apr-18 19:01

I ran across a discussion recently of Tanaka contours, and decided to try it in 9. A Tanaka contour is a contour line that gets brighter where it runs perpendicular to the Sun azimuth on the climbing side of a contoured hill and it gets darker on the other side of the hill. It is also thicker when running perpendicular to Sun azimuth and thinner when running to or fro in the direction of Sun azimuth.

Click the image above to make it bigger.

If you overlay these lines on top of a colored raster of a terrain, especially if you use Fill rules of closest lower or higher so that regions between contour lines are the same color, you get a cool effect of terraced, 3D-like contours. It's a nice trick.

The way people usually kludge this is to take contour lines and to break them up into segments (I used the decompose to segments template) so that instead of one contour line you have a zillion lines, each of which is one segment between vertices. Next, you compute the bearing for each such tiny segment and save it as a field. I used a computed field called azi for that, with the expression

57.2958 * Atan2((VectorValue(GeomCoordXY([Geom], 1),0) - VectorValue(GeomCoordXY([Geom], 0),0)), (VectorValue(GeomCoordXY([Geom], 1),1) - VectorValue(GeomCoordXY([Geom], 0),1)))

If you have two points at coordinates x1, y1 and x2, y2, then the bearing using the inverse arctangent function atan2 is simply atan2( (x2-x1), (y2-y1)). You have to multiply by 57.2958 to convert radians to degrees. The tricky functions are copied out of the Example topic on creating a geocoded table from a drawing and are just simple functions to pull the X or Y coordinate out of the first or the second vertex in a geom.

You then have to normalize the bearing so it is always a positive number, using an expression like

CASE WHEN ([azi]< 0) THEN [azi]+360 ELSE [azi] END

to create another computed field. All the above, of course, could be done in one go.

Next, you tinker with Style to color the various one-segment lines depending on their bearing, and to size their widths so those perpendicular to the Sun azimuth are fatter. Last, you create a PDF like the one attached.

The experience teaches some lessons: first, there is some tuning we will do to make the rendering smoother and better. The PDFs are prettier than the view onscreen, and we can't settle for that! :-) Second, although it is cool the technique works just fine in 9, decomposing contour lines to a huge number of one segment lines is a kludge. Everybody else does it that way but it is still a kludge. We should put this into a special style. Third, it is gratifying 9 does this so well in the print to PDF part of it, which would without fail would have choked 8.

I'll try to get around to publishing a .mxb on this, since the formatting used is part of the art of doing Tanaka contours.

By the way, the attached PDF is called what it is because I used the Microsoft print to PDF facility using basic rendering. That ends up creating a smaller, but acceptable PDF than using the hardware accelerated rendering option. The region shown is the Mount Hood terrain elevation data that is used in the Contours examples.



7,905 post(s)
#09-Apr-18 19:36

That is a really cool effect! (Which I hadn’t heard of.)

What else can we use it for? Stream lines would benefit.

Underneath, are you suggesting variable colour from start to end of line, according to an SQL expression?

If so, also variable width?


4,754 post(s)
#10-Apr-18 06:14

What else can we use it for? Stream lines would benefit.

I agree. It is called "contours" or "illuminated contours" but really it is a form of drop shadow that could work with many objects that involved directionality, although logically the brightening on the "up" side and the darkening on the "dark" side make most visual sense on closed figures that appear to be illuminated from one side, to give a raised effect. Strictly speaking as a matter of visual perspective it is a cheat, since in an inclined view if you see the dark side of a hill you don't also see the bright side at the same time... can't see all sides of a hill at the same time unless you are looking straight down at a conical sides, and then you would not have the variable width used in Tanaka. So it is a bit of false perspective going on.

Underneath, are you suggesting variable colour from start to end of line, according to an SQL expression?

If so, also variable width?

Yes, exactly. I'll try to create some illustrations that better explain.


7,905 post(s)
#10-Apr-18 06:27

This would open up many cartographic opportunities that (as far as I know) don’t already exist.

I would use them all the time!

Absolutely great Dimitri.


531 post(s)
#10-Apr-18 11:03

Stream tapering that I'm familiar with is either best done in Illustrator, using a tapering brush over the length of the stream. To do this drainage lines need to be converted to rasters. This results in a tapered width line, albeit a raster.

ESRI have a workflow, to produce tapered streams, which is simply applying a line width to stream segment with a flow rate field. This results in a stepped width stream line.

I'd be very interested to see the first approach, or indeed the second, with a variable width line done in 9.


4,754 post(s)
#10-Apr-18 13:32

There's a new topic that shows the complete process in 9: Example: Tanaka Contours.

There's a lot of enthusiasm within Manifold for the visual effects this provides, but there is also fairly significant dislike for the totally inelegant method employed. Kludging the effect by splitting a single contour line into hundreds of thousands of end-to-end one-segment line objects is really distasteful. Yes, that's how everybody else does it, but 9, internally, has facilities that could do better when they are made available.

There are many capabilities within 9 that are in there and as yet not utilized which are in there to facilitate more advanced capabilities in style. The more elegant way to support Tanaka effects will happen when those style facilities become available within the panes and dialogs, so that a single line can be styled in a variable way along its length, or that a derived effect, such as highlighting/dropshadow can appear in a way that varies along the length of the object. Then we'll have something that's elegant. :-)

But, of course, until then the exploration of how Tanaka Contours can be done is a great way to see how the different features within 9 can interact to achieve some unexpected and useful effects.


429 post(s)
#09-Apr-18 23:29

by using Atan2((VectorValue(GeomCoordXY([Geom], 1),0) - VectorValue(GeomCoordXY([Geom], 0),0)), (VectorValue(GeomCoordXY([Geom], 1),1) - VectorValue(GeomCoordXY([Geom], 0),1))).

so the Geom has many XY coordinate !!

Does Geom is a vector of XY ? ( yes)

How many points contain a geom in the tanaka drawing ? ( ? )

Does union that store in one row many points is a vector of points ? ( yes ? )

Does Atan2 ( <Geom, Line> ) exist and is supported ? ( TODO )

at SQL functions doc

Atan2(<dy>, <dx>) : <radians>

Returns the arc tangent (inverse tangent) of the ratio of y/x.



join image "Because my dad promised me" interstellar from Manifold: Time by Stephen Baxter. power Math destruction


7,818 post(s)
#17-Apr-18 10:08

The technique is per-segment, lines get split into segments. So, each geom is supposed to have two coordinates.

You are right regarding Atan2 - the order of arguments should be y, then x. The order in the first post is swapped, this will be fixed.


4,754 post(s)
#17-Apr-18 13:48

You are right regarding Atan2 - the order of arguments should be y, then x.

That depends on how you want your bearings to read, clockwise or counter-clockwise.

If you want clockwise bearings, that is, classic compass bearings where a line that starts at an origin and heads directly East is considered to have a bearing of 90 degrees, then it is Atan2(deltaX, deltaY).

If you want counterclockwise bearings, then it is Atan2(deltaY, deltaX). That's the usual for programming, but it is not compass bearings.

Tanaka himself used compass bearings so that's how the post and the example read. The SQL doc gives the usual programming convention counter-clockwise bearing. You can do Tanaka contours either way, just adjusting the thematic format used in Style appropriately.

Manifold User Community Use Agreement Copyright (C) 2007-2017 Manifold Software Limited. All rights reserved.