in reply to Re^2: Permutation and comparison loop
in thread Permutation and comparison loop

This is no problem

All you have to do is be careful how you define your min and max longitude. If an area starts at longitude 350 and is 20 clicks wide going to 10, then your minimum longitude is 350 and max is 10. The same algorithm works that either I and BrowserUk provided

If your data is defined so that it gives you a range of 350-370, then all you need to is take modulus 360 of your data ($max = $max % 360). Same thing is true if it's -10 to 20 ($min = $min % 360).

There's no reason to touch latitudes, as they won't ever be outside of the -90 to 90 range.

Replies are listed 'Best First'.
Re^4: Permutation and comparison loop
by BrowserUk (Patriarch) on Apr 21, 2011 at 09:43 UTC
    There's no reason to touch latitudes, as they won't ever be outside of the -90 to 90 range.

    Satellites that do global imaging tend to fly in polar orbits. So, it possible to imagine an image taken when the sat is directly over the pole, (I think that this is technically infeasible, but they can get pretty damn close), that has coordinates for its four corners:

    (85,45) 90 (85,135) +--------|--------+ | | North | | | Pole | | | / | 0/360 +--------0--------+ 180 | | | | | | | | | +--------|--------+ (85,315) 270 (85,225)

    If that was represented by the OPs minlat/maxlat, minlon/maxlon system, then you get: nnn, 85, 85, 0, 360 which isn't going to play well for overlap detection.

    The simplest fix is to break such transition images into two (or 4) parts:

    nnn-a, 85, 90, 0, 180 nnn-b, 85, 90, 180, 360

    But even then, the distortions that occur at high latitudes screws the math as soon as you start doing any trig, so spherical coordinates become pretty much de rigueur.


    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.

      Aye. However, your example image isn't exactly representative of what his coordinates would define, which would be two adjacent pie slices instead of a full rectangle. I doubt that his data would work that way, but yes anything is possible.

      Your solution of breaking up the wierd region would work though, yes. For MaxLong > 90

      MinLat, MaxLat, MinLong, MaxLong
      to
      MinLat, MaxLat, MinLon, 90 # and (MinLat+180)%360, (MaxLat+180)%360, 180-MaxLong, 90
        However, your example image isn't exactly representative of what his coordinates would define, which would be two adjacent pie slices instead of a full rectangle

        That really depends upon whether the imagery in question is raw sat data or post-processed.

        CCDs don't adjust their shape with reference to the 'latitude' of their current position. Ie. The images they take a always rectangular. Hence the reason why images of the poles (of earth or other planets) are often made up of composites of lots of frames that are all rectangular, but overlay each other at weird angles. Like this one of the Martian South Pole.

        The poles are (can be) imaged on every orbit, each time at a slightly different angle as the orbit precesses. Whether the positioning of (the corners of) such images are given in lat/long or some other perhaps spherical coordinate system I don't know. But given that the OP mentions 0 - 360 longitude rather than the more usual -180/0/+180 used by mapping (and GPS?), assuming that the image coordinates have been converted into a Mercator-like system seems unlikely.

        ...%360

        You have to be careful using modulus on float data, it integerises:

        print +(123.456 + 180 )%360;; 303

        Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
        "Science is about questioning the status quo. Questioning authority".
        In the absence of evidence, opinion is indistinguishable from prejudice.