In [3]:
# In order for this notebook to work, it assumes two things:
#
# 1. You have ingested source elevation data into MrGeo, giving
#    if the name "small-elevation". If you ingest to a different
#    name, be sure to change the code in this notebook accordingly.
# 2. You have the MrGeo web services running on the localhost. You
#    can run "mrgeo webserver" on the command line to start a standalone
#    isntance of the MrGeo web services for this purpose.

import math
from pymrgeo import MrGeo
import folium
from folium import plugins
from folium.features import WmsTileLayer

mrgeo = MrGeo()
mrgeo.usedebug()
mrgeo.start()
try:
    output_name = "test-slope-10"
    elev = mrgeo.load_image("small-elevation")
    slope_gradient = elev.slope("gradient")
    intermediate_slope = slope_gradient + 0.05
    tobler_raw = 6 * math.e ** (-3.5 * intermediate_slope.abs())
    tobler_raw.save(output_name)
    tobler_raw_2 = mrgeo.load_image(output_name)
    tobler_raw_2.buildpyramid()

finally:
    mrgeo.stop()

map_osm = folium.Map(location=[-18, 142],
                     crs='EPSG3857',
#                      crs='EPSG4326',
                     tiles='OpenStreetMap')
wms_layer = WmsTileLayer('http://localhost:8080/mrgeo/wms', name='MrGeo',
                             format='image/png',
                             layers=output_name,
                             styles='rainbow',
                             overlay=True,
                             transparent=True, control=True)
map_osm.add_child(wms_layer)
map_osm.add_child(folium.LayerControl())
map_osm


Initializing gateway
Talking with MrGeo on port 25333
Out[3]: