Beginner Question: Latitude/Longitude to x,y conversion - understanding output

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Beginner Question: Latitude/Longitude to x,y conversion - understanding output

AdamDynamic
Hi,

I've been scouring the internet for a couple of days now and getting absolutely nowhere - I appreciate this is probably a simple question once you know the answer but any help on this would be appreciated!

I have a series of latitude/longitude coordinates that i want to plot as xy coordinates (i.e. a flat, rectangular map).

I'm using the PyProj Python library to perform the conversion, the problem is I can't determine what the output of the function means or represents?

e.g. Converting [51.5072,0.1275] (what Google tells me is the lat/long for London in the UK) returns [5733755.276187301, 14193.246790158479] for a Mercator projection - my question is '5733755.276187301 of what'? I understand that the library converts to Proj.4 notation (?) but I can't seem to find what the units are, or how I'd map the output onto a 900x1100 rectangle?

I'm using the following conversion formula which I found here

+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m  +no_defs

Any assistance would be great as I haven't been able to get any information from anywhere else. Please let me know if more information would be useful.

Thanks,

Adam
Reply | Threaded
Open this post in threaded view
|

Re: Beginner Question: Latitude/Longitude to x, y conversion - understanding output

Antti Castrén-2
 Hi Adam,

Units are meters. But they are true meters only at the latitude of
true scale of Mercator projection, which in your case is the Equator
(+lat_ts=0, +k=1.0). The string actually tells you that units are
meters (+units=m). At other latitudes meters are 'scaled' as the
projection formulae show. I personally call them pseudo-meters or
Mercator-meters, since they don't represent the correct distance. They
are just units of rectangular coordinates.

The longitude you are projecting (0.1275) is 14 193.25 m away from the
Central Meridian at the Equator. At latitude of London the true
distance from the Central Meridian is less since the meridians are
closer each other.

The latitude you are projecting (51.5072) is 5 733 755.28
pseudo-meters north of the Equator. The first meter is quite close to
real meter, but the scaling affects more and more the further you go
from the Equator. The true distance is only about 4 973 600 m.

To output the map onto 900x1100 rectangle you have to scale the length
and width of your projected map coordinates to 900 and 1100. And then
you have to apply shift of origin of course.

Hope this helps,

  Antti

2014-02-24 11:37 GMT+02:00 AdamDynamic <[hidden email]>:

> Hi,
>
> I've been scouring the internet for a couple of days now and getting
> absolutely nowhere - I appreciate this is probably a simple question once
> you know the answer but any help on this would be appreciated!
>
> I have a series of latitude/longitude coordinates that i want to plot as xy
> coordinates (i.e. a flat, rectangular map).
>
> I'm using the PyProj Python library to perform the conversion, the problem
> is I can't determine what the output of the function means or represents?
>
> e.g. Converting [51.5072,0.1275] (what Google tells me is the lat/long for
> London in the UK) returns [5733755.276187301, 14193.246790158479] for a
> Mercator projection - my question is '5733755.276187301 of what'? I
> understand that the library converts to Proj.4 notation (?) but I can't seem
> to find what the units are, or how I'd map the output onto a 900x1100
> rectangle?
>
> I'm using the following conversion formula which I found  here
> <http://osgeo-org.1560.x6.nabble.com/Google-Mercator-Projection-td3841191.html>
>
> +proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0
> +k=1.0 +units=m  +no_defs
>
> Any assistance would be great as I haven't been able to get any information
> from anywhere else. Please let me know if more information would be useful.
>
> Thanks,
>
> Adam
>
>
>
> --
> View this message in context: http://osgeo-org.1560.x6.nabble.com/Beginner-Question-Latitude-Longitude-to-x-y-conversion-understanding-output-tp5105455.html
> Sent from the PROJ.4 mailing list archive at Nabble.com.
> _______________________________________________
> Proj mailing list
> [hidden email]
> http://lists.maptools.org/mailman/listinfo/proj
_______________________________________________
Proj mailing list
[hidden email]
http://lists.maptools.org/mailman/listinfo/proj
Reply | Threaded
Open this post in threaded view
|

Re: Beginner Question: Latitude/Longitude to x, y conversion - understanding output

AdamDynamic
Ah ok, thanks for that. Reading your answer, the notation makes a bit more sense (a risk of using something you find on the internet without actually understanding it)

To output the map onto 900x1100 rectangle you have to scale the length
and width of your projected map coordinates to 900 and 1100. And then
you have to apply shift of origin of course.
Am I correct in thinking that as I have the latitude of true scale as the Equator, then no shift of origin is required?

In terms of scaling the output, my understanding is that the 'corners' of a projection based on latitude and longitude should be -180,-90 and 180,90 - when I convert these values using the PyProj library I get values of 1E30 for each value (which seems to me clearly wrong). What is the best way to scale the output in terms of min/max values (in 'pseudo-meters') for each corner of my 900x1100 rectangle?

Thanks again for the help!

Adam
Reply | Threaded
Open this post in threaded view
|

Re: Beginner Question: Latitude/Longitude to x, y conversion - understanding output

José Alberto Gonçalves
Adam

I think you have to change the order of your coordinates. The default input for PROJ is (lon,lat) and the default output is (Easting,Northing).
I used PROJ in the command line to check.

You have done:
echo 51.5072 0.1275 | proj +proj=merc +a=6378137 +b=6378137
5733755.28      14193.25


and it should have been:
echo 0.1275 51.5072 <span class="skype_c2c_container" dir="ltr" tabindex="-1" onmouseover="SkypeClick2Call.MenuInjectionHandler.showMenu(this, event)" onmouseout="SkypeClick2Call.MenuInjectionHandler.hideMenu(event)"> | proj +proj=merc +a=6378137 +b=6378137
14193.24        6711506.71

The local deformation of lengths at latitude LAT is approximately 1/COS(LAT)

Regards

José Gonçalves



<div onmouseout="SkypeClick2Call.MenuInjectionHandler.hideMenu(event)" onmouseover="SkypeClick2Call.MenuInjectionHandler.showMenu(this, event)" style id="skype_c2c_menu_container" class="skype_c2c_menu_container">
You'll need Skype CreditFree via Skype


2014-02-24 13:30 GMT+00:00 AdamDynamic <[hidden email]>:
Ah ok, thanks for that. Reading your answer, the notation makes a bit more
sense (a risk of using something you find on the internet without actually
understanding it)


> To output the map onto 900x1100 rectangle you have to scale the length
> and width of your projected map coordinates to 900 and 1100. And then
> you have to apply shift of origin of course.

Am I correct in thinking that as I have the latitude of true scale as the
Equator, then no shift of origin is required?

In terms of scaling the output, my understanding is that the 'corners' of a
projection based on latitude and longitude should be -180,-90 and 180,90 -
when I convert these values using the PyProj library I get values of 1E30
for each value (which seems to me clearly wrong). What is the best way to
scale the output in terms of min/max values (in 'pseudo-meters') for each
corner of my 900x1100 rectangle?

Thanks again for the help!

Adam




--
View this message in context: http://osgeo-org.1560.x6.nabble.com/Beginner-Question-Latitude-Longitude-to-x-y-conversion-understanding-output-tp5105455p5105524.html
Sent from the PROJ.4 mailing list archive at Nabble.com.
_______________________________________________
Proj mailing list
[hidden email]
http://lists.maptools.org/mailman/listinfo/proj


_______________________________________________
Proj mailing list
[hidden email]
http://lists.maptools.org/mailman/listinfo/proj
Reply | Threaded
Open this post in threaded view
|

Re: Beginner Question: Latitude/Longitude to x, y conversion - understanding output

Antti Castrén-2
In reply to this post by AdamDynamic
2014-02-24 15:30 GMT+02:00 AdamDynamic <[hidden email]>:
>> To output the map onto 900x1100 rectangle you have to scale the length
>> and width of your projected map coordinates to 900 and 1100. And then
>> you have to apply shift of origin of course.
>
> Am I correct in thinking that as I have the latitude of true scale as the
> Equator, then no shift of origin is required?

It depends on the area of interest and the coordinate system of your
map image (where your image's origin is). If you are mapping the
World, I think your image origin (0,0) will be somewhere else than in
the center. Or it could be there if your image coordinate ranges are
-450 to 450 and -550 to 550.

> In terms of scaling the output, my understanding is that the 'corners' of a
> projection based on latitude and longitude should be -180,-90 and 180,90 -
> when I convert these values using the PyProj library I get values of 1E30
> for each value (which seems to me clearly wrong). What is the best way to
> scale the output in terms of min/max values (in 'pseudo-meters') for each
> corner of my 900x1100 rectangle?

You simply can NOT project the poles (lat=90) using Mercator
projection, because the formulae give the infinity as result. Stop at
around 75N/S degrees in case you want something usable.

  Antti
_______________________________________________
Proj mailing list
[hidden email]
http://lists.maptools.org/mailman/listinfo/proj
Reply | Threaded
Open this post in threaded view
|

Re: Beginner Question: Latitude/Longitude to x, y conversion - understanding output

Andre Joost
Am 24.02.2014 15:37, schrieb Antti Castrén:

>
> You simply can NOT project the poles (lat=90) using Mercator
> projection, because the formulae give the infinity as result. Stop at
> around 75N/S degrees in case you want something usable.


If you stop at 85°N/S, the map will be a square. That`s the logic behind
using 256x256pixel tiles as Google and Openstreetmap do.

Greetings,
André Joost


_______________________________________________
Proj mailing list
[hidden email]
http://lists.maptools.org/mailman/listinfo/proj