GithubHelp home page GithubHelp logo

isabella232 / quadtree-contours Goto Github PK

View Code? Open in Web Editor NEW

This project forked from esri/quadtree-contours

0.0 0.0 0.0 20 KB

Efficient contour algorithm based on mipmaps and quadtrees

License: Apache License 2.0

JavaScript 100.00%

quadtree-contours's Introduction

quadtree-contours

This is a JavaScript implementation of an algorithm for efficiently computing contours (isolines) of raster data such as digital elevation models, inspired primarily by this article. Unlike the more common "marching squares" algorithm, it does not have to visit every input pixel for every contour line.

See the geotiff-contour.js example for how to generate GeoJSON contour lines from a GeoTIFF elevation model.

First, it builds a min-max mipmap of the input data -- a pair of image pyramids using minimum and maximum as the reduction operators. Each higher level of the pyramid is half the resolution of the previous, and a pixel stores the min or max of the 4 corresponding pixels covering the same area at the level below. The lowest level of both the min and max pyramids is simply the original image, while the highest level is a single pixel with the minimum and maximum values found across the entire input raster.

This mipmap can be reused for all the contour lines on the same raster. Starting at the top of the pyramid, this mipmap is interpreted as a quadtree for a particular contour level value. It selects the cells of the mipmap where the contour level lies between the cell's min and max, and recursively subdivides such cells by proceeding down to more detailed mipmap levels. It recurses into cells that may contain the contour line, and traces out the boundary between cells that are entirely above the contour level and those that are entirely below. These boundary line segments are then sorted and reassembled into vector rings and lines.

This animation shows the changes to the quadtree structure as the contour level sweeps upward through an elevation model of a canyon: Animation (generated by this example)

quadtree-contours's People

Contributors

kevinmehall avatar dulldrums avatar gpbmike avatar

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.