0

The following code snippet produces the warning. The csv has a list of longitudes and latitudes. The csv contains around 800,000 examples,

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

fname = "train.csv"
data = pd.read_csv(fname,sep=",",quotechar='"')
minlon=data["X"].min()
maxlon=data["X"].max()
minlat = data["Y"].min()
maxlat = data["Y"].max()


m =Basemap(projection='merc',llcrnrlat=minlat,urcrnrlat=maxlat,llcrnrlon=-minlon,urcrnrlon=maxlon,resolution='c')
m.drawcoastlines()
m.drawmapboundary()
x,y = m(list(data["X"].astype(float)),list(data["Y"].astype(float)))
m.scatter(x,y,1,marker='o',color='red')
plt.show()

Here is how the map is displayed:enter image description here

The warning generated reads: UserWarning: Unable to find pixel distance along axis for interval padding of ticks; assuming no interval padding needed. warnings.warn("Unable to find pixel distance along axis "

TheM00s3
  • 3,677
  • 4
  • 31
  • 65

1 Answers1

1

Mercator projection does not work around poles by definition, isn't there some value of latitude -90 deg or 90 deg?

Radek Hofman
  • 517
  • 3
  • 12
  • maxlat is equal to 90. How does one go about and specify geographic areas that they want to zoom on? Im looking to zoom on SF. – TheM00s3 Jan 09 '16 at 20:03
  • @them00s3 For the beginning, try to use cylindrical projection, i.e. `projection='cyl'`. I do not understand the rest of your question, can you be please more specific? – Radek Hofman Jan 09 '16 at 21:24
  • I want to have a map of San Francisco and put a scatter plot on top. – TheM00s3 Jan 09 '16 at 21:46
  • @TheM00s3 oh, I see. But for such a map like a city map, Basemap is probably not a good choice since it contains only country and state borders. When you zoom to are of SF, you will probably see just an empty canvas, maybe US border but nothing else. I would go for GoogleMaps or OpenStreetMaps in this case -- like [http://stackoverflow.com/questions/3059044/google-maps-js-api-v3-simple-multiple-marker-example](http://stackoverflow.com/questions/3059044/google-maps-js-api-v3-simple-multiple-marker-example). Markers can be alsi clickable and so on. – Radek Hofman Jan 10 '16 at 09:16