# Lattitude and Longitude to X,Y

• k_squared
In summary, the program places markers on a map of the United States, but the conversion factor between degrees and kilometers varies drastically depending on the location.
k_squared
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 alot.

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.

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.

Last edited by a moderator:
Last edited:

## 1. What is the purpose of using latitude and longitude to determine X and Y coordinates?

The use of latitude and longitude to determine X and Y coordinates helps to accurately pinpoint a specific location on Earth's surface. This is particularly useful for navigation and mapping purposes, as well as for determining distances between two points.

## 2. How are latitude and longitude used to calculate X and Y coordinates?

Latitude and longitude are used to measure the angular distance of a location from the equator and the prime meridian, respectively. These measurements are then converted into X and Y coordinates using mathematical formulas and trigonometric functions.

## 3. Can latitude and longitude be converted to X and Y coordinates for any location on Earth?

Yes, latitude and longitude can be used to calculate X and Y coordinates for any location on Earth. However, the accuracy of the coordinates may vary depending on the projection or coordinate system being used. Different projections and coordinate systems are better suited for different purposes and locations.

## 4. Are X and Y coordinates the same as latitude and longitude?

No, X and Y coordinates are not the same as latitude and longitude. Latitude and longitude refer to the angular distance of a location from the equator and prime meridian, while X and Y coordinates refer to the Cartesian coordinates on a two-dimensional plane. However, they are closely related as X and Y coordinates can be calculated from latitude and longitude measurements.

## 5. How do changes in latitude and longitude affect X and Y coordinates?

Changes in latitude and longitude directly affect X and Y coordinates. As the latitude and longitude of a location change, the X and Y coordinates will also change accordingly. This is because the X and Y coordinates are based on the angular distance of a location from the equator and prime meridian, which are used to determine latitude and longitude.

Replies
19
Views
26K
Replies
9
Views
2K
Replies
2
Views
1K
Replies
1
Views
2K
Replies
9
Views
5K
Replies
5
Views
1K
Replies
2
Views
5K
Replies
4
Views
3K
Replies
1
Views
2K