#!/usr/bin/env python # coding: utf-8 # # Map plots # # Plots on Mapbox maps are available only considering you have a Mapbox account and a Mapbox Access Token. After getting a mabox token it can be written set to pandapower as the following (where `''` needs to be replaced with provided mapbox token) # In[1]: from pandapower.plotting.plotly.mapbox_plot import set_mapbox_token set_mapbox_token('') # If network geodata are in Geographic coordinate system as latitude/longitude, a network can be plot on different maps. # Moreover, if network geodata are not in latitude/longitude, but in some of the projections, it may be converted to lat/long by providing name of the projection (in the form '*epsg:projection_number*'according to http://spatialreference.org/ref/epsg/). # # Following example shows plot of the network mv_oberrhein, where network geodata are in Gauss-Kruger projection (zone 3). # Since geodata are not in lat/long, plot using only `on_map=True` cannot be realized on a map: # In[2]: from pandapower.plotting.plotly import simple_plotly, pf_res_plotly, vlevel_plotly from pandapower.networks import mv_oberrhein net = mv_oberrhein() # The plot can be obtained if one knows specific projection and zone. In this case it is 3-degree Gauss-Kruger zone 3, which corresponds to [epsg:31467](http://spatialreference.org/ref/epsg/31467/): # In[3]: # net = mv_oberrhein() simple_plotly(net, on_map=True)# , projection='epsg:31467'); # ## Transforming geo-data from a projection to lat/long # There is a function available in pandapower which uses `pyproj` to transform geodata from a projection to WGS84 (lat/long). It transforms and replaces `net.bus_geodata` and `net.line_geodata` (if existing). An example for `mv_oberreihn`: # In[4]: net = mv_oberrhein() print('before:\n', net.bus.geo.head()) from pandapower.plotting.plotly.mapbox_plot import geo_data_to_latlong # geo_data_to_latlong(net, projection='epsg:31467') print('\nafter:\n', net.bus.geo.head()) # ## Some more map plots... # The following map styles are available: # * 'streets' # * 'bright' # * 'light' # * 'dark' # * 'satellite' # In[5]: simple_plotly(net, on_map=True,map_style='satellite'); # In[6]: net = mv_oberrhein() simple_plotly(net, on_map=True, projection='epsg:31467', map_style='streets'); # In[7]: pf_res_plotly(net, on_map=True, map_style='dark'); # More tutorials about interactive plots using ploltly: # * [built-in interactive plots](http://nbviewer.jupyter.org/github/e2nIEE/pandapower/blob/develop/tutorials/plotly_built-in.ipynb) # * [custom interactive plots](http://nbviewer.jupyter.org/github/e2nIEE/pandapower/blob/develop/tutorials/plotly_traces.ipynb)