I have an application in which I would like to draw counties from a shapefile using Basemap. Drawing graph polygons is a bottleneck in rendering, and since I will draw the same region in the USA (a bunch of times), I'd rather not draw all the polygons more than I need. So I got the idea to draw counties on a figure with a transparent background, copy the axes to the pixel buffer using copy_from_bbox() and restore the buffer using restore_region() when I need to draw counties.
The main code is as follows:
import matplotlib.pyplot as plt from mpl_toolkits.basemap import Basemap map = Basemap(...)
It works like a charm ... except for the line where I clean the figure. Clearing a shape between visualizers seems to also clear the BufferRegion object, and since I am updating the title and color bar, I would also like to clear the shape between renderings.
So my question is, does anyone know a way to clear the shape and keep the pixel buffer intact? I could not find much documentation on BufferRegion , copy_from_bbox() or restore_region() , so it was a bit difficult to debug this. If there is no easy way around, does anyone know another way to do basically what I'm trying to do?
Thanks in advance!
source share