Results 1 to 7 of 7

Thread: HELP! How to turn a circle into a square?

  1. #1
    Guild Expert Facebook Connected Caenwyr's Avatar
    Join Date
    Apr 2012
    Location
    Flanders, Belgium
    Posts
    1,276

    Default HELP! How to turn a circle into a square?

    Okay, the title was a bit dramatic maybe, but it got you clicking, didn't it . Basically I'm out of inspiration for this terrible conundrum.

    What I'm after is the following. I want a way to stretch a circle - horizontally only - so that it fits within a square. Or very practically, I want to turn this:

    Click image for larger version. 

Name:	Earth_Apian-II.jpg 
Views:	46 
Size:	817.2 KB 
ID:	113666 (the Apian-II double hemisphere projection)

    into this:

    Click image for larger version. 

Name:	Earth_equirectangular.jpg 
Views:	27 
Size:	590.1 KB 
ID:	113667 (the equirectangular projection)

    I know it can easily be done the other way around, e.g. using NASA's awesome freeware tool G.Projector (which is what I used to turn the second image into the first one!), but I can't think of a way to do it in the direction I want: from Apian-II to equirectangular.

    Quote Originally Posted by random nerdy rant!!
    Basically what I'd need is a way to take each disc in that first image, and stretch each of the pixel rows horizontally with such an amount that they all end up just as wide as the equator. Obviously the stretch factor would depend on how far away that particular pixel row is from the "equator row". Then I just need to stitch both squares et voilŕ, I'm back at the equirectangular!

    For each row of pixels, the stretch factor would be Nequator / Nactual, with
    • Nequator being the number of pixels on the equator, which is known, and
    • Nactual being the sine of the angle that has that particular row height (measured from the equator, as a fraction of the height of the poles) as its cosine.


    That last bit sounds complicated but actually you just take the sine of acos (Hactual / Hpole), with
    • Hactual being the vertical distance between the equator row and the actual row, and
    • Hpole being the vertical distance between the equator and the pole, which is known (and identical to Nequator since we're talking about a perfect circle here!)


    But "simple" as that may sound, I have no knowledge of coding, and no idea whatsoever of how I can turn this into something that actually does the thing I want, no matter how long I ponder on it...
    So all in all, I'm at a loss. It's not a terrible inconvenience, I should be able to work around it, but man would it be awesome to turn my Apian-II map into an equirectangular one again...
    Caenwyr Cartography


    Check out my portfolio!

  2. #2
    Guild Grand Master Azélor's Avatar
    Join Date
    Jul 2008
    Location
    Québec
    Posts
    3,363

    Default

    I'm not sure what you are trying to reproject here, but it will stretch your map so bad that you will have to redraw it.

  3. #3
    Guild Expert Facebook Connected Caenwyr's Avatar
    Join Date
    Apr 2012
    Location
    Flanders, Belgium
    Posts
    1,276

    Default

    Quote Originally Posted by Azélor View Post
    I'm not sure what you are trying to reproject here, but it will stretch your map so bad that you will have to redraw it.
    Well no, it should simply turn that first map (Apian-II) into that second map (Equirectangular). No horrible stretching anywhere, just a different projection.

    Anyone else has an idea?
    Caenwyr Cartography


    Check out my portfolio!

  4. #4
    Guild Grand Master Azélor's Avatar
    Join Date
    Jul 2008
    Location
    Québec
    Posts
    3,363

    Default

    It can work if your map is georeferenced which is not a problem if you are working with the Earth.

    I think this thread could be helpful for you : https://www.cartographersguild.com/s...049#post395049

  5. #5
    Administrator waldronate's Avatar
    Join Date
    Mar 2007
    Location
    The High Desert
    Posts
    3,561

    Default

    Apian II can't be transformed into Equirectangular by simply stretching things horizontally, if I'm reading it correctly. Depending on your accuracy needs, you might be able to use Mollweide instead.

    My elderly Windows program ReprojectImage ( http://www.fracterra.com/ReprojectImage.zip ) can do something like this:
    Click image for larger version. 

Name:	Untitled-1.jpg 
Views:	44 
Size:	67.9 KB 
ID:	113675

    If you look closely, you'll see that there is a bit of stretch in the polar regions. Doing this process twice and assembling the pieces in something like Photoshop should get you most of the way there if you can't find an exact transform.

  6. #6
    Guild Expert Facebook Connected Caenwyr's Avatar
    Join Date
    Apr 2012
    Location
    Flanders, Belgium
    Posts
    1,276

    Default

    Quote Originally Posted by waldronate View Post
    Apian II can't be transformed into Equirectangular by simply stretching things horizontally, if I'm reading it correctly. Depending on your accuracy needs, you might be able to use Mollweide instead.

    My elderly Windows program ReprojectImage ( http://www.fracterra.com/ReprojectImage.zip ) can do something like this:
    Click image for larger version. 

Name:	Untitled-1.jpg 
Views:	44 
Size:	67.9 KB 
ID:	113675

    If you look closely, you'll see that there is a bit of stretch in the polar regions. Doing this process twice and assembling the pieces in something like Photoshop should get you most of the way there if you can't find an exact transform.
    Sorry for not answering earlier, Waldronate, but man, you saved me here! Thanks a bunch!!
    Caenwyr Cartography


    Check out my portfolio!

  7. #7
    Administrator waldronate's Avatar
    Join Date
    Mar 2007
    Location
    The High Desert
    Posts
    3,561

    Default

    Glad that I was able to help. It's nice when one of my elderly pieces of software can get out and stretch its legs a little.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •