Conversion Formula of geographic (projection) coordinates and screen coordinates

Source: Internet
Author: User

Rule for defining geographic coordinates: the X axis (representing the longitude) increments to the right, and the Y axis (latitude) increments up, just like the plane coordinates learned in elementary school (it seems that I forgot to re-read the Primary School) right? To the left and down rules, I don't need to explain it again. If you still don't understand it, I suggest you re-read the primary school .... it's more sad than me. Hey, I finally found a zhialready .... not easy...
Screen coordinate definition rules: X axis increments to the right, and Y axis increments downward ..
It can be seen that the difference between geographic coordinates and screen coordinates is only that the incremental direction of the Y axis is the opposite... (this is different ).
Now let's switch to them. here, we emphasize that to ensure accuracy, the degree of geographic coordinates x 3600 is converted to seconds. All values are calculated using double, and the final result is converted to int.
1. I have known the range of the screen height (Y), width (H), and geographical coordinate areas (maxlon, minlon, maxlat, minlat ).. here we know these known parameters...
2. We can calculate the longitude and latitude represented by each pixel (this is called a proportional factor ):
Formula: scalex = H/(maxlon-minlon) * 3600) ---------- longitude seconds represented by each pixel on the X axis;
Formula: scaley = y/(maxlat-minlat) * 3600) ----------- latitude and seconds represented by each pixel on the Y axis;
The two proportional factors are the relationship between the two coordinate systems ..
3. A very simple step is to calculate the coordinates of any point (Lon, Lat) in the geographic coordinate area on the screen. How can this problem be solved? Below:
Formula: screenx = Lon * 3600/scalex; --------- screen coordinate X axis Coordinate
Formula: screeny = lat * 3600/scaley; ---------- screen coordinate Y axis coordinate, how? Is it easy? Here, we can figure out the coordinates on any point of geographic coordinates to the screen ......
In the last step, what should we do if we want to fill up the geographic area with a screen?
4. What should we do if the geographic area is full of screens?
Formula: Minx = minlon * 3600/scalex; leftmost end of the area
Formula: miny = minlat * 3600/scaley; top of the Region
5. The screenx and screeny parameters calculated in step 3 are used when the local geographic range is full of the screen.
, The formula for any point in the region is as follows:
Formula: x = screenx-Minx = (Lon-minlon) * 3600/scalex;
Because the latitude direction is opposite to the Y axis of the screen,
Formula: screenmaxlat = (maxlat-minlat) * 3600/scaley;
Formula: screenlat = (lat-minlat) * 3600/scaley;
Formula: Y = screenmaxlat-screenlat = (maxlat-lat) * 3600/scaley. As for why this formula is used, I think you should think about it carefully ..
6. Conclusion:
The formula for converting the longitude and latitude coordinates to the screen coordinates is as follows:
Formula: x = (Lon-minlon) * 3600/scalex;
Formula: Y = (maxlat-lat) * 3600/scaley;
Then, we can use the above formula to introduce the following formula for converting screen coordinates to longitude and latitude coordinates:
Formula: Lon = x * scalex/3600 + minlon;
Formula: lat = maxlat-y * scaley/3600;

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.