How to plot markers from two columns in one geographical map

Hi guys,

I want to create a geographic map with two different markers. The primary marker is on the basis of (lat, long), while the second one would be on the basis of zip codes. I am able to plot the location on the basis of lat, lon but I don’t know if it is possible to plot the zips in the same map or even zips on a different map.
My main objective is to show the location of a store and all the zip codes surrounding that location.
All of this data is in a csv file.
If it is not possible with plotly can I use any other library for this purpose?
Thanks,

Hi @ankitsati,

You can add multiple Scattergeo traces to a single plot.

For the first trace you could set the mode property to 'markers' and the lat/lon properties to the coordinates of your markers.

For the second trace you could set the mode property to 'text', the text property to the zip code strings, and the lat/lon properties to the coordinates of the zip codes (You would need some way to convert zip code to coordinates).

Hope that helps!
-Jon

@jmmease Sorry for such a late reply, what I am trying to do is to create something similar to a folium map.
In folium map, I have two kinds of coordinates first are the store coordinates that I am using to plot the marker(like a point marker).
second is the coordinates that I am getting from the zipcodes and I am using them to create a choropleth map.
So my map is a choropleth map with zip codes used to create choropleth and then store coordinates to create markers.
Is something like this possible on dash/plotly?
I am attaching a screenshot for reference.

Hi @ankitsati,

I think the closest example to what your doing is https://plot.ly/python/mapbox-county-choropleth/. But to reproduce it with zip codes you would need to come up with your own data source that contains the geometry of the zip code boundaries.

-Jon

Thanks @jmmease,
I tried creating something like that but i can’t figure out how to create the colorscale based on the sales. i created a map from geojson that has all the geometry and sales as a property. I don’t know how to use the geojson[‘feature’][i][‘properties’][‘sales’] to map the colors intensity in the map. Is there any examples for that?

Hi @ankitsati,

I think what you would need to do is bin your geojson['feature'][i]['properties']['sales'] values and then create a separate layer for each binned value.

It’s not exactly the same processes, but the county_choropleth figure factory performs this kind of binning and coloring. So it may be helpful to read through the create_choropleth method (See https://github.com/plotly/plotly.py/blob/2e5bf6e2f7c213295c405ece3e859f4d3f8030d1/plotly/figure_factory/_county_choropleth.py#L359).

Hope that helps!
-Jon

@jmmease Thank you so much. I will look into it.