This site uses cookies to deliver our services and to show you relevant ads and job listings.
By using our site, you acknowledge that you have read and understand our Cookie Policy, Privacy Policy, and our Terms of Service.
Your use of Stack Overflow’s Products and Services, including the Stack Overflow Network, is subject to these policies and terms.

Join us in building a kind, collaborative learning community via our updated
Code of Conduct.

Additionally, the image resolution shows to be 10 meters, as shown below

.

My question is

as i have known the centered geolocation (53.4055429,-2.9976502) and resolution of this static image, how would i be able to extend it to calculate the geolocation of left up or right bottom in the image, and finally calculate each pixel of the image

You can try my answer. Actually you don't need to have google maps js api to do simple math like powers and cosines. Notice, that the two answers have the same results in output console.
– shukshin.ivanNov 12 '17 at 2:07

You should select the best answer, otherwise your bounty will disappear in vain.
– shukshin.ivanNov 13 '17 at 17:40

2 Answers
2

Looks like you need not a javascript solution but for python to use it not in browser but on a server. I've created a python example, but it is the math that I am going to stand on, math is all you need to calculate coordinates. Let me do it with js as well to make snippet work in browser. You can see, that python and js give the same results.

Jump to the answer

If you just need formulae for degrees per pixel, here you are. They are simple enough and you don't need any external libraries but just a python's math. The explanation can be found further.

We have some parameters needed in url https://maps.googleapis.com/maps/api/staticmap?center=53.4055429,-2.9976502&zoom=16&size=400x400&maptype=satellite&key=YOUR_API_KEY – coordinates, zoom, size in pixels.

The math is as follows. Zoom 1 stands for full view of the Earth equator 360° when using image size 512 (see the docs for size and zoom). See the example at zoom 1. It is a very important point. The scale (degrees per pixel) doesn't depend on the image size. When one changes image size, one sees the same scale: compare 1 and 2 – the second image is a cropped version of the bigger one. The maximum image size for googleapis is 640.

Then use linear function to find coordinates for any point of the image. It should be mentioned, that linearity works well only for high zoomed images, you can't use it for low zooms like 5 or less. Low zooms have slightly more complex math.

Latitude degree and longitude degree on the equator are of the same size, but if we go north or south, longitude degree become smaller since rings of parallels on the Earth have smaller radii - r = R * cos(lat) < R and therefore image height in degrees becomes smaller (see P.S.).

P.S. You can probably ask me, why I place cos(lat) multiplier to latitude, not as a divider to longitude formula. I found, that google chooses to have constant longitude scale per pixel on different latitudes, so, cos goes to latitude as a multiplier.

In order to solve this in python you should understand the Map and Tile Coordinates principles used by Google Maps JavaScript API and implement projection logic similar to Google Maps API in python.

Fortunately, somebody has already did this task and you can find the project that implements methods similar to map.getProjection().fromLatLngToPoint() and map.getProjection().fromPointToLatLng() from my example in python. Have a look at this project in github:

@shukshin.ivan Thanks for the comment. I didn't test the mercator.py thoroughly, indeed, it is possible the implementation is not precise enough, but it demonstrates the idea. I will have a look once I have some free time.
– xomenaNov 13 '17 at 11:59

I'm talking not about precision but about an error. The difference is huge, more than a factor of hundred.
– shukshin.ivanNov 13 '17 at 20:39