dclenden
dclenden

Reputation: 23

Issue with plotting markers in scattermapbox

Currently, my issue is that I can't seem to get the markers to be in the correct spot for my Scattermapbox (they should be in the USA at the east coast). I zoom all the way out of the map and I see that the markers are in Antarctica, which is not where I want them to be. The longitude and latitude may be the issue, but I am using a Pandas dataframe to hold them, so I'm unsure as to why the markers are being rendered in a different spot. I am currently trying to get this to work specifically for 3 data points, but I want it to work in a dataframe so that I can add other locations to it. The df is parsed from a csv, where longitude/latitude are fields, and the reason I use unique is because the same values pop up multiple times due to the nature of the CSV (security footage). Any help is appreciated.

Image of markers in Antarctica

a=[10,20,30]
b=['blue','red','orange']
site_lat = df_copy['latitude'].unique()
site_lon = df_copy['longitude'].unique()
location_name = df_copy.site_location.unique()
map_fig = go.Figure()
map_fig.add_trace(go.Scattermapbox(
        lat = site_lat,
        lon = site_lon,
        mode='markers',
        marker=go.scattermapbox.Marker(
            #symbol="circle",
            size=a,
            color=b,
        ),
        hoverinfo='text',
        hovertext=df_copy['site_location'].unique(),
    )
)

Upvotes: 2

Views: 304

Answers (1)

mattsap
mattsap

Reputation: 3806

Your code is right. Typically, this happens when you're providing bad GPS coordinates. Check if your longitude and latitude values are swapped in the CSV or if they're legit GPS coordinates.

Upvotes: 1

Related Questions