Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: Map grid to boundary conversion algorithm

by BrowserUk (Patriarch)
on Apr 16, 2004 at 19:31 UTC ( [id://345847]=note: print w/replies, xml ) Need Help??


in reply to Map grid to boundary conversion algorithm

UPDATE: Many thanks to all who responded. I should maybe have been a little less figurative with the ASCII art; it was the actual roughness contour lines I was after, though I'm sure I could write an ASCII to vector converter.

Perhaps you could give an example of the format you need, for your sample?


Examine what is said, not who speaks.
"Efficiency is intelligent laziness." -David Dunham
"Think for yourself!" - Abigail
  • Comment on Re: Map grid to boundary conversion algorithm

Replies are listed 'Best First'.
Re: Re: Map grid to boundary conversion algorithm
by Willard B. Trophy (Hermit) on Apr 28, 2004 at 02:27 UTC
    Sorry for the delay. With your comments in mind, I ended up coding it this way:
    1. define a zero-value one cell border around the whole array.
    2. walk through each row horizontally, looking for vertical changes in value. Store each one in a structure containing the left and right values, and the coordinates of the end points
    3. walk through each column vertically, looking for horizontal changes in value, as above.
    4. search for adjoining vertical segments, and merge them.
    5. search for adjoining horizontal segments, and merge them.
    6. Write out the lists of line segments.

    It appears that the mapping tool we use is clever enough to join up adjacent lines into areas, so lines are all we need. The reason for the zero-value border isn't initially obvious, but it's necessary for the contouring routine to get its senses right.

    I put an example of what a tiny (300m x 300m) test file in my blog, if anyone cares to see what it looks like.

    I know my algorithm isn't that efficient; it took nearly 8 hours to process a real 73 x 58 km dataset on a P4-2800. My Fortran version (compiled with the excellent free-for-personal use Intel Fortran Compiler for Linux) looks like it will run at least an order of magnitude quicker.

    I'm beginning to warm to Fortran (90, or 95; F77 I cannot love). It has a nifty WHERE command which is somewhere between map and grep.

    Yes, at this point, you can say 'He's got away from us Jack.' ...

    --
    bowling trophy thieves, die!

      Glad you have a solution that works for you. It is an interesting problem that I think I would have enjoyed having a crack at, but it still isn't clear to me what format you want the output in? What would the line segments for your original example be?


      Examine what is said, not who speaks.
      "Efficiency is intelligent laziness." -David Dunham
      "Think for yourself!" - Abigail
        Okay, a full set of (small) examples are in my scratchpad. It's a knotty wee problem.

        --
        bowling trophy thieves, die!

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://345847]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (4)
As of 2024-04-24 13:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found