matplotlib - Using basemap to plot tax trips in Python -


i'm trying use basemap function create plot 1 shown here, using this data.

this code:

west, south, east, north = -74.26, 40.50, -73.70, 40.92  fig = plt.figure(figsize=(14,10))  m = basemap(projection='merc', llcrnrlat=south, urcrnrlat=north,             llcrnrlon=west, urcrnrlon=east, lat_ts=south, resolution='c') x, y = m(df['pickup_longitude'].values, df['pickup_latitude'].values) m.hexbin(x, y, gridsize=1900, cmap=cm.ylorrd_r) 

however, result nothing weird.

enter image description here

i'm wondering i'm missing.

thanks.

it seems data comprises more data in range inside basemap plot.
desired plot using lot more gridpoints, e.g. gridsize=10000. cost lot of memory.

a better option first select dataframe values in range shown in map.

import pandas pd import matplotlib.pyplot plt mpl_toolkits.basemap import basemap matplotlib import cm  df = pd.read_csv("train.csv") west, south, east, north = -74.26, 40.50, -73.70, 40.92 df = df[(df['pickup_longitude'] > west) & (df['pickup_longitude'] < east)] df = df[(df['pickup_latitude'] > south) & (df['pickup_latitude'] < north)]  fig = plt.figure(figsize=(14,8))  m = basemap(projection='merc', llcrnrlat=south, urcrnrlat=north,             llcrnrlon=west, urcrnrlon=east, lat_ts=south, resolution='c') x, y = m(df['pickup_longitude'].values, df['pickup_latitude'].values) m.hexbin(x, y, gridsize=100, bins='log', cmap=cm.ylorrd_r, lw=0.4)  plt.show() 

enter image description here

using more gridpoints allows finer resolution. e.g. gridsize=1000:

enter image description here


Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -