Drawing a Topographical Map

前端 未结 9 2039
遥遥无期
遥遥无期 2020-12-22 21:31

I\'ve been working on a visualization project for 2-dimensional continuous data. It\'s the kind of thing you could use to study elevation data or temperature patterns on a 2

相关标签:
9条回答
  • 2020-12-22 22:03

    I recommend the CONREC approach:

    • Create an empty line segment list
    • Split your data into regular grid squares
    • For each grid square, split the square into 4 component triangles:
      • For each triangle, handle the cases (a through j):
        • If a line segment crosses one of the cases:
          • Calculate its endpoints
          • Store the line segment in the list
    • Draw each line segment in the line segment list

    If the lines are too jagged, use a smaller grid. If the lines are smooth enough and the algorithm is taking too long, use a larger grid.

    0 讨论(0)
  • 2020-12-22 22:04

    It occurred to me that what you're trying to do would be pretty easy to do in MATLAB, using the contour function. Doing things like making low-density approximations to your contours can probably be done with some fairly simple post-processing of the contours.

    Fortunately, GNU Octave, a MATLAB clone, has implementations of the various contour plotting functions. You could look at that code for an algorithm and implementation that's almost certainly mathematically sound. Or, you might just be able to offload the processing to Octave. Check out the page on interfacing with other languages to see if that would be easier.

    Disclosure: I haven't used Octave very much, and I haven't actually tested it's contour plotting. However, from my experience with MATLAB, I can say that it will give you almost everything you're asking for in just a few lines of code, provided you get your data into MATLAB.

    Also, congratulations on making a very VanGough-esque slopefield plot.

    0 讨论(0)
  • 2020-12-22 22:05

    The gradient is a mathematical operator that may help you.

    If you can turn your interpolation into a differentiable function, the gradient of the height will always point in the direction of steepest ascent. All curves of equal height are perpendicular to the gradient of height evaluated at that point.

    Your idea about starting from the highest point is sensible, but might miss features if there is more than one local maximum.

    I'd suggest

    1. pick height values at which you will draw lines
    2. create a bunch of points on a fine, regularly spaced grid, then walk each point in small steps in the gradient direction towards the nearest height at which you want to draw a line
    3. create curves by stepping each point perpendicular to the gradient; eliminate excess points by killing a point when another curve comes too close to it-- but to avoid destroying the center of hourglass like figures, you might need to check the angle between the oriented vector perpendicular to the gradient for both of the points. (When I say oriented, I mean make sure that the angle between the gradient and the perpendicular value you calculate is always 90 degrees in the same direction.)
    0 讨论(0)
提交回复
热议问题