Black Lives Matter. Please consider donating to Black Girls Code today.
Dash HoloViews is now available! Check out the docs.

Geoplotting using the input command for any city with dash

Is there is any way to plot only one location (latitude and longitude) on map. Because, I have created an input box wherein when I type any city name, I get the exact latitude and longitude, but unable to plot those points on the map. I don’t know what type of plot to be used in this case. I looked some examples of dash and plotly. All the examples have a set of latitudes and longitudes predefined in a dataset.

I’m making something that, when a user types any valid city name, the appropriate location of that city should get plotted on the geographical plot.

What could be the suggestion here to get what I wanted?

california

hamilton

Thanks

I think the best option is to use plotly.graph_objs.Scattergeo.

It is basically a scatter plot, but tailored to geographical plotting.

It takes lat and lon as main arguments, and places the point(s) on the right place in the map.

This will get you a standard default map, which you can customize, but customizing the plotly.graph_objs.Layout of the plot. (width, height, plot_bgcolor, etc).

Under the layout dictionary you can add several parameters through the geo option, which has very useful options. Check the full list here: https://plot.ly/python/reference/#layout-geo (where to center the map, what lat and lon limits to give it, the angle of the earth, whether to show country borders or not, oceans, etc).

Hope this helps!

1 Like