Changes between Version 20 and Version 21 of GSoC/2021/JupyterAndGRASS
- Timestamp:
- 08/22/21 12:48:39 (3 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
GSoC/2021/JupyterAndGRASS
v20 v21 9 9 || GSoC proposal: || [https://docs.google.com/document/d/1ZT0cZobd87YCb3Ogis7RzWPj02XZkCpAHbC3VBGh7gc/edit?usp=sharing View Proposal] || 10 10 11 [https://mybinder.org/v2/gh/OSGeo/grass/ 5e2fd30?urlpath=lab%2Ftree%2Fdoc%2Fnotebooks%2Fjupyter_integration.ipynb Try grass.jupyter in Binder here]11 [https://mybinder.org/v2/gh/OSGeo/grass/c173461?urlpath=lab%2Ftree%2Fdoc%2Fnotebooks%2Fgrass_jupyter.ipynb Try grass.jupyter in Binder here] 12 12 13 13 == Abstract == 14 The previous integration of GRASS GIS and Jupyter Notebooks required a cumbersome environment variable setup after launching GRASS from within the notebook . It also only allowed for simple, non-interactive map displays. The `grass.jupyter` subpackage for addresses both these issues by introducing a new startup function, `init()`, and two display classes, `GrassRenderer` and `InteractiveMap`. `GrassRenderer` renders GRASS displays as PNG images. `InteractiveMap` displays rasters and vectors in[https://python-visualization.github.io/folium/index.html folium], a leaflet library for Python.14 The previous integration of GRASS GIS and Jupyter Notebooks required a cumbersome environment variable setup after launching GRASS from within the notebook and only allowed for simple, non-interactive map displays. The `grass.jupyter` subpackage for addresses both these issues by introducing a new startup function, `init()`, and two display classes, `GrassRenderer` and `InteractiveMap`. `GrassRenderer` renders GRASS displays as PNG images using a more intuitive syntax. `InteractiveMap` displays rasters and vectors interactively with [https://python-visualization.github.io/folium/index.html folium], a leaflet library for Python. 15 15 16 16 == Goal == … … 432 432 433 433 **Abstract:**\\ 434 This project introduces a new subpackage for GRASS GIS, `grass.jupyter` that improves the integration of GRASS GIS with Jupyter Notebooks. Previously, using GRASS in Jupyter Notebooks required a cumbersome environment variable setup after launching GRASS from within the notebook . It also only allowed for simple, non-interactive map displays. The `grass.jupyter` subpackage for addresses both these issues by introducing a new startup function, `init()`, and two display classes, `GrassRenderer` and `InteractiveMap`. `GrassRenderer` renders GRASS displays as PNG images. `InteractiveMap` displays rasters and vectors in[https://python-visualization.github.io/folium/index.html folium], a leaflet library for Python.434 This project introduces a new subpackage for GRASS GIS, `grass.jupyter` that improves the integration of GRASS GIS with Jupyter Notebooks. Previously, using GRASS in Jupyter Notebooks required a cumbersome environment variable setup after launching GRASS from within the notebook and only allowed for simple, non-interactive map displays. The `grass.jupyter` subpackage addresses both these issues by introducing a new startup function, `init()`, and two display classes, `GrassRenderer` and `InteractiveMap`. `GrassRenderer` renders GRASS displays as PNG images using an intuitive syntax. `InteractiveMap` displays rasters and vectors interactively with [https://python-visualization.github.io/folium/index.html folium], a leaflet library for Python. 435 435 436 436 **The state of integration BEFORE the start of GSoC:**\\ 437 The previous integration of GRASS GIS and Jupyter Notebooks required a cumbersome environment variable setup after launching GRASS from within the notebook. There is an external python library grass_session that can be installed to shorten this launch substantially but, as an external library, it is not included in a typical GRASS install. Additionally, the previous integration allowed for maps to rendered as PNG images uses a unintuitive sequence of calling `d.erase`, then modules from the display family and finally rendering the image with IPython.display `Image()`. 437 The previous integration of GRASS GIS and Jupyter Notebooks required a cumbersome environment variable setup after launching GRASS from within the notebook. There is an external python library grass_session that can be installed to shorten this launch substantially but, as an external library, it is not included in a typical GRASS install. Additionally, the previous integration allowed for maps to rendered as PNG images uses a unintuitive sequence of calling `d.erase`, then modules from the display family and finally rendering the image with IPython.display `Image()`. For an example this workflow, see [https://mybinder.org/v2/gh/OSGeo/grass/c173461?urlpath=lab%2Ftree%2Fdoc%2Fnotebooks%2Fbasic_example.ipynb basic_example.ipynb]. 438 438 439 439 **The state of integration AFTER GSoC:**\\ 440 With the help of my mentors, I introduced a new package `grass.jupyter` that contains a new `init()` function to shorten the launch and two display-related classes, `GrassRenderer` and `InteractiveMap`. `GrassRenderer` wraps the previous approach, rendering PNG images . Users create an instance of `GrassRenderer` then add elements to the rendering with GRASS display modules. The GRASS modules are called by using the name of module as a class method and replacing "." with "_" in the name. For example, to add a raster, one would call `GrassRenderer.d_rast(map="raster_name")`.440 With the help of my mentors, I introduced a new package `grass.jupyter` that contains a new `init()` function to shorten the launch and two display-related classes, `GrassRenderer` and `InteractiveMap`. `GrassRenderer` wraps the previous approach, rendering PNG images but with a more intuitive syntax. Users create an instance of `GrassRenderer` then add elements to the rendering with GRASS display modules. The GRASS modules are called by using the name of module as a class method and replacing "." with "_" in the name. For example, to add a raster, one would call `GrassRenderer.d_rast(map="raster_name")`. 441 441 442 442 `InteractiveMap`, the other display-related class in `grass.jupyter`, allows users to view GRASS vectors and rasters in [https://python-visualization.github.io/folium/index.html folium], a leaflet library for Python. After creating an instance of `InteractiveMap`, users can add vectors and rasters with `add_vector()` and `add_raster()`. Users can also add a layer control element with `add_layer_control()`. Folium only supports EPSG 4326 (for raster overlay) and EPSG 3857 (for vectors and coordinates) so `InteractiveMap` creates a temporary location, reprojects data then saves it to a temporary directory where it is imported by folium. … … 451 451 3. introducing an interactive map display function (`InteractiveMap()`) 452 452 453 The work I accomplished this summer paves the way for many future improvements, listed below in the Future Work section. In addition to some smaller modifications to `init()` and 'GrassRenderer', there remains a lot of work to be done on `InteractiveMap` or with other folium-GRASS class es/functionsto fully access folium. I am grateful for the support I've received this summer and for the opportunity to contribute to GRASS GIS. I'm looking forward to continuing to improve `grass.jupyter`.453 The work I accomplished this summer paves the way for many future improvements, listed below in the Future Work section. In addition to some smaller modifications to `init()` and 'GrassRenderer', there remains a lot of work to be done on `InteractiveMap` or with other folium-GRASS class to fully access folium. I am grateful for the support I've received this summer and for the opportunity to contribute to GRASS GIS. I'm looking forward to continuing to improve `grass.jupyter`. 454 454 455 455 **Future Work:**\\ … … 492 492 493 493 Binder Examples: \\ 494 [https://mybinder.org/v2/gh/OSGeo/grass/5e2fd30?urlpath=lab%2Ftree%2Fdoc%2Fnotebooks%2Fjupyter_integration.ipynb grass.jupyter tutorial] 495 [more links coming...] 496 497 498 494 [https://mybinder.org/v2/gh/OSGeo/grass/c173461?urlpath=lab%2Ftree%2Fdoc%2Fnotebooks%2Fgrass_jupyter.ipynb grass_jupyter.ipynb] 495 [https://mybinder.org/v2/gh/OSGeo/grass/c173461?urlpath=lab%2Ftree%2Fdoc%2Fnotebooks%2Fbasic_example_grass_jupyter.ipynb basic_example_grass_jupyter.ipynb] 496 [https://mybinder.org/v2/gh/OSGeo/grass/c173461?urlpath=lab%2Ftree%2Fdoc%2Fnotebooks%2Fhydrology.ipynb hydrology.ipynb] 497 [https://mybinder.org/v2/gh/OSGeo/grass/c173461?urlpath=lab%2Ftree%2Fdoc%2Fnotebooks%2Fviewshed_analysis.ipynb viewshed_analysis.ipynb] 498 [https://mybinder.org/v2/gh/OSGeo/grass/c173461?urlpath=lab%2Ftree%2Fdoc%2Fnotebooks%2Fsolar_potential.ipynb solar_potential.ipynb] 499 500 501