Simpler mathematic formula to find latitude coordinate mapping to lines “equally sized” on mercator...












1














I'm implementing a map visualization atop a mercator projected map (e.g google maps) where each circle appears to be the same size on the map:



enter image description here.



At the equator, a circle plotted with a one degree latitude x one degree longitude looks like a circle, but as you go further away from the equator, the height of a one degree appears taller on the map, so we scale it back. Thus the "equally sized" circles are in fact squatter and squatter dimensions.



We're taking a number of lat/lon points and mapping them to the appropriate circle, and then plotting the circles with darker colors indicating a higher density. So this finally leads to may question: is there a simple formula to calculate the correct latitude offset for a given latitude point? For longitude, it's simply the floor, but for latitude, this won't work.



I'm currently finding the appropriate 'bin' or floor for the latitude by counting up cos(angle) size chunks from the equator; at zero, one degree works and as you go north, the delta decreases. Here's sample python code:



def makelatbins():
"""
make steps of latitude that will appear equal hieght on the
mercator projecion based google map; if we did equal size degrees
the height of each circle gets taller as you go further north.
"""
import math
latbins =
lat = 0
while lat < 84:
latbins.append(lat)
lat += math.cos(math.radians(lat))
return latbins

latbins = makelatbins()

def latbin(lat):
import bisect
index = bisect.bisect_left(latbins, lat)
return latbins[index]


I have this nagging sense that there should be a simple formula to compute the appropriate floor function for a latitude point, but can't figure it out.










share|cite|improve this question





























    1














    I'm implementing a map visualization atop a mercator projected map (e.g google maps) where each circle appears to be the same size on the map:



    enter image description here.



    At the equator, a circle plotted with a one degree latitude x one degree longitude looks like a circle, but as you go further away from the equator, the height of a one degree appears taller on the map, so we scale it back. Thus the "equally sized" circles are in fact squatter and squatter dimensions.



    We're taking a number of lat/lon points and mapping them to the appropriate circle, and then plotting the circles with darker colors indicating a higher density. So this finally leads to may question: is there a simple formula to calculate the correct latitude offset for a given latitude point? For longitude, it's simply the floor, but for latitude, this won't work.



    I'm currently finding the appropriate 'bin' or floor for the latitude by counting up cos(angle) size chunks from the equator; at zero, one degree works and as you go north, the delta decreases. Here's sample python code:



    def makelatbins():
    """
    make steps of latitude that will appear equal hieght on the
    mercator projecion based google map; if we did equal size degrees
    the height of each circle gets taller as you go further north.
    """
    import math
    latbins =
    lat = 0
    while lat < 84:
    latbins.append(lat)
    lat += math.cos(math.radians(lat))
    return latbins

    latbins = makelatbins()

    def latbin(lat):
    import bisect
    index = bisect.bisect_left(latbins, lat)
    return latbins[index]


    I have this nagging sense that there should be a simple formula to compute the appropriate floor function for a latitude point, but can't figure it out.










    share|cite|improve this question



























      1












      1








      1







      I'm implementing a map visualization atop a mercator projected map (e.g google maps) where each circle appears to be the same size on the map:



      enter image description here.



      At the equator, a circle plotted with a one degree latitude x one degree longitude looks like a circle, but as you go further away from the equator, the height of a one degree appears taller on the map, so we scale it back. Thus the "equally sized" circles are in fact squatter and squatter dimensions.



      We're taking a number of lat/lon points and mapping them to the appropriate circle, and then plotting the circles with darker colors indicating a higher density. So this finally leads to may question: is there a simple formula to calculate the correct latitude offset for a given latitude point? For longitude, it's simply the floor, but for latitude, this won't work.



      I'm currently finding the appropriate 'bin' or floor for the latitude by counting up cos(angle) size chunks from the equator; at zero, one degree works and as you go north, the delta decreases. Here's sample python code:



      def makelatbins():
      """
      make steps of latitude that will appear equal hieght on the
      mercator projecion based google map; if we did equal size degrees
      the height of each circle gets taller as you go further north.
      """
      import math
      latbins =
      lat = 0
      while lat < 84:
      latbins.append(lat)
      lat += math.cos(math.radians(lat))
      return latbins

      latbins = makelatbins()

      def latbin(lat):
      import bisect
      index = bisect.bisect_left(latbins, lat)
      return latbins[index]


      I have this nagging sense that there should be a simple formula to compute the appropriate floor function for a latitude point, but can't figure it out.










      share|cite|improve this question















      I'm implementing a map visualization atop a mercator projected map (e.g google maps) where each circle appears to be the same size on the map:



      enter image description here.



      At the equator, a circle plotted with a one degree latitude x one degree longitude looks like a circle, but as you go further away from the equator, the height of a one degree appears taller on the map, so we scale it back. Thus the "equally sized" circles are in fact squatter and squatter dimensions.



      We're taking a number of lat/lon points and mapping them to the appropriate circle, and then plotting the circles with darker colors indicating a higher density. So this finally leads to may question: is there a simple formula to calculate the correct latitude offset for a given latitude point? For longitude, it's simply the floor, but for latitude, this won't work.



      I'm currently finding the appropriate 'bin' or floor for the latitude by counting up cos(angle) size chunks from the equator; at zero, one degree works and as you go north, the delta decreases. Here's sample python code:



      def makelatbins():
      """
      make steps of latitude that will appear equal hieght on the
      mercator projecion based google map; if we did equal size degrees
      the height of each circle gets taller as you go further north.
      """
      import math
      latbins =
      lat = 0
      while lat < 84:
      latbins.append(lat)
      lat += math.cos(math.radians(lat))
      return latbins

      latbins = makelatbins()

      def latbin(lat):
      import bisect
      index = bisect.bisect_left(latbins, lat)
      return latbins[index]


      I have this nagging sense that there should be a simple formula to compute the appropriate floor function for a latitude point, but can't figure it out.







      trigonometry geodesy






      share|cite|improve this question















      share|cite|improve this question













      share|cite|improve this question




      share|cite|improve this question








      edited Nov 26 at 0:47









      Henry

      98k475159




      98k475159










      asked Oct 27 '11 at 1:20









      Karl R

      1085




      1085






















          2 Answers
          2






          active

          oldest

          votes


















          2














          On a Mercator projection the verticals are lines of constant longitude with equal spacing. The horizontals are lines of constant latitude, with $x=R(lambda-lambda_0)$, where $R$ is the radius of the earth and $lambda_0$ is the central longitude of the map. $y=Rln(tanphi + sec phi)$ so a small step in $y$ corresponds to $R sec phi$ in distance. So you should scale your verticals by $1/sec phi$ to keep the circles round on the map.






          share|cite|improve this answer





















          • Yes, scaling by 1/secϕ, or cos(ϕ) gives the correct ratio, but in addition to finding the correct height of the circle, I need to know the latitude coordinate that maps to an equal height circles all the way from 0 latitude. That's why right now I'm counting in discreet steps of cos(ϕ) from ϕ = 0. But I'm wondering if there's a formulaic way to find the nearest boundary without counting up from 0.
            – Karl R
            Oct 27 '11 at 14:44










          • The equation $y=Rln(tanphi + sec phi)$ shows how to do that, as it is the integral of $sec phi$. $R$ is not the earth radius, it is just your scale factor. To find what $phi$ corresponds to a particular $y$, you need to invert this, which you can do numerically.
            – Ross Millikan
            Oct 27 '11 at 15:25










          • I think I'm getting closer to understanding this, perhaps a concrete example will help. I'm mapping all of a collection of lat,lons to bins of equal square sizes on the map, and then I will plot circles for each square. For a point at position 78.3, 68.3, I need to find which counter this maps to. I can map it to longitude position 68.0, since each longitude box is equal width. I know the height of the box will be scaled by cos(78.3) = 0.203. But where is the starting point of the box in latitude?
            – Karl R
            Oct 27 '11 at 20:56










          • (continued) You are saying that I can use y=R*ln(tan(lat) + sec(lat)) to find the starting point of the box. What is R here? The scaling factor, cos(78.3)? (upvoting for the time you have taken already).
            – Karl R
            Oct 27 '11 at 20:58












          • You have defined your horizontal scale to be one degree per box, so if you plot the whole earth you need to have a width of 360 boxes. In this case $R=180/pi$ to make the $x$ and $y$ scales match as well as possible. In the other axis you need to decide how far north you are going to go. If your map is square, it will go up to 85.05113 deg latitude, corresponding to $y=pi$ for 180 boxes. Latitude 78.3 plots to $y=2.2783$, or box number 130.537
            – Ross Millikan
            Oct 27 '11 at 21:06





















          1














          I know this is an old question, but in case you're still interested there is a solution that doesn't involve counting up $cos(phi)$: you can use a binary search to find the latitude of a particular box.



          Here's some (python-like) pseudo-code for it:



          latitude = 0 degrees
          delta = 45 degrees
          while convert_latitude_to_box_number(latitude) != desired_box_number:
          if desired_box_number > convert_latitude_to_box_number(latitude):
          latitude += delta
          else:
          latitude -= delta
          delta = delta / 2
          //end while (also, latitude now corresponds to desired box)


          While this solution is O(log(n)) time and may seem better than the O(n) time $cos(phi)$ solution, you should weigh the cost of computing $R ln(cos(phi)+sec(phi))$ for each iteration.



          Since n is bound by 90 degrees in the case of a map, you might be better off just sticking with your $cos(phi)$ solution, but I figured this was worth posting to present another approach.






          share|cite|improve this answer





















            Your Answer





            StackExchange.ifUsing("editor", function () {
            return StackExchange.using("mathjaxEditing", function () {
            StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
            StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
            });
            });
            }, "mathjax-editing");

            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "69"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            noCode: true, onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f76229%2fsimpler-mathematic-formula-to-find-latitude-coordinate-mapping-to-lines-equally%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            2














            On a Mercator projection the verticals are lines of constant longitude with equal spacing. The horizontals are lines of constant latitude, with $x=R(lambda-lambda_0)$, where $R$ is the radius of the earth and $lambda_0$ is the central longitude of the map. $y=Rln(tanphi + sec phi)$ so a small step in $y$ corresponds to $R sec phi$ in distance. So you should scale your verticals by $1/sec phi$ to keep the circles round on the map.






            share|cite|improve this answer





















            • Yes, scaling by 1/secϕ, or cos(ϕ) gives the correct ratio, but in addition to finding the correct height of the circle, I need to know the latitude coordinate that maps to an equal height circles all the way from 0 latitude. That's why right now I'm counting in discreet steps of cos(ϕ) from ϕ = 0. But I'm wondering if there's a formulaic way to find the nearest boundary without counting up from 0.
              – Karl R
              Oct 27 '11 at 14:44










            • The equation $y=Rln(tanphi + sec phi)$ shows how to do that, as it is the integral of $sec phi$. $R$ is not the earth radius, it is just your scale factor. To find what $phi$ corresponds to a particular $y$, you need to invert this, which you can do numerically.
              – Ross Millikan
              Oct 27 '11 at 15:25










            • I think I'm getting closer to understanding this, perhaps a concrete example will help. I'm mapping all of a collection of lat,lons to bins of equal square sizes on the map, and then I will plot circles for each square. For a point at position 78.3, 68.3, I need to find which counter this maps to. I can map it to longitude position 68.0, since each longitude box is equal width. I know the height of the box will be scaled by cos(78.3) = 0.203. But where is the starting point of the box in latitude?
              – Karl R
              Oct 27 '11 at 20:56










            • (continued) You are saying that I can use y=R*ln(tan(lat) + sec(lat)) to find the starting point of the box. What is R here? The scaling factor, cos(78.3)? (upvoting for the time you have taken already).
              – Karl R
              Oct 27 '11 at 20:58












            • You have defined your horizontal scale to be one degree per box, so if you plot the whole earth you need to have a width of 360 boxes. In this case $R=180/pi$ to make the $x$ and $y$ scales match as well as possible. In the other axis you need to decide how far north you are going to go. If your map is square, it will go up to 85.05113 deg latitude, corresponding to $y=pi$ for 180 boxes. Latitude 78.3 plots to $y=2.2783$, or box number 130.537
              – Ross Millikan
              Oct 27 '11 at 21:06


















            2














            On a Mercator projection the verticals are lines of constant longitude with equal spacing. The horizontals are lines of constant latitude, with $x=R(lambda-lambda_0)$, where $R$ is the radius of the earth and $lambda_0$ is the central longitude of the map. $y=Rln(tanphi + sec phi)$ so a small step in $y$ corresponds to $R sec phi$ in distance. So you should scale your verticals by $1/sec phi$ to keep the circles round on the map.






            share|cite|improve this answer





















            • Yes, scaling by 1/secϕ, or cos(ϕ) gives the correct ratio, but in addition to finding the correct height of the circle, I need to know the latitude coordinate that maps to an equal height circles all the way from 0 latitude. That's why right now I'm counting in discreet steps of cos(ϕ) from ϕ = 0. But I'm wondering if there's a formulaic way to find the nearest boundary without counting up from 0.
              – Karl R
              Oct 27 '11 at 14:44










            • The equation $y=Rln(tanphi + sec phi)$ shows how to do that, as it is the integral of $sec phi$. $R$ is not the earth radius, it is just your scale factor. To find what $phi$ corresponds to a particular $y$, you need to invert this, which you can do numerically.
              – Ross Millikan
              Oct 27 '11 at 15:25










            • I think I'm getting closer to understanding this, perhaps a concrete example will help. I'm mapping all of a collection of lat,lons to bins of equal square sizes on the map, and then I will plot circles for each square. For a point at position 78.3, 68.3, I need to find which counter this maps to. I can map it to longitude position 68.0, since each longitude box is equal width. I know the height of the box will be scaled by cos(78.3) = 0.203. But where is the starting point of the box in latitude?
              – Karl R
              Oct 27 '11 at 20:56










            • (continued) You are saying that I can use y=R*ln(tan(lat) + sec(lat)) to find the starting point of the box. What is R here? The scaling factor, cos(78.3)? (upvoting for the time you have taken already).
              – Karl R
              Oct 27 '11 at 20:58












            • You have defined your horizontal scale to be one degree per box, so if you plot the whole earth you need to have a width of 360 boxes. In this case $R=180/pi$ to make the $x$ and $y$ scales match as well as possible. In the other axis you need to decide how far north you are going to go. If your map is square, it will go up to 85.05113 deg latitude, corresponding to $y=pi$ for 180 boxes. Latitude 78.3 plots to $y=2.2783$, or box number 130.537
              – Ross Millikan
              Oct 27 '11 at 21:06
















            2












            2








            2






            On a Mercator projection the verticals are lines of constant longitude with equal spacing. The horizontals are lines of constant latitude, with $x=R(lambda-lambda_0)$, where $R$ is the radius of the earth and $lambda_0$ is the central longitude of the map. $y=Rln(tanphi + sec phi)$ so a small step in $y$ corresponds to $R sec phi$ in distance. So you should scale your verticals by $1/sec phi$ to keep the circles round on the map.






            share|cite|improve this answer












            On a Mercator projection the verticals are lines of constant longitude with equal spacing. The horizontals are lines of constant latitude, with $x=R(lambda-lambda_0)$, where $R$ is the radius of the earth and $lambda_0$ is the central longitude of the map. $y=Rln(tanphi + sec phi)$ so a small step in $y$ corresponds to $R sec phi$ in distance. So you should scale your verticals by $1/sec phi$ to keep the circles round on the map.







            share|cite|improve this answer












            share|cite|improve this answer



            share|cite|improve this answer










            answered Oct 27 '11 at 4:21









            Ross Millikan

            291k23196370




            291k23196370












            • Yes, scaling by 1/secϕ, or cos(ϕ) gives the correct ratio, but in addition to finding the correct height of the circle, I need to know the latitude coordinate that maps to an equal height circles all the way from 0 latitude. That's why right now I'm counting in discreet steps of cos(ϕ) from ϕ = 0. But I'm wondering if there's a formulaic way to find the nearest boundary without counting up from 0.
              – Karl R
              Oct 27 '11 at 14:44










            • The equation $y=Rln(tanphi + sec phi)$ shows how to do that, as it is the integral of $sec phi$. $R$ is not the earth radius, it is just your scale factor. To find what $phi$ corresponds to a particular $y$, you need to invert this, which you can do numerically.
              – Ross Millikan
              Oct 27 '11 at 15:25










            • I think I'm getting closer to understanding this, perhaps a concrete example will help. I'm mapping all of a collection of lat,lons to bins of equal square sizes on the map, and then I will plot circles for each square. For a point at position 78.3, 68.3, I need to find which counter this maps to. I can map it to longitude position 68.0, since each longitude box is equal width. I know the height of the box will be scaled by cos(78.3) = 0.203. But where is the starting point of the box in latitude?
              – Karl R
              Oct 27 '11 at 20:56










            • (continued) You are saying that I can use y=R*ln(tan(lat) + sec(lat)) to find the starting point of the box. What is R here? The scaling factor, cos(78.3)? (upvoting for the time you have taken already).
              – Karl R
              Oct 27 '11 at 20:58












            • You have defined your horizontal scale to be one degree per box, so if you plot the whole earth you need to have a width of 360 boxes. In this case $R=180/pi$ to make the $x$ and $y$ scales match as well as possible. In the other axis you need to decide how far north you are going to go. If your map is square, it will go up to 85.05113 deg latitude, corresponding to $y=pi$ for 180 boxes. Latitude 78.3 plots to $y=2.2783$, or box number 130.537
              – Ross Millikan
              Oct 27 '11 at 21:06




















            • Yes, scaling by 1/secϕ, or cos(ϕ) gives the correct ratio, but in addition to finding the correct height of the circle, I need to know the latitude coordinate that maps to an equal height circles all the way from 0 latitude. That's why right now I'm counting in discreet steps of cos(ϕ) from ϕ = 0. But I'm wondering if there's a formulaic way to find the nearest boundary without counting up from 0.
              – Karl R
              Oct 27 '11 at 14:44










            • The equation $y=Rln(tanphi + sec phi)$ shows how to do that, as it is the integral of $sec phi$. $R$ is not the earth radius, it is just your scale factor. To find what $phi$ corresponds to a particular $y$, you need to invert this, which you can do numerically.
              – Ross Millikan
              Oct 27 '11 at 15:25










            • I think I'm getting closer to understanding this, perhaps a concrete example will help. I'm mapping all of a collection of lat,lons to bins of equal square sizes on the map, and then I will plot circles for each square. For a point at position 78.3, 68.3, I need to find which counter this maps to. I can map it to longitude position 68.0, since each longitude box is equal width. I know the height of the box will be scaled by cos(78.3) = 0.203. But where is the starting point of the box in latitude?
              – Karl R
              Oct 27 '11 at 20:56










            • (continued) You are saying that I can use y=R*ln(tan(lat) + sec(lat)) to find the starting point of the box. What is R here? The scaling factor, cos(78.3)? (upvoting for the time you have taken already).
              – Karl R
              Oct 27 '11 at 20:58












            • You have defined your horizontal scale to be one degree per box, so if you plot the whole earth you need to have a width of 360 boxes. In this case $R=180/pi$ to make the $x$ and $y$ scales match as well as possible. In the other axis you need to decide how far north you are going to go. If your map is square, it will go up to 85.05113 deg latitude, corresponding to $y=pi$ for 180 boxes. Latitude 78.3 plots to $y=2.2783$, or box number 130.537
              – Ross Millikan
              Oct 27 '11 at 21:06


















            Yes, scaling by 1/secϕ, or cos(ϕ) gives the correct ratio, but in addition to finding the correct height of the circle, I need to know the latitude coordinate that maps to an equal height circles all the way from 0 latitude. That's why right now I'm counting in discreet steps of cos(ϕ) from ϕ = 0. But I'm wondering if there's a formulaic way to find the nearest boundary without counting up from 0.
            – Karl R
            Oct 27 '11 at 14:44




            Yes, scaling by 1/secϕ, or cos(ϕ) gives the correct ratio, but in addition to finding the correct height of the circle, I need to know the latitude coordinate that maps to an equal height circles all the way from 0 latitude. That's why right now I'm counting in discreet steps of cos(ϕ) from ϕ = 0. But I'm wondering if there's a formulaic way to find the nearest boundary without counting up from 0.
            – Karl R
            Oct 27 '11 at 14:44












            The equation $y=Rln(tanphi + sec phi)$ shows how to do that, as it is the integral of $sec phi$. $R$ is not the earth radius, it is just your scale factor. To find what $phi$ corresponds to a particular $y$, you need to invert this, which you can do numerically.
            – Ross Millikan
            Oct 27 '11 at 15:25




            The equation $y=Rln(tanphi + sec phi)$ shows how to do that, as it is the integral of $sec phi$. $R$ is not the earth radius, it is just your scale factor. To find what $phi$ corresponds to a particular $y$, you need to invert this, which you can do numerically.
            – Ross Millikan
            Oct 27 '11 at 15:25












            I think I'm getting closer to understanding this, perhaps a concrete example will help. I'm mapping all of a collection of lat,lons to bins of equal square sizes on the map, and then I will plot circles for each square. For a point at position 78.3, 68.3, I need to find which counter this maps to. I can map it to longitude position 68.0, since each longitude box is equal width. I know the height of the box will be scaled by cos(78.3) = 0.203. But where is the starting point of the box in latitude?
            – Karl R
            Oct 27 '11 at 20:56




            I think I'm getting closer to understanding this, perhaps a concrete example will help. I'm mapping all of a collection of lat,lons to bins of equal square sizes on the map, and then I will plot circles for each square. For a point at position 78.3, 68.3, I need to find which counter this maps to. I can map it to longitude position 68.0, since each longitude box is equal width. I know the height of the box will be scaled by cos(78.3) = 0.203. But where is the starting point of the box in latitude?
            – Karl R
            Oct 27 '11 at 20:56












            (continued) You are saying that I can use y=R*ln(tan(lat) + sec(lat)) to find the starting point of the box. What is R here? The scaling factor, cos(78.3)? (upvoting for the time you have taken already).
            – Karl R
            Oct 27 '11 at 20:58






            (continued) You are saying that I can use y=R*ln(tan(lat) + sec(lat)) to find the starting point of the box. What is R here? The scaling factor, cos(78.3)? (upvoting for the time you have taken already).
            – Karl R
            Oct 27 '11 at 20:58














            You have defined your horizontal scale to be one degree per box, so if you plot the whole earth you need to have a width of 360 boxes. In this case $R=180/pi$ to make the $x$ and $y$ scales match as well as possible. In the other axis you need to decide how far north you are going to go. If your map is square, it will go up to 85.05113 deg latitude, corresponding to $y=pi$ for 180 boxes. Latitude 78.3 plots to $y=2.2783$, or box number 130.537
            – Ross Millikan
            Oct 27 '11 at 21:06






            You have defined your horizontal scale to be one degree per box, so if you plot the whole earth you need to have a width of 360 boxes. In this case $R=180/pi$ to make the $x$ and $y$ scales match as well as possible. In the other axis you need to decide how far north you are going to go. If your map is square, it will go up to 85.05113 deg latitude, corresponding to $y=pi$ for 180 boxes. Latitude 78.3 plots to $y=2.2783$, or box number 130.537
            – Ross Millikan
            Oct 27 '11 at 21:06













            1














            I know this is an old question, but in case you're still interested there is a solution that doesn't involve counting up $cos(phi)$: you can use a binary search to find the latitude of a particular box.



            Here's some (python-like) pseudo-code for it:



            latitude = 0 degrees
            delta = 45 degrees
            while convert_latitude_to_box_number(latitude) != desired_box_number:
            if desired_box_number > convert_latitude_to_box_number(latitude):
            latitude += delta
            else:
            latitude -= delta
            delta = delta / 2
            //end while (also, latitude now corresponds to desired box)


            While this solution is O(log(n)) time and may seem better than the O(n) time $cos(phi)$ solution, you should weigh the cost of computing $R ln(cos(phi)+sec(phi))$ for each iteration.



            Since n is bound by 90 degrees in the case of a map, you might be better off just sticking with your $cos(phi)$ solution, but I figured this was worth posting to present another approach.






            share|cite|improve this answer


























              1














              I know this is an old question, but in case you're still interested there is a solution that doesn't involve counting up $cos(phi)$: you can use a binary search to find the latitude of a particular box.



              Here's some (python-like) pseudo-code for it:



              latitude = 0 degrees
              delta = 45 degrees
              while convert_latitude_to_box_number(latitude) != desired_box_number:
              if desired_box_number > convert_latitude_to_box_number(latitude):
              latitude += delta
              else:
              latitude -= delta
              delta = delta / 2
              //end while (also, latitude now corresponds to desired box)


              While this solution is O(log(n)) time and may seem better than the O(n) time $cos(phi)$ solution, you should weigh the cost of computing $R ln(cos(phi)+sec(phi))$ for each iteration.



              Since n is bound by 90 degrees in the case of a map, you might be better off just sticking with your $cos(phi)$ solution, but I figured this was worth posting to present another approach.






              share|cite|improve this answer
























                1












                1








                1






                I know this is an old question, but in case you're still interested there is a solution that doesn't involve counting up $cos(phi)$: you can use a binary search to find the latitude of a particular box.



                Here's some (python-like) pseudo-code for it:



                latitude = 0 degrees
                delta = 45 degrees
                while convert_latitude_to_box_number(latitude) != desired_box_number:
                if desired_box_number > convert_latitude_to_box_number(latitude):
                latitude += delta
                else:
                latitude -= delta
                delta = delta / 2
                //end while (also, latitude now corresponds to desired box)


                While this solution is O(log(n)) time and may seem better than the O(n) time $cos(phi)$ solution, you should weigh the cost of computing $R ln(cos(phi)+sec(phi))$ for each iteration.



                Since n is bound by 90 degrees in the case of a map, you might be better off just sticking with your $cos(phi)$ solution, but I figured this was worth posting to present another approach.






                share|cite|improve this answer












                I know this is an old question, but in case you're still interested there is a solution that doesn't involve counting up $cos(phi)$: you can use a binary search to find the latitude of a particular box.



                Here's some (python-like) pseudo-code for it:



                latitude = 0 degrees
                delta = 45 degrees
                while convert_latitude_to_box_number(latitude) != desired_box_number:
                if desired_box_number > convert_latitude_to_box_number(latitude):
                latitude += delta
                else:
                latitude -= delta
                delta = delta / 2
                //end while (also, latitude now corresponds to desired box)


                While this solution is O(log(n)) time and may seem better than the O(n) time $cos(phi)$ solution, you should weigh the cost of computing $R ln(cos(phi)+sec(phi))$ for each iteration.



                Since n is bound by 90 degrees in the case of a map, you might be better off just sticking with your $cos(phi)$ solution, but I figured this was worth posting to present another approach.







                share|cite|improve this answer












                share|cite|improve this answer



                share|cite|improve this answer










                answered Mar 8 '13 at 1:47









                nickiaconis

                1111




                1111






























                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Mathematics Stack Exchange!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    Use MathJax to format equations. MathJax reference.


                    To learn more, see our tips on writing great answers.





                    Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                    Please pay close attention to the following guidance:


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f76229%2fsimpler-mathematic-formula-to-find-latitude-coordinate-mapping-to-lines-equally%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Probability when a professor distributes a quiz and homework assignment to a class of n students.

                    Aardman Animations

                    Are they similar matrix