Reputation: 6551
In various operational and manually-run Python scripts, I produce thousands of plots of California every day using matplotlib's Basemap:
mp = Basemap(width=1284000,height=1164000,projection='lcc',lat_1=30.,lat_2=60,\
lat_0=37,lon_0=-120.5,resolution='c',rsphere=6370000.00)
# fill data: lats, lons, grid
cs = orb.pcolor(lons,lats,grid,cmap=cm.jet,norm=colors.LogNorm(),latlon=True)
mp.drawcounties()
However, I lose dozens of hours of computing time every single day to loading these large basemaps that cover the entire world. All I need is the counties in California, but I end up loading all the counties in the world into memory. I love how flexible this library is, but it is officially too slow.
Basemap
, with only California?Upvotes: 2
Views: 1836
Reputation: 384
How could I produce these maps faster?
You are already using the lowest resolution ("c"). You can change the "area_thresh" argument, but I don't think that'll help much. You'll probably have to work on the way you're plotting the data itself.
Could I somehow create a cropped version of the matplotlib Basemap, with only California?
You can download a custom map of California and plot only that. Basemap comes with basic world maps, but you can use maps from other sources. It should be easy to get one googling "california shapefile". Use the "readshapefile" method in mpl_toolkits.basemap to load it.
This notebook shows how to work with readshapefile and with an alternative method (the pyshp module).
Is there a faster, non-matplotlib way to create geo-referenced plots?
I've heard good things about Vincent, but I haven't tried it myself.
Upvotes: 3