<h1 style="text-align: center;">
Improve GRASS user experience in Jupyter Notebook
</h1>
<p style="text-align: center;">Google Summer of Code Proposal <br>
<b>Summer 2024</b></p>
## Contact Details
- **Name and Surname:** Riya Saxena
- **Nickname**: Riya
- **Country:** India
- **Email:** 29riyasaxena@gmail.com
- **Phone:** [9413370466](<tel: 9413370466>)
- **Public repository:** [29riyasaxena](https://github.com/29riyasaxena/)
- **Personal blog (optional):** [29riyasaxena](https://29riyasaxena.github.io/Portfolio/)
- **Twitter/Identica/LinkedIn/others:** [29riyasaxena](https://www.linkedin.com/in/29riyasaxena/)
## Your Idea
- **OSGeo or guest software:** [GRASS GIS](https://grass.osgeo.org/)
- **Title:** [Improve GRASS user experience in Jupyter Notebook](https://grasswiki.osgeo.org/wiki/GRASS_GSoC_Ideas_2024#Improve_GRASS_user_experience_in_Jupyter_Notebook)
- **Brief Description:** My project involves:
1. Enhancing `InteractiveMap` with additional features.
2. Use `InteractiveMap` with custom projections.
3. Optimizing rendering process for SeriesMap and TimeseriesMap.
Stretch goals:
1. Improving connection of `GRASS` with Pandas.
2. Incorporating tiles for displaying extensive datasets.
3. GUI integration in a Jupyter Notebook.
- **State of the software BEFORE your GSoC:**
- **Current Feature of `InteractiveMap()`**: The `grass.jupyter.InteractiveMap()` offers basic functionalities, including zooming, panning, and layer addition, as depicted in the provided image.
![interactive.png](https://hackmd.io/_uploads/rJqbtQ1yA.png)
- **Projection Details:** Presently, the map projection utilized by `grass.jupyter.InteractiveMap()` is Pseudo-Mercator, managed through the `ReprojectionRenderer` module.
```python
# InteractiveMap
self._renderer = ReprojectionRenderer(
use_region=use_region, saved_region=saved_region
)
# ReprojectionRenderer
self._rcfile_psmerc, self._psmerc_env = setup_location(
"psmerc", self._tmp_dir.name, "3857", self._src_env
)
self._rcfile_wgs84, self._wgs84_env = setup_location(
"wgs84", self._tmp_dir.name, "4326", self._src_env
)
```
- **Rendering Performance:** Rendering the map with `grass.jupyter.InteractiveMap()` is suboptimal, evidenced by the considerable time it takes to display, approximately 7.55 seconds per loop.
- **Data Handling:** Integrating data from Pandas DataFrames into the map requires cumbersome steps involving conversion to JSON format and subsequent DataFrame construction. For example:
```python
pd.DataFrame(
json.loads(
gs.read_command(
"v.db.select",
map="viewpoints",
columns="cat,height",
layer=2,
format="json",
)
)["records"]
)
```
- **Limitations with Large Data:** Displaying extensive raster datasets is currently unfeasible due to high memory consumption, posing a significant limitation.
- **Addition your project will bring:**
1. **Interactive Data Retrieval:** Users will gain the ability to retrieve associated data for selected raster and vector layers and visualize them on the map. Using ipyleaflet backend and ipywidgets I will add a button to the `InteractiveMap` to activate a query mode that enables users to click on the map to query the raster and vector attribute values. Additionally, users will be able to draw a box to set the computational region and draw simple geometries to add as a GRASS native vector map.
2. **Use `InteractiveMap` with custom projections:** By using custom coordinate reference systems (CRS), we can avoid reprojecting raster and vector layers to pseudomercator, significantly speeding up the visualization. IPyLeaflet supports that through Proj4Leaflet. While base layers won't work, this will be still a useful feature for visualizing and querying data.
3. **Optimizing rendering process for SeriesMap and TimeseriesMap:** SeriesMap and TimeseriesMap typically need to render many maps, which can be parallelized using standard Python libraries such as `multiprocessing`.
- **Future developments**
Ideas for stretch goals and future developments:
1. **Improved Pandas Integration:** Enhanced connectivity with Pandas will enable users to display data with a single command.
2. **High-Resolution Image Tiling:** Large, high-resolution image display will be enabled by implementing tiling techniques, reducing memory consumption and enabling smooth rendering of large images.
3. **GUI Integration:** Implementing a graphical user interface (GUI) for tool presentation within Jupyter Notebooks would simplify usability and enhance user experience, facilitating smoother workflows within the platform.
To enable easy maintenance after GSoC, all newly implemented code will be well documented and tested with tests written in pytest running in CI.
## Timeline
| Timeline | Tasks |
| ------------------------------------- | ----------------------------------------------------------------------------------------------------------- |
| **Bonding Period** | |
| (May 1- May 26) | Initial research |
| | Proposal Discussion with Mentor |
| **Official Coding Period** | |
| ***Week 1*** (May 27 - June 1) | Write initial function for adding button to `grass.jupyter.InteractiveMap()` |
| ***Week 2*** (June 2 - June 8) | Add click to see attributes features to the button |
| ***Week 3*** (June 9 - June 15) | Add button to allow users to create drawings in the displayed `InteractiveMap()` |
| ***Week 4*** (June 16 - June 22) | Add tools to the button to create different drawings |
| ***Week 5*** (June 23 - June 29) | Add functionality to retrieve points from user drawn drawings and add them to the data, if the user wants |
| ***Week 6*** (June 30 - July 6) | Speeding up the rendering of `InteractiveMap()` by skipping reprojection |
| ***Week 7*** (July 7 - July 13) | Code refactoring, testing, documentation |
| | Mid-term Evaluation: July 12 |
| ***Week 8*** (July 14 - July 20) | Adding parallelization to `TimeseriesMap` and `SeriesMap` |
| ***Week 9*** (July 21 - July 27) | Documentation, testing, writing tutorial |
| ***Week 10*** (July 28 - August 3) | Working on a selected stretch goal |
| ***Week 11*** (August 4 - August 10) | Working on a selected stretch goal |
| ***Week 12*** (August 11 - August 17) | Write project summary |
| | |
| **Evaluation Period** | |
| (August 26 - September 2) | Submit code and final evaluation |
- **Do you understand this is a serious commitment, equivalent to a full-time paid summer internship or summer job?** I acknowledge that the project I'm undertaking is large, spanning 350 hours in total. Over a 12-week period, excluding the Bonding and Evaluation Periods starting May 27, I'll be dedicating approximately 30 hours per week to this project.
- **Do you have any known time conflicts during the official coding period?** No, I do not have any known time conflicts during the official coding period.
## Studies
- **School and Degree:**
- I am currently a pre-final year Undergraduate student at the Department of Earth Sciences, IIT Roorkee, pursuing an Integrated Masters of Technology degree in Geological Technology.
- **Would your application contribute to your ongoing studies/degree? If so, how?**
- Participating in Google Summer of Code perfectly complements my academic journey. Through my involvement with the SEG-SPG Student Chapter IIT Roorkee and the Data Science Group, I've been actively contributing to open-source software development. GSoC offers me a fantastic opportunity to enhance my skills, gain practical experience, and connect with the GRASS-dev community. As part of my degree program, I'm eager to develop open-source GIS tools. Contributing to GRASS is a vital aspect of this goal. The proposed project to improve GRASS integration in Jupyter Notebook is a significant step forward. It will enable me to share my work effectively through Jupyter Notebooks while doing my Masters Thesis.
## Programming and GIS
- **Computing Experience:**
- **Laptop:** Lenovo ThinkPad
- **Processor:** 12th Gen Intel(R) Core(TM) i7-1255U @ 1.70 GHz
- **OS:** I primarily work on Windows Subsystem for Linux (Ubuntu 22.04.4 LTS)
- **Programming Languages:** Python (primary), C++, HTML, CSS, JavaScript, LaTeX
- **GIS Experience as a User:**
- I have experience with GRASS GIS, QGIS, and Google Earth Engine. My journey in GIS began during my undergraduate studies, where I took a course on Introduction to GIS. I further honed my skills by doing a project under the guidance of my professor, focusing on selecting the best spatial interpolation technique.
- **GIS Programming and Other Software Programming:**
- GeoPandas, GDAL, GRASS GIS, QGIS, and Google Earth Engine, alongside programming tools such as PyTorch, NumPy, JAX, Flax, Pandas, Matplotlib, LaTeX, Linux Shell, Vim, git, zsh, and ssh.
- **Former Open Source Contributions:**
- I have contributed to various open-source projects, including ModECI/MDF, networkx/outreachy, and gdsc-gvp/Machine-learning, with pull requests listed [#220](https://github.com/ModECI/MDF/pull/220), [#50](https://github.com/networkx/outreachy/pull/50), [#51](https://github.com/networkx/outreachy/pull/51), [#58](https://github.com/networkx/outreachy/pull/58), [#27](https://github.com/gdsc-gvp/Machine-learning/pull/27), [#32](https://github.com/gdsc-gvp/Machine-learning/pull/32), [#34](https://github.com/gdsc-gvp/Machine-learning/pull/34), [#35](https://github.com/gdsc-gvp/Machine-learning/pull/35), and [#98](https://github.com/iam-abbas/ML-FromScratch/pull/98).
## GSoC Participation
- **Have you participated in GSoC before?** No.
- **How many times, which year, which project?** N/A
- **Have you applied but were not selected? When?** No
- **Have you submitted/will you submit another proposal for this year's GSoC to a different org? Which one?** No.