0

I am in trouble with how to plot the coordinate given in a file.csv using basemap. It has error when I run with latlon=True. My code below :

import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.basemap import Basemap 

df=pd.read_csv('E:\Classification\DATA.csv')
lat=df['Latitude']
lon=df['Longitude']

plt.figure(figsize=(12,7))
m = Basemap(projection='mill',
           llcrnrlat = 7,
           urcrnrlat = 25,
           llcrnrlon = 90,
           urcrnrlon = 120,
           resolution = 'l')
m.drawcoastlines()
m.drawcountries()
m.drawstates()
m.fillcontinents(color='None',lake_color='#FFFFFF')
m.drawmapboundary(color='k', linewidth=1.0, fill_color=None, zorder=None, ax=None)

parallels = np.arange(0.,81,10.)
# labels = [left,right,top,bottom]
m.drawparallels(parallels,labels=[False,True,True,False])
meridians = np.arange(10.,351.,5.)
m.drawmeridians(meridians,labels=[True,False,False,True])

m.scatter(lon,lat,latlon=True,c='red', marker='o',linewidth=1, zorder=2)

plt.show()

I really appreciate if some of you can help me. Thank you so much.

2
  • Need a few lines in DATA.csv for testing. Commented Jul 22, 2020 at 10:38
  • My lattitude: 16.22 13.95 13.9 22.15 My longitude: 107.28 108.65 109.12 105.83 Commented Jul 22, 2020 at 10:43

1 Answer 1

0

Try using lon.values, lat.values in place of lon, lat in m.scatter().

m.scatter(lon.values, lat.values, latlon=True,c='red', marker='o',linewidth=1, zorder=2)

vn

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you so much for your help.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.