Hey, i'm hoping that someone reading this can help me better understand how to plot longitude and latitude points on a map.
Alright, say I have a map that is 602pixels wide and 324pixels high.
And say I want to map the longitude/latitude cordinate +39,-75
How would I do this?
I'm thinking I would basically just need to find the number of pixels per degree of longitude and pixels per degree of latitude and then multiply the number of degrees of either longitude or latitude by the number of corresponding pixels? But my attempt at doing this did not produce the desired output.
Thanks a bunch for any input provided.
mapping with php, converting lon/lat
Moderator: General Moderators
http://www.phpbuilder.com/columns/moss2 ... hp3?page=3
remember kids point 0,0 is at the top left and point 602,324 is on the bottom right!
remember kids point 0,0 is at the top left and point 602,324 is on the bottom right!
That doesn't work accurately when used on an image of an individual continent in which the border of the continent don't touch the border of the image.
Check out the article Trip Mapping on ONLamp
http://www.oreillynet.com/pub/a/php/200 ... p_map.html
Now, the function in that article didn't work for me either, but the logic makes more sense than that of the phpbuilder article.
Check out the article Trip Mapping on ONLamp
http://www.oreillynet.com/pub/a/php/200 ... p_map.html
Now, the function in that article didn't work for me either, but the logic makes more sense than that of the phpbuilder article.
Re: mapping with php, converting lon/lat
Is this map just part of the world, or is it all 360/180 degrees?nigma wrote:Hey, i'm hoping that someone reading this can help me better understand how to plot longitude and latitude points on a map.
Alright, say I have a map that is 602pixels wide and 324pixels high.
And say I want to map the longitude/latitude cordinate +39,-75
How would I do this?
I'm thinking I would basically just need to find the number of pixels per degree of longitude and pixels per degree of latitude and then multiply the number of degrees of either longitude or latitude by the number of corresponding pixels? But my attempt at doing this did not produce the desired output.
If it's the whole world you're laughing, just divide 602 by 360 and 324by 180 to get the amount of pixels per degree, then plot your points accordingly, probably something along the lines of
Code: Select all
$x=(602/360)*$lon //(65.22 in your example above, more or less :))
$y=(324/180)*$lat //(-135)Code: Select all
$longitude_res=602/360
$longitude_origin=$longitude_res*180
$x=(-1*($lon*$longitude_res))+$longitude_origin
if($x<0)$x+=602;That the kind of thing you're looking for? If you can provide more details I'll try to help out all I can
It's just going to be part of the world. The map i'm using is a 2-d picture of the united states. A friend of mine actually wrote me two functions to do it for me but I'm not quite sure I completely understand what is going on.
So any explanations of why you would do what to get the lon/lat cords onto the image accurately would be greatly apreciated.
So any explanations of why you would do what to get the lon/lat cords onto the image accurately would be greatly apreciated.
As PrObLeM said, you'll need to know the lat/long of the image edges, I've no idea how to accurately do that, at a guess I'd start off on the likes of terraserver.com and manually try to find them, you may be out of luck though.nigma wrote:It's just going to be part of the world. The map i'm using is a 2-d picture of the united states. A friend of mine actually wrote me two functions to do it for me but I'm not quite sure I completely understand what is going on.
So any explanations of why you would do what to get the lon/lat cords onto the image accurately would be greatly apreciated.
If you can post a link to the picture I'll try to help you figure it out, but I don't know how helpful I'll be.