Lattitude and Longitude to X,Y

  • Thread starter Thread starter k_squared
  • Start date Start date
  • Tags Tags
    Longitude
Click For Summary

Discussion Overview

The discussion revolves around converting latitude and longitude coordinates to a Cartesian coordinate system (X, Y) for mapping purposes, specifically in the context of a Civil War battlemap generator. Participants explore the complexities of scaling factors for different coordinates and the mathematical principles involved in this conversion.

Discussion Character

  • Technical explanation
  • Mathematical reasoning
  • Debate/contested

Main Points Raised

  • One participant describes an attempt to calculate a conversion factor between latitude/longitude and pixel coordinates, noting variability in factors across different locations.
  • Another participant points out that the size of a degree of longitude varies with latitude, while the size of a degree of latitude remains constant, suggesting the need for different scaling factors in X and Y.
  • A participant seeks clarification on the function that defines the scaling factor for X, expressing limitations in their mathematical background.
  • One reply suggests searching for "longitude x latitude y" for more information.
  • Another participant mentions that while accurate conversion can be complex, a rough approximation can be made for smaller distances.
  • One participant shares a calculation that yields unexpected results, questioning the validity of their approach and the constants involved.
  • Another participant provides a rough estimate of the distance represented by degrees at the equator and highlights the importance of using radians in calculations.
  • A participant discusses their efforts to develop a new conversion ratio for vertical scaling, questioning the validity of a fixed conversion ratio for longitude.
  • One participant corrects earlier statements about the scaling factors and introduces the concept of the Lambert Conformal Projection as a method for minimizing distortion in navigational charts.
  • Another participant inquires about the projection type of a specific map and seeks clarification on a mathematical notation used in the context of cosine functions.

Areas of Agreement / Disagreement

Participants express differing views on the complexity of accurately converting geographic coordinates to Cartesian coordinates, with some suggesting that a fixed conversion ratio may not be valid. There is no consensus on the best approach or the accuracy of the proposed methods.

Contextual Notes

Participants mention limitations in their mathematical knowledge and the complexity of the calculations involved, indicating that assumptions about the Earth's shape and the projection method may affect the results.

k_squared
Messages
62
Reaction score
0
I was writing a program to place a markers on a map of the United States, for a Civil War battlemap generator. I tried this:

Assuming x,y and lat/long are superimposed yet different coordinate systems. For example, if a coordinate system with a unary equivalent to 12 on the other were to exist, express two concurrent points. Then use the distance formula:
sqrt( (24+12)^2+(24+12)^2)/sqrt ( (2+1)^2+(2+1)) = 12 (as do all other concurrent values.)

I found pixel where the four corners states meet (195,306), and a point in Florida. Using the formula above, with lat/long and x/y I calculated a conversion factor of about 14. However, when I did the four corners and the Lake Michigan. The conversion factors varied dramitcally. I thusly assume the the lines curve, even on a flat projection where Texas looks like its near Florida? My code went thus...
Code:
const float refcoord[2]={36.998976, -109.045172};
const float conversionfactor=0.17975951;
const int refpix[2]={195,306};
void drawID(float lat, float lon, FXint& x,FXint& y){
x=refpix[0]-(refcoord[0]-lat)/conversionfactor;
y=refpix[1]-(refcoord[1]-lon)/conversionfactor;
}

If this is the problem I think it is, could someone link me to some trig help? Thanks a lot.
 
Technology news on Phys.org
The size of a degree of longtitude (x-axis) depends on your latitude (since the Earth gets smaller nearer the poles)
The size of a degree of longitude is the same everywhere.

So you need a different scaling factor in X and Y
 
What is the sequence or function that would define this scaling factor for x? I figured out the ratio above on my own, but my math education at the moment, is limited (trig). Or how would I determine it?

Thanks again.
 
Last edited:
Try googling "longitude x latitude y".
 
Whenever I put in that calculation for (3.141592654/180)*Cos(0)*6367449 I get 111132.950017331. This must be wrong (by several factors of 10). Also, I get 0.0174.. whenever I do the more complex equation (with the polar and equatorial radii) with Cos(0). Cos(0) is, of course, 1.

In fact I seem to be encountering .017 type stuff a LOT. Is that a constant... or something near a standard cos(x)?

Thanks again...
 
There are about 111km/deg at the equator so that's probbaly the value for longtitude in metres.
0.0174 sounds a lot like 1deg in radians - remember you computer/calcualtor is workign in radians
 
Ahhhhhhhhhhhhhhhhhhhhhhhhh... should've seen THAT coming.

Thanks.
 
Because I am a glutton for pain, I have decided to carry this one through (if I can). Aside from the obvious (km means 1000) and the less than obvious (cos(x)*6...). I tried to develop a new conversion ration JUST going vertical (different Y on a fixed X)... but the inaccuracy is .08 every 10 degrees (ratio/ratio, basically.) Is a fixed conversion ratio for longitude even valid? Otherwise, would this piece of code do it?

Code:
const float refcoord[2]={36.999, -109.05};
const float conversionfactor=4.3; ///The AVERAGE conversion ratio
const int refpix[2]={321,337};
void drawID(float lat, float lon, FXint& x,FXint& y){
x=refpix[0]-(refcoord[0]-lat)*(conversionfactor*((float(180/3.141)*cos(float(3.141/180)*lat)) ));
y=refpix[1]-(refcoord[1]-lon)*conversionfactor*-1;
}

It gets practice, it gets fairly close (within the size of my marker) for some locations (St. Louis). However, there is a magic threshold somewhere my X value becomes fairly massive (lake Michigan). (If anyone wants this threshold, I can figure it out by just systematically logging the output of the sub.)

Oh... and thanks for the help.
 
  • #10
mgb_phys said:
The size of a degree of longtitude (x-axis) depends on your latitude (since the Earth gets smaller nearer the poles)
The size of a degree of latitude is the same everywhere.

So you need a different scaling factor in X and Y

Corrected...

Most navigational charts are http://en.wikipedia.org/wiki/Lambert_Conformal_Projection" , which have two parallel lines of latitude secant to the globe and intersecting it. The result is a chart of least distortion for it's scale, and where straight lines drawn on the chart closely approximate great circle lines.

If you're starting with an LCC, you can use http://en.wikipedia.org/wiki/Lambert_Conformal_Projection#Transformation"to convert spheric coordinates into the projection coordinates. This is useful, as this is what most electronic mapping software uses to pinpoint one's location on a digitized chart from GPS feeds.

k_squared said:
Because I am a glutton for pain...

Oh... and thanks for the help.

No worries! http://fer3.com/arc/img/106859.pre-comp%20pages%20from%20afpam11-216.pdf" (but it's the good kind). Be forewarned, however, as it's a 70 MB file.

Check out page 395. I think you may find it helpful. :smile:
 
Last edited by a moderator:
  • #11
Last edited:

Similar threads

  • · Replies 19 ·
Replies
19
Views
27K
  • · Replies 9 ·
Replies
9
Views
3K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 9 ·
Replies
9
Views
5K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 2 ·
Replies
2
Views
5K
  • · Replies 4 ·
Replies
4
Views
4K
  • · Replies 1 ·
Replies
1
Views
3K