Mapping GPS coordinates to an image - google-maps

I have attempted to map some GPS coordinates (longitude / latitude pairs) onto an image of the region of the world that they correspond to. The math was not complicated simply offsetting and then transforming the numbers with a multiplier. However this worked fine for points in Australia, but not for points in New Zealand.
The result is that the points seem to drift south near the middle of the image then slowly correct before the bottom.
Is there some extra math which needs to be taken into consideration for plotting points on a map?
Note:
during my diagnostic excercise I placed my map over google maps and noticed that my version of Australia was different to google maps, but New Zealand was the same as google maps. But the plotting for Australia works but for New Zealand does not.

Longitude/Lattitude is spherical coordinatesystem and will only work if you have a globe to show your map on. In your case you have a flat map and need to project the coordinates onto a flat surface. The maps that Google uses is created with an Mercator-like projection.
What kind of projection you want to use depends on how big area your map consist of. Most countries have their own projection that fit best for their purposes.
Those transformations are quite tricky to work out by hand if your not a mathematician but there are good libraries for transformations like Dotspatial and GDal.

Related

Python tool to get an outline map of counties/states given the bounding coordinates?

I am looking for a python tool that gives me the county and/or state boundaries in an image format if I provide the 4 corners in lat/lon coordinates. I plan to overlay some satellite images on these.
I briefly dabbled with geopandas and I could get a map of North America, but having something more zoomed in would be better.
Thanks.

How Google Maps API calculates meters with coordinates?

I found this issue while experimenting with shapes. As written in documentation, we can draw circle with radius specified in meters. But Google Maps use cylindrical projection of the Earth (edit: ok, it doesn't), so logically, in Arctic regions our circles should be something similar to ellipse. So I conducted simple experiment and drew a circle near The Egde. That's the result:
As we can see, we still have a circle.
So, my question is, how Google Maps API calculates meters? Is there some constant coefficient between meters and coordinates, used consequently? Or maybe this is a bug and in all other cases one meter in Google Maps equals one meter in reality?
So, as I said in comment, the problem was my misinterpretation of the north edge of the map. When it comes to measuring, Google Maps API is reliable. This is how my 400-meters circle looks like near the real north pole:

How to detect water on google maps

Is it possible to determine if a gps point is in water or near(not including elevation) . From what I have seen it doesn't seem possible. I had an idea of somehow getting the gps fence of water bodies and checking if the point lays in the fence. Sounds good but I can't find gps coordinate fences. If any one have any other ideas or a place to get those fences it would be great.
You can get the GPS fence for water from OpenStreetMap.
Then you do a point in polygon operation, optionally you put all polygons in
a spatial search structure, like a quad tree, for a fast polygon search nearby the lat,lon point.
You can start here. and later read more how to identify water in OpenStreetMap
A solution that works on small areas of waters, worldwide, would use much storage space If you concentrate on some countries this should work.
I found that the article is a very interesting approach.
Using google static maps to draw just some pixels around your coordinates, and then check whether its blue or not blue.
You can set a custom unique colour for "water" as a parameter to the google static map, which makes it easy for you to determine if it matches water or not

Google Maps coloured overlay/polygon that only applies to water

I need to plot some coastal areas that are are easily defined in English (eg "water in the bay north of latitude X"), but are highly complex polygons because of the shoreline.
Do I have to plot the the entire (relevant) section of shoreline, or is there a way to draw a rectangle that only colours the water (and has no effect on land)?
The maps drawing tools have no knowledge of the terrain type. The tiles that show up are just background images that Google has generated from various data sources: there isn't data attached to them by the time you use the API that says "this pixel is land" or "this pixel is water". Even so, the drawing tools of Google Maps are fairly "dumb": they just allow you to plot geometric primitives on a canvas which has a coordinate system that matches latitude/longitude.
Sadly, this means that your geometry needs to be drawn to match the shoreline if you don't want it to overlap. There are resources for this, such as the NOAA shoreline data, but it's a non-trivial amount of work to consume the data and serve it up in the map.

How to solve discrepancy between 3rd party coordinates and google map?

I have a set of coordinates data from 3rd party provider. However when I plot those coordinates on google maps with annotations, the annotated points are not exactly on the position they should be. For example, some points should be placed on the road, however they are placed slightly off the road.
My question is, how to solve this kind of discrepancy?
Thanks!
Coordinates (lat and long), by themselves, do not describe a position on the Earth. You need a third piece of information, called the datum. The datum for google maps is WGS84. The datum establishes such things as where 0,0 is on the Earth's surface.
If you've received coordinates, and those coordinates are based on a different datum, then they will not plot correctly on Google Maps.
On the other hand, if the points came from any kind of mobile device (even if it is using WGS84), there are inherent inaccuracies in such measurements (thankfully generally down to < 5m for GPS these days, I believe) that mean that they will not align 100%.