Geopy using the Google Maps v3 API: How to plot an optimal TSP route on a map - geopy

I kindly need help with plotting optimal routes from my optimization model on say google map using the 'geopy' and google map v3 api. The image below illustrates an example of the optimal routes obtained from my model with the corresponding zip codes of cities.
My objectives are as follow:
plot each of the routes for each of the salesmen on say a google map showing the routes using the corresponding zip codes. For example, salesman1 travels from city1(zip code 13901) -> city3(zip code 13903) -> city4(zip code 13905) and then ending back at city1(zip code 13902). Similar for salesman2 and salesman3
the plot from point 1 must follow the road that leads to the shortest path between the points, lastly
I would like to show the direction of the optimal path if at all possible.
I know how to plot zip code information using the google maps using the 'My Maps', but this does not address what I am trying to accomplish here as described above. Thanks in advance for your help.

Related

Plot two lines on the same row on a graph

I am trying to create a medical graph to display the heart rate. It will have the live data on the left part and the prediction forecast on the right. I will get both from the backend API, and I need now to show them as one line on the graph. I am using ReactJs and chart.JS.
Look the picture below to understand better:
(https://i.stack.imgur.com/qWd6H.jpg)tter:
I just tried to do the regression but it will be done from the backend. I am getting from the API two fields: live data: and prediction:
And I need them to add them together.
I think you can use segment option for this. You can change line styles based on datapoint options / value.
Usage example: Link an official example

How to create Topographic 3d graphs in r?

I have come across some cool topographic maps on reddit and wonder how they can be made in r ?
from: reddit image post link
Is it even possible to create such maps in r and what kind of data files does it need to create them ?

GEE obtain bands from image collection

I'm currently working on my bachelor's thesis and I am trying to work with Sentinel 5 - P's aerosol data.
I am trying to obtain Aerosol Layer Height (L3__AER_LH) data but I do not know the bands, which I need to 'select'.
The README file on L3__AER_LH reads as follows:
The data file contains the aerosol_mid_pressure and aerosol_mid_height which provide the
air pressure at the center of the aerosol layer and the height at the center of the aerosol layer relative
to the geoid, respectively.
But when I try running: .select('absorbing_aerosol_index'); I get no results.
Therefore, I have tried using print(collection.bandNames); but I recieve an 'undefined'.
Could someone help me obtain L3__AER_LH data from GEE?
Thank you for your time.
Therefore, I have tried using print(collection.bandNames); but I recieve an 'undefined'.
The best way to find out about bands programmatically is to look at the band names of one image, because band information for a collection is sometimes incomplete.
print(collection.first().bandNames());
That said, for datasets from the Earth Engine Data Catalog, you'll get documentation as well as the names by looking at their catalog pages (example), so doing so is a better option in that case.
That page tells you that the band names for L3_AER_LH (as provided by Earth Engine) include aerosol_pressure and aerosol_height.

Google Maps vs. ggplot2/MarMap

Below is a JavaScript page I have created that allows me add and freely move markers on the map. From this map I can figure out the regions I am interested in.
Basically what I want to do is show the same map using ggplot2/MarMap with coastline indicators + bathymetry data. I am really just interested in getting bathymetry data per GPS location, basically getting negative/positive elevation per Lat+Long, so I was thinking if I can plot it then I should be able to export data to a Database. I am also interested in coastline data, so I want to know how close I am (Lat/Long) to coastline, so with plot data I was also going to augment in DB.
Here is the R script that I am using:
library(marmap);
library(ggplot2);
a_lon1 = -79.89836596313478;
a_lon2 = -79.97179329675288;
a_lat1 = 32.76506070891712;
a_lat2 = 32.803624214389615;
dat <- getNOAA.bathy(a_lon1,a_lon2,a_lat1,a_lat2, keep=FALSE);
autoplot(dat, geom=c("r", "c"), colour="white", size=0.1) + scale_fill_etopo();
Here is the output of above R script:
Questions:
Why do both images not match?
In google-maps I am using zoom value 13. How does that translate in ggplot2/MarMap?
Is it possible to zoom in ggplot2/MarMap into a (Lat/Long)-(Lat/Long) region?
Is it possible to plot what I am asking for?
I don't know how you got this result. When I use your script, I get an error since the area your are trying to fetch from the ETOPO1 database using getNOAA.bathy() is too small. However, adding resolution=1 (this gives the highest possible resolution for the ETOPO1 database), here is what I get:
To answer your questions:
Why do both images not match?
Probably because getNOAA.bathy() returned an error and the object dat you're using has been created before, using another set of coordinates
In google-maps I am using zoom value 13. How does that translate in ggplot2/MarMap?
I have no clue!
Is it possible to zoom in ggplot2/MarMap into a (Lat/Long)-(Lat/Long) region?
I urge you to take a look at section 4 of the marmap-DataAnalysis vignette. This section is dedicated to working with big files. You will find there that you can zoom in any area of a bathy object by using (for instance) the subsetBathy() function that will allow you to click on a map to define the desired area
Is it possible to plot what I am asking for? Yes, but it would be much easier to use base graphics and not ggplot2. Once again, you should read the package vignettes.
Finally, regarding the coastline data, you can use the dist2isobath() function to compute the distance between any gps point and any isobath, including the coastline. Guess where you can learn more about this function and how to use it...

How to create interactive online map with contour (filled) plot layer?

I would like to create an online interactive map with filled contour plot layer like the ones can be seen on openweathermaps (I would like to use my own data for the plots).
What I need is also similar to the Leaflet heatmap (heatmap.js) but without dynamically changing the colors and the extent of the graphical objects (as in case of heatmap.js). Let's call them static heat maps.
I would like to know which mapping code/library can be used to produce such maps.
I am really newbie to these things, so please bear with me.
I tried Leaflet but did not find any plugin which would create filled contour map layers (static heatmap). I created the following map with Leaflet where the rectangles are geojson polylines and the color is based on some assigned values to every rectangle (elevation)
my leaflet attempt
The problem with this approach is that if higher resolution (smaller and more rectangles) is needed the site would really slow down.
I checked OpenLayers but did not see any similar examples.
I have the data in a matrix format:
Lat; Long; Value
.
.
Values are given in every gridpoints.
(if needed I would convert into other formats, like in case of the above attempt into geojson format)
The data is static, would be saved on the server.
So what I basically want to accomplish is a site where some spatial data is represented as filled contour map (static heatmap) and it is plotted over a map.
Here is my solution to the problem using open-source programs and free, online service:
(1) Processing the data in a GIS program. I used QGIS. I interpolated my data which is in grid points to get a high resolution raster map.
(2) Save the post-processed raster map as a georeferenced *.tif image.
(3) Import the image into TileMill. Remove the basemap and keep only the image as the only layer (style it).
(4) Export the 'map' from TileMill as MBTiles. This will save numerous *.png files (tiles) corresponding to different zoom levels. These are the same type as google or openstreetmap use for their online maps.
(5) Create a free account at Mapbox and create a new map project. Upload the MBTiles created by TileMill (can be directly uploaded from it). Style it.
(6) Use the Map ID corresponding to your created project to embed the map into html sites, e.g. the javascript code:
// Provide your access token
L.mapbox.accessToken = 'Mapbox will generate this for you';
// Create a map in the div #map
var map = L.mapbox.map('map', 'username.mapid', {
minZoom: 5,
maxZoom: 10
}).setView([47, 20], 8);
Example hosted on Mapbox
Sample image(I do not how long will the above link live):
In retrospect, the question would have been better fit to GIS stack exchange.

Resources