AME
AME

Reputation: 2609

Plotting a list of (lattitude, longitude, value)-tuples in Python?

I have a list of (latitude, logitude, value)-Tuples I want to show using Basmap. What's the easiest way to do that?

data = [(1, 2, 0.12323),
        (2, 5, 0.23232),
        (4, 52,0.23131)
        .
        . tenthousand times this.
        .
       ]

Upvotes: 4

Views: 4356

Answers (2)

Adam Morris
Adam Morris

Reputation: 8545

I haven't used basemap, but it looks like what you want is the scatter() method:

https://matplotlib.org/basemap/stable/users/examples.html

Which takes the same parameters as the matplotlib.pyplot.scatter method:

https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.scatter.html

Upvotes: 1

JeeyCi
JeeyCi

Reputation: 599

easiest way

# https://stackoverflow.com/questions/61068670/plotting-latitude-and-longitude-from-csv-file?rq=3 
import pandas as pd
import plotly.express as px

df=  pd.DataFrame( {'Latitude': [51.0, 51.2, 53.4, 54.5],
              'Longitude': [-1.1, -1.3, -0.2, -0.9],
              'values': [10, 2, 5, 1] })

fig = px.scatter_geo(df,lat='Latitude',lon='Longitude', hover_name="values")  # can add param size also as list
fig.update_layout(title = 'World map', title_x=0.5)
fig.show()

for GPS see example here

P.S. can add e.g. colorbar for rainfall

Upvotes: 0

Related Questions