isolining package for ActionScript 3

A week or so back I wrote about a package I ported/modified to create the Delaunay triangulation in Flash with a few AS3 classes. As I noted there, such a triangulated irregular network (TIN) allows us to interpolate isolines — lines of constant value (aka isarithms, commonly called contours).

So, given a field of points (weather stations, say)…

weather stations

…with one or more attributes attached (temperature, say)…

weather stations for interpolation

…a TIN can be constructed.

triangulated irregular network

With the above TIN, values can be interpolated along each edge between the points of known values (control points). The interpolation is strictly linear (that is, the value 50 would be interpolated halfway along an edge whose control points were valued 48 and 52).

interpolated points for isolining

With a given contouring interval (I’m using 4 degrees F here), we can connect some of these interpolated points, creating our contour lines.

rigid isolines, ready for smoothing

With the previous steps stripped away, this creates a passable isoline map.

masked isolines

The lines are rigid, though, and should be smoothed for presentation. I allow two methods for this. You can use the “simple” method, which just uses the built-in graphics method curveTo between the midpoint of each isoline segment (below with the isoline interval decreased to 3 degrees).

simple curves for isolining

The above looks alright, but the curves are not continuous, closed loops can still have hard corners, and the isolines no longer pass through the interpolated points (we have therefore generalized an already-inaccurate interpolation). My compatriot Andy Woodruff, author of the glorious new Cartogrammar blog, offered to write a nice continuous curve method that ensured isolines would still pass through the interpolated values. You can read about the method in his post. Here she blows:

continuous curves for isolining

Bringing it all together, then, and incorporating the only extra feature I wrote (tinting of isolines), here’s a nice finished isoline map of temperature across the U.S.

finished isoline map of U.S. temperature

My new isolining package for Flash/ActionScript3 accomplishes all of the above, requiring only an array of point data with attribute values attached. The above example, was accomplished with the following lines of code (after drawing the U.S. states from a shapefile).

//first, generate the array of triangles (ITriangle objects) from the point data
var triangles:Array = Delaunay.triangulate(points);
Delaunay.drawDelaunay(triangles, points, triClip, false); //comment this out if you don't want to draw the triangulation
//generate an array of isolines (isoline objects)
var isos:Array = IsoUtils.isoline(triangles, points, triClip, 3, 0);
//create color and class arrays for tinting the isolines
var classesArray:Array = new Array(40, 44, 48, 52, 56, 60, 64, 68, 72, 76);
var colorsArray:Array = new Array(0x051CFD, 0x4602FD, 0x6D0EEB, 0x8400FF, 0xC400FF, 0xEA00FF, 0xFF00E2, 0xFF0095, 0xFF0030, 0xFF0015, 0xFB3507);
//then, actually draw them, using a continuous curve
IsoUtils.drawIsolines(isos, triClip, "continuous", colorsArray, classesArray, .5, .95);

The full example is included in the .zip distribution. Get that here:

Keep in mind: triangulation is just one interpolation method, and is many ways the least technical (and accurate). More accurate interpolation techniques include inverse-distance and kriging. ***If you’re having trouble, and your isoline interval is not an integer, check out the comment at line 171 of isoUtils.as. Please fix that, BTW.

I meant to add other features, but since I started work this past week, I’m posting the package as-is, and invite others to modify. On my wishlist:

  • hypsometric tinting, or color between the lines, would allow for more effective terrain or temperature mapping
  • support for projections and other coordinate conversions in the drawIsolines method. I have packages for converting lat/long to a number of map projections, but currently the drawIsolines method doesn’t have support for passing a point coordinate conversion method.
  • an animated demo. This thing’s lightning-fast, so why not?
  • something that would be super wicked would be if someone would implement Tanaka’s illuminated contours [pdf] method, that thickens/thins and darkens/lightens lines like so…
    tanaka method
    …creating beautiful relief maps like the one below
    tanaka illuminated contours

If you add anything to the package, feel free to post a link to your revised version in the comments.

21 Comments

  1. Great stuff, thanks for taking the time to explain it as well as post it!

    Illuminated contours look lovely, I wonder if a passable version of them could be achieved with a BevelFilter?

    Posted June 9, 2008 at 2:18 am | Permalink
  2. AMAZING!

    grabring
    Posted July 28, 2008 at 11:11 am | Permalink
  3. ur api for contour is wonderful
    and thanks a lot to u
    i’d like to fill color between lines ,and want it bo be like
    http://blog.spatialkey.com/images/sacbee1.png

    how can i extend ur api?
    can u give me some hint?
    thanks a lot!

    aiya
    Posted September 2, 2008 at 1:20 am | Permalink
  4. this letter woman frog

    Posted September 17, 2008 at 11:08 am | Permalink
  5. The New Dress summary and study guide, with notes, essays, quotes, and pictures.

    Casino
    Posted September 17, 2008 at 1:56 pm | Permalink
  6. Get the latest mobile phones online at Dialaphone, the mobile phone shop offering great deals on the latest mobile phones.

    Posted September 17, 2008 at 1:56 pm | Permalink
  7. Hey, this is awesome… well done!!

    However for some reason the isolines mess up when the nodes/weather stations are square.

    It would be great if you could fix this.

    Raymond

    Posted January 15, 2009 at 11:51 am | Permalink
  8. This looks interesting. Iwas hoping to apply this to archaeological site densities…but not being all that computer savy I am not able to open the application files after unzipping. A little help please.

    erik
    Posted January 19, 2009 at 3:59 pm | Permalink
  9. @erik: Hello, this is a small library specifically for Flash, Flex, or ActionScript 3 projects. So if you want to display your data as an isoline on the web, it may be for you. But if you have no use for an ActionScript-specific solution, other options may be better for your needs. R & GRASS, for example, are free tools with lots of flexibility in contouring. Neither are very easy to get started with, but both would be easier to use (esp. importing your data) than my classes if you don’t need a Flash solution

    Posted January 20, 2009 at 6:54 pm | Permalink
  10. nice work you’ve done, congratulations! In our office we would like to generate our charts and diagramms esp. contour-maps with flash for interactive presentations. I’ve searched the web the last year and havn’t found the right stuff. I will try out your software, you are on the right way! The next weeks, I will also take a close look on alternative implementations for GIS-interpolations. For example: http://www.geog.ubc.ca/courses/geog470/notes/interpolation/interpolation.html
    when we can push your software into this… it would be a great deal! Thanx for your posting

    Kind regards

    Moritz

    Moritz Wagner
    Posted January 21, 2009 at 2:59 am | Permalink
  11. Hi!
    Gimme link to downloading XRumer 5.0 Palladium for free!
    Thank you…
    Very-very much.
    I’m so need this program for promote my website! This software is the best thing for online promo and mass posting, you know…

    And, dont send me XRumer 2.9 and XRumer 3.0 - that versions are too old!

    P.S. Google cant help me((((

    Posted March 12, 2009 at 5:29 pm | Permalink
  12. Not that I’m impressed a lot, but this is a lot more than I expected when I found a link on Delicious telling that the info here is quite decent. Thanks.

    Posted April 14, 2009 at 3:58 pm | Permalink
  13. Full sex tape video whith Alessandra Ambrosio
    click here Alessandra Ambrosio nude gallary sextape or just follow the link http://digg.com/celebrity/Alessandra_Ambrosio_nude_pictures_naked_video_sextape_3
    You MUST SEE it, this girl really beautifull!!!

    hnEydo
    Posted April 28, 2009 at 2:21 pm | Permalink
  14. I found paparazzi nude video whith Summer Glau >>
    click here Summer Glau nude gallery sextape or just follow the link http://digg.com/celebrity/Summer_Glau_nude_pictures_naked_video_sextape
    You MUST SEE it, this chik really beautifull!!!

    Posted April 29, 2009 at 6:13 am | Permalink
  15. Full sex tape video whith Tara Reid
    click here Tara Reid nude gallery sextape or just follow the link http://digg.com/celebrity/Tara_Reid_nude_pictures_naked_video_sextape
    You MUST SEE it, this chik really beautifull!!!

    piniko
    Posted April 29, 2009 at 9:10 am | Permalink
  16. mp3 downloads mp3 music downloads fly on the windscreen free chris de burgh mp3 download ricky martin mp3 songs download shania twain songs

    Posted May 7, 2009 at 10:02 am | Permalink
  17. типа веревка хороша когда длинна.. :)

    fuxkix
    Posted May 19, 2009 at 8:35 am | Permalink
  18. IndyCar Series Driver Danica Patrick talks about modeling for the Sports Illustrated Swimsuit Edition.
    Danica Patrick 20Q Playboy Interview or just follow the link http://www.youtube.com/watch?v=XZYb4m1nY4g
    You MUST SEE it, this girl really HOT!!!

    Posted May 24, 2009 at 4:49 pm | Permalink
  19. suborn virginia slims ultra phosphorescence cigarettes
    cheap doral cigarette tawdry doral cigarette|cheap doral cigarettes
    shoddy doral cigarettes cheap doral cigarettes
    cheaply gpc cigarette cheap gpc cigarettes
    tight gpc cigarettes tinpot gpc cigarettes
    virginia slims ultra

    Posted May 25, 2009 at 11:14 am | Permalink
  20. система ниппель: туда суй - оттуда х#й

    Posted June 17, 2009 at 2:05 pm | Permalink
  21. Петербуржская Школа Правильного Питания (7 минут от метро “Чернышевская”) приглашает всех желающих избавиться от лишнего веса на бесплатные вечерние (18:45) ознакомительные занятия 15, 16, 18, 19 и 22 июня 2009г.
    Более подробная информация и запись на сайте - http://hudeem-vmeste.com

    ignikammipmep
    Posted June 17, 2009 at 7:53 pm | Permalink

2 Trackbacks

  1. [...] isolining package for ActionScript 3 You can use the “simple” method, which just uses the built-in graphics method curveTo between the midpoint of each isoline segment (below with the isoline interval decreased to 3 degrees). The above looks alright, but the curves are not … [...]

  2. [...] update: for a cool usage of Delaunay triangulation, see my isolining package for ActionScript 3 [...]

Post a Comment

Your email is never published nor shared. Required fields are marked *