def show(self,**kwargs): """ show Ezone Parameters ---------- title : string xlabel : string ylabel : string height : boolean display dem if True bldg : boolean display building if True coord : string 'lonlat'| 'cartesian' source: string 'srtm' | 'aster' extent : [lonmin,lomax,latmin,latmax] Returns ------- fig,ax Notes ----- If height is False the DEM is not displayed. If extent is a void list all the tile is displayed """ defaults = {'title':'', 'xlabel':'Longitude', 'ylabel':'Latitude', 'figsize':(10,10), 'height':True, 'bldg':False, 'clim':(0,200), 'coord':'lonlat', 'extent':[], 'contour':False, 'source':'srtm', 'alpha':0.5, 'facecolor':'black', 'cmap':plt.cm.jet } divider = [] for k in defaults: if k not in kwargs: kwargs[k]=defaults[k] if 'fig' in kwargs: fig = kwargs['fig'] else: fig = plt.figure(figsize=kwargs['figsize']) if 'ax' in kwargs: ax = kwargs['ax'] else: ax = fig.add_subplot(111) # get zone limitation # lon,lat or cartesian if kwargs['extent']==[]: if kwargs['coord']=='lonlat': extent = self.extent if kwargs['coord']=='cartesian': extent_c = self.extent_c else: if kwargs['coord']=='cartesian': extent_c = kwargs['extent'] extent = conv(extent_c,self.m,mode='toll') if kwargs['coord']=='lonlat': extent = kwargs['extent'] # ploting buildings with collection of polygons # if kwargs['coord'] == 'cartesian': kwargs['xlabel'] = 'W-E Distance (meters)' kwargs['ylabel'] = 'N-S Distance (meters)' if kwargs['title']=='': kwargs['title'] = self.prefix ax.set_title(kwargs['title']) ax.set_xlabel(kwargs['xlabel']) ax.set_ylabel(kwargs['ylabel']) if (kwargs['height'] | kwargs['contour']): if kwargs['source']=='srtm': shaphgt = self.hgts.shape else: shaphgt = self.hgta.shape # full original x and y # if kwargs['coord']=='lonlat': if kwargs['source']=='srtm': x = np.linspace(self.extent[0],self.extent[1],1201) # warning the y axis is inversed y = np.linspace(self.extent[3],self.extent[2],1201) hgt = self.hgts else: x = np.linspace(self.extent[0],self.extent[1],3601) y = np.linspace(self.extent[3],self.extent[2],3601) hgt = self.hgta if kwargs['coord']=='cartesian': self.tocart(source=kwargs['coord']) if kwargs['source']=='srtm': x = np.linspace(self.extent_c[0],self.extent_c[1],1201) y = np.linspace(self.extent_c[3],self.extent_c[2],1201) hgt = self.hgts_cart else: x = np.linspace(self.extent_c[0],extent_c[1],3601) y = np.linspace(self.extent_c[3],extent_c[2],3601) hgt = self.hgta_cart extent = extent_c # get index corresponding to the selected zone ix = np.where((x>=extent[0]) & (x<=extent[1]))[0] iy = np.where((y>=extent[2]) & (y<=extent[3]))[0] if kwargs['height']: im = ax.imshow(hgt[iy[0]:(iy[-1]+1),ix[0]:(ix[-1]+1)], extent=extent,clim=kwargs['clim'],cmap=kwargs['cmap'],alpha=kwargs['alpha']) divider = make_axes_locatable(ax) cax = divider.append_axes("right", size="5%", pad=0.05) cb = fig.colorbar(im,cax) cb.set_label('Height (meters)') if kwargs['contour']: cnt = ax.contour(hgt[iy[0]:(iy[-1]+1),ix[0]:(ix[-1]+1)],N=10,extent=extent,origin='upper') # display buildings if kwargs['bldg']: # get subtiles corresponding to extent if kwargs['coord']=='cartesian': extent = conv(extent_c,self.m,mode='toll') ltiles = ext2qt(extent,self.lL0) # iterating over subtiles for ti in ltiles: if ti in self.dbldg.keys(): info = self.dbldg[ti][0] poly = self.dbldg[ti][1] if kwargs['coord']=='cartesian': tu = map(lambda x : self.m(x[:,0],x[:,1]),poly) poly = map(lambda x : np.vstack((x[0],x[1])).T,tu) if kwargs['height']: fig,ax = plu.polycol(poly, clim = kwargs['clim'], facecolor=kwargs['facecolor'], fig=fig,ax=ax) else: fig,ax = plu.polycol(poly,info[:,3], clim = kwargs['clim'], fig=fig, ax=ax) return(fig,ax,divider)