Google Maps coloured overlay/polygon that only applies to water - google-maps

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.

Related

Can I highlight specific rivers with Mapbox?

Is it possible to highlight rivers in Mapbox?
I would like to look at the world and see a list of specific rivers standing out as if highlighted with a yellow marker on a paper map. As I zoom in, the highlights would get more precise and ultimately coincide with the actual geometry of the rivers, or at least follow a line equidistant to their banks…
Is this at all possible?
I understand I can draw anything I want at specific geographic coordinates, but I can't figure out how to extract the river geometry from Mapbox to compute the paths for my highlighter strokes…
Or perhaps this kind of thing would be easier with another provider? How do people usually handle this kind of thing?
As far as I know there is not a way to highlight specific rivers in Mapbox's water related layers by an attribute like name. However, if you are looking to filter features based on size/prominence it is possible to filter features using the "class" or "type" property on the Mapbox waterway layer. This will at least allow you to filter/style features based on their type (i.e. river, stream, canal, etc...).
An alternative approach would be to pull together spatial data outside of the Mapbox platform and then bring it into Mapbox as your own tilset or dataset. I have done this before using the National Hydrography Dataset (this is just for the US) when I wanted to highlight specific rivers (i.e. only show the Rio Grande, Arkansas, and Colorado Rivers). I brought the NHD into my desktop GIS application (QGIS), filtered the features to just those rivers, exported the filtered features as GeoJSON and then uploaded to Mapbox and did all the desired styling in Mapbox Studio.
Hope this helps! I have been writing a series of guides for Mapbox that you might be interested in too. Here are some links:
The Mapbox Developer's Handbook
A Complete Guide to Sources and Layers in React and Mapbox GL JS
Here's something you can try:
Use the waterway line layer in the Mapbox Streets vector tileset and set a filter to show only the river feature type. This will show all rivers at low zoom levels, but because this is a line layer, it will not show the rivers' widths at high (close to the ground) zoom levels. Set the layer to 0 opacity at higher zoom levels so it disappears.
At higher zoom levels, you can use the water polygon layer in the Mapbox Streets vector tileset, but it includes oceans, rivers, lakes, ponds, reservoirs, and fountains all smashed into a simple polygon layer of undifferentiated, merged shapes:
there is no way to filter out or highlight specific water bodies or a partial subset of them.
If you want to isolate one specific waterway (like only the Rio Grande), you will need to import that data yourself as #tylerben suggests.
If you feel adventurous, you could try using mask in Turf.js to hide features in the water layer that are more than, say, ten miles from the centerline of a river from the waterway layer.
You can learn more about Mapbox map data in the core tilesets documentation.

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

Mapping GPS coordinates to an image

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.

How does Google StreetView recognize 3D planes?

Inside Google Street View, moving the mouse around over different buildings and stuff, it highlights the 3D plane in which that surface of the building is located.
How does it recognize this thing? Is it done automatically by machine algorithms, or manually in the preprocessing?
Read this to get your answer. What Google does is it gets a panoramic view by stitching multiple images together, and then the device measures the relative distance of every object around it (through lasers), and constructs a 3D model of the surroundings based on that.
You want to look into space-filling-curves. A sfc reduce the 3d complexity to a 1d complexity. A sfc subdivide the 3d space into 8 tiles thus it resemble an octree.

is it possible to display 3D data in Google Maps or Google Earth?

I'm trying to find an effective way to visualise feedback from some real-world sensors measuring wind speeds at various heights. Does anyone know if it's feasible to display 3D data in google maps?
I was imagining 3D arrows indicating direction and wind speed. If it's possible to load a model and position it to a particular GPS position / elevation and then change its orientation to point to a particular azimuth / elevation what could work.
Another alternative I was considering would be to create an image for each height and display the arrow by scaling / rotating the disk. The documentation suggests you could do a single layer at ground level with an overlay but doesn't make any mention of pulling those images up into the air.
I've played with google maps before, but not Google earth. Just trying to get a feel for what might be possible here. Has anyone tried anything like this?
Google maps is 2d and as such does not support 3d objects, things are located via a latitude and longitude only. However, you could easily create a '3d looking' image and incorporate it in to a map using the maps Api.
Google earth is 3d (latitude, longitude, altitude) and supports models and geometries loaded via kmz archives or constructed via the Api. It is fairly trivial to include using either method.
The reason you see no mention of 'pulling those images up into the air' in the doc you reference is because the document covers 'ground overlays' - so they are fixed to the ground...
Anyhow, take a look at the geometries and models section in the google earth api - should be exactly what you need.
http://code.google.com/apis/earth/documentation/geometries.html
http://earth-api-samples.googlecode.com/svn/trunk/examples/model.html