Adding Layers with plot_mapbox() in Plotly

Hi Everyone,

Thanks for reading my post.

Is anyone familiar working with Plotly and Mapbox? I am trying to create a map using a Mapbox baselayer. I have 2 files; one is a geojson file. Each record has a collection of coordinates that make up a geographic block; a feature collection. The second file is a csv file that includes columns for longitude and latitude to make points on a map.

I would like to use a Mapbox streets basemap and layer the geojson file on top. This shows zones. Then I would like to add the markers on top to analyze which markers are in or out of the zones.

I've been able to show the zones on the street Mapbox layer, but I can't add the markers. Here is my question:

Is it possible to use two different data sources to create layers on a map using functions that work with plot_mapbox?

I am also using the package sf and have tried converting just the geojson file to a sf object, both files to sf objects and I've used the following functions with the markers csv file; add_markers, plot_mapbox, add_trace, add_sf. I've tried changing the order of the files. I can plot a starter stage map with both files in ggplot2 using add sf. However, I want an interactive map to use. My next strategy will be to explore the package leaflet.

Please let me know if plot_mapbox() can be used to show layers on a map and what I might try to get my map to render.

Much appreciated!

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.