Can I highlight specific rivers with Mapbox? - gis

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.

Related

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.

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.

what is the difference between overlay map type and layers

From the google map v3 javascript api,I found this:
Overlay Map Types
Some map types are designed to work on top of existing map types. Such
map types may have transparent layers indicating points of interest,
or showing additional data to the user. (Google's traffic layer is an
example of such a map type.)
Which say that Google's traffic layer is an example of such a map type.
But the traffic layer is intance of Layer in google map.
So I am confused with the concept.
Since we are build our own map library for offline use,so I want to refer google's concept and their idea.
Any one can give me more details?
Layers and Overlays are not of the same type.
Layers can only be manipulated as a whole object. I guess google dont want you to mess with the information.
Layers thought of as a type of map type for selection, and are transparent. They are also sort of like the concept of an overlay as they are made of geometric shapes.
i think the concept is confusing because overlays, layers and the underlying map type are all things that in other systems (photoshop for example) would just be layers (that might be of different type (ie vector or raster).
Hope this helps.

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.