def map_ice_conc(df,m,cols): lat = 73. lon = 45.748445 center = [lat, lon] zoom = 2 #m = Map(default_tiles=TileLayer(opacity=1.0), center=center, zoom=zoom) for i in range(df.shape[0]): bounds=df.geometry.values[i] crd=bounds.exterior.coords.array_interface()['data'] shapes=bounds.exterior.coords.array_interface()['shape'] crd1=[] for j in range(0,shapes[0]*2,2): crd1.append((crd[j+1],crd[j])) cid=df.loc[df.index==i,'CT'].values[0] if cid=='-9': fcolor = mpl.colors.rgb2hex(cols.loc[cols.CT==0,['color1','color2','color3']].values[0]/255.) else: fcolor = mpl.colors.rgb2hex(cols.loc[cols.CT==np.int(cid),['color1','color2','color3']].values[0]/255.) pg = il.Polygon(locations=crd1, weight=1, color='white', opacity=0.8, fill_opacity=0.5, fill_color=fcolor ) m += pg
def show_timetables(map: Map, timetables: List[Timetable]) -> None: for i, timetable in enumerate(timetables): for j, variant in enumerate(timetable.variants): group = lf.LayerGroup(name=f"{timetable.caption}, variant {j}") for stop in variant.stops: group.add_layer( lf.Marker( location=(stop.latitude, stop.longitude), draggable=False, title=stop.name, ) ) map.add_layer(group) section_group = lf.LayerGroup( name=f"(Shapes) {timetable.caption}, variant {j}" ) for section in prediction.route_sections(variant.stops): p = section.polygon section_group.add_layer( lf.Polygon( locations=[list(p.exterior.coords), list(p.interiors)], color="blue", ) ) map.add_layer(section_group)
def display_composite_ipyleaflet(self, zoom=10): image = self.image.clip(ee.Geometry(self.polygon)) mapid = image.getMapId() tiles_url = self.ee_tiles.format(**mapid) tile_layer = ipyl.TileLayer(url=tiles_url, layers='collection', format='image/png', name=self.collection, opacity=1) polygon = ipyl.Polygon(locations=self.locations, color=self.color, fill_opacity=0., name='AoI') m = ipyl.Map(center=tuple(self.centroid), zoom=zoom) m.add_layer(tile_layer) m.add_layer(polygon) control = ipyl.LayersControl(position='topright') m.add_control(control) m.add_control(ipyl.FullScreenControl()) return m
def loadPolygons(self, o): o["layers"].clear_layers() data = o["datasource"].getData() for key, value in data.items(): coords = value[o["coords"]] a = coords.split(" ") points = [] i = 0 while True: points.append((a[i + 1], a[i])) i += 2 if i >= len(a): break polygon = maps.Polygon(locations=points) polygon.stroke = True polygon.weight = 1 if "text" in o: text = value[o["text"]] polygon.popup = widgets.HTML(value=text) polygon.color = "green" polygon.fill_color = "green" o["layers"].add_layer(polygon) if self._map != None: self._map.add_layer(o["layers"])
def display_video(self, zoom=12): # Display movie on map m = ipyl.Map(center=tuple(self.centroid), zoom=zoom) video = ipyl.VideoOverlay(url=self.file_name, bounds=tuple(list(map(tuple, self.bounds)))) polygon = ipyl.Polygon(locations=self.locations, color=self.color, fill_opacity=0., name='AoI') m.add_layer(video) m.add_layer(polygon) return m
def map_ice_conc_f(df,m,cols,name_col='CT',fdate='2018-07-04T12:00:00',map_dt=datetime.date(2016,1,10)): #datetime.datetime.now()): lat = 73. lon = 45.748445 center = [lat, lon] zoom = 2 #m = Map(default_tiles=TileLayer(opacity=1.0), center=center, zoom=zoom) pyear=map_dt.year pweek=pd.to_datetime(map_dt.strftime('%Y%m%d')).week if pyear==2016: pyear=pd.to_datetime(fdate).year pweek=pd.to_datetime(fdate).week for lon in df.lon.unique(): for lat in df.lat.unique(): #print(lon,lat) crd1=get_p(lat,lon,1.) cid=df.loc[ (df.year==pyear)& (df.week==pweek)& #(df.dat==map_dt)& (df.lat==lat)& (df.lon==lon),name_col] #print(cid.shape) if cid.shape[0]!=0: cid=cid.values[0] else: continue #print(cid) name_color='CT' if (cid==-9)|(cid=='-9'): fcolor = mpl.colors.rgb2hex(cols.loc[cols[name_color]==0,['color1','color2','color3']].values[0]/255.) else: fcolor = mpl.colors.rgb2hex(cols.loc[cols[name_color]==np.int(cid),['color1','color2','color3']].values[0]/255.) pg = il.Polygon(locations=crd1, weight=1, color=fcolor #'white' , opacity=0.8 , opacity=0.5 , fill_opacity=0.5, fill_color=fcolor ) m += pg
def plot_isochrones(coordinates, isochrones, zoom_level=8): '''Initiate map and plot isochrones centered on coordinates.''' center = coord_to_tuple(coordinates) layer_color = 'brown' fill_color = 'orange' m = ipl.Map(center=center, zoom=zoom_level) for key in isochrones.keys(): item = ipl.Polygon(locations=isochrones[key], color=layer_color, weight=1, fill_color=fill_color, fill_opacity=0.2, name=key) m.add_layer(item) m.add_control(ipl.LayersControl()) return m
def add_polygon(self, p: sg.Polygon, colour: str = "blue") -> None: self.add_layer( lf.Polygon( locations=[list(p.exterior.coords), list(p.interiors)], color=colour ) )