I'm trying to plot some data with matplotlib and basemap, but I have trouble making the coordinates match between Google Maps and basemap. For example, I click at a distinctive feature on the map in Google Maps, and read the coordinates (this is on the north east coast of Greenland:
I then try to plot those same coordinates on a map with matplotlib and basemap:
The two points seem to differ by about 10 km. Are there any parameters I can pass to basemap, or any conversions between ellipsoiods or anything I can do to make these points match up?
The python code I used was this:
#!/usr/bin/env python import matplotlib matplotlib.use('agg') from mpl_toolkits.basemap import Basemap import mpl_toolkits.basemap.pyproj as pyproj import matplotlib.pyplot as plt # These are the coordinates I read out from Google Maps lat, lon = 80.615439, -15.474109 m = Basemap(width=200000, height=150000, resolution='i', projection='stere', lat_ts=80, lat_0=lat, lon_0=lon) m.fillcontinents(color='#aaaaaa', lake_color='#cccccc') m.drawcountries(linewidth=0.2) m.drawmapboundary(fill_color='#cccccc') X, Y = m(lon, lat) plt.scatter(X, Y, s = 20, color = 'red') plt.savefig('map.png')
I tried this:
# These are the coordinates I read out from Google Maps lat, lon = 80.615439, -15.474109 gmaps = pyproj.Proj('+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +no_defs') wgs84 = pyproj.Proj(init='epsg:4326') print(lat, lon) lon, lat = pyproj.transform(gmaps, wgs84, lon, lat) print(lat, lon)
This converts from 80.615439 -15.474109 to 0.000724 -0.000139.
What I'm looking for is a way to convert between two different lat-lon systems.