I'm having difficulties using Matplotlibs Basemap in combination with a PyQt4 interface. Basically I create a Pyqt4 Canvas in which I plot a Matplotlib Basemap and some markers. I call the function in
self.button3 = QtGui.QPushButton('plot', self) self.button3.clicked.connect(lambda: self.plot(geom0))
And pass a geometry to my plot(geom0) function.
def plot(self, geom0): x1, y1 = zip(*((geom0.GetX(i), geom0.GetY(i)) for i in range(geom0.GetPointCount()))) print geom0 self.m = Basemap(projection='merc', resolution = None, area_thresh = 0.1,llcrnrlon=6.66321, llcrnrlat=50.48198, urcrnrlon=7.54761, urcrnrlat=51.46085) self.m.drawlsmask(land_color='lightgreen',ocean_color='aqua',lakes=True) x,y = self.m(x1, y1) self.m.plot(x, y, 'D-', markersize=4, linewidth=2, color='k', markerfacecolor='b') self.canvas.draw()
This works fine and the canvas is filled and a map without any kind of resolution is shown with my Linestring from
geom0 but when I change the resolution to low
'l' or high
'h' Python quits unexpectedly. Changing the resolution to low or high takes a while to calculate and I guess that is where the problem lies.
Do you have any ideas how I can tell PyQt to wait until the Basemap is calculated?