GPS coordinates to pixel

2019-08-12 12:59发布

问题:

I need to create image (polygon) from GPS coordinates. I have coordinates like this:

(49.274633220,17.160206083),(49.276968797,17.162732143),(49.278188519,17.162391767),(49.279761626,17.161087954), ......

And I need to transform them to XY pixel points. Each pair of coordinates are vertex of created polygon.

File with all coordinates:

GPS.txt

and how the created polygon should look like:

Any idea how can I transform the coordinates? Thanks for all reply.

回答1:

In all cases you need a transformation form lat,lon (spherical) to cartesian (x,y) coordinated. If the polygon is not bigger than 100km you can use a simple Cyclindrical Equidistant Projection. Otherwise, you may use a Mercator Projection. (Google Maps uses that too)



回答2:

Are you sure the assignment says to create a graphic? Or is it just to read the text file and extract the pairs of coordinates? Because you can't create a graphic without defining a transformation. I would start by finding the max and min latitude and longitude values (making sure which is which!). Then just use a linear scale for the longitude so that your minimum longitude goes to px=0 and the maximum longitude goes to however wide you want your image to be. Then do the same for latitude - it'll look distorted but at least you'll see something to start with.

By the way, the graphic you pasted doesn't seem to correspond to the coordinates you gave. If it helps, yours look more like this red area.



标签: java gps