Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jupyter: Interactive display #1684

Closed
wants to merge 6 commits into from
Closed

Conversation

chaedri
Copy link
Contributor

@chaedri chaedri commented Jun 25, 2021

This PR contains interactive functions for displaying GRASS maps in Jupyter Notebooks using folium. It is part of an ongoing Google Summer of Code project, Improved Integration of GRASS and Jupyter Notebooks. You can find more information here.

The functions can also be tried in this Jupyter Notebook:

https://mybinder.org/v2/gh/chaedri/grass/interactive-display?urlpath=lab%2Ftree%2Fdoc%2Fnotebooks%2Fjupyter_integration.ipynb

@chaedri chaedri closed this Jun 25, 2021
@chaedri chaedri reopened this Jun 25, 2021
@chaedri chaedri marked this pull request as draft June 25, 2021 14:34
@chaedri
Copy link
Contributor Author

chaedri commented Jun 25, 2021

This is just a draft (it doesn't allow the display of vectors at all yet!) but I wanted to open a PR so we could discuss and I could have some feedback. One of the issues I'm working on is figuring out the best way to pass raster/vector data between GRASS and folium. In this first draft, a PNG of the raster is written by GRASS then overlayed on a map in folium. But, I think folium only takes certain projections (WGS84), so I reproject the bounding box of the region and stretch the PNG into the box when it's overlayed. Thoughts and feedback welcome.

Copy link
Member

@wenzeslaus wenzeslaus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leaving aside the issue of reprojection for now, the image size does not correspond to the region. The region is fitted into the image, but the image contains whitespace on the sides which is outside of the computational region (in other context, it could be used e.g. for legend). However, to georeference the image, it needs to actually exactly fit the region, so the ratio needs to be the same. See for example of the this procedure:

https://github.com/ncsu-geoforall-lab/grass-web-publishing

You can test the basic fit with the base map using:

gs.run_command("v.to.rast", input="roadsmajor", output="roadsmajor", use="val")
spm_map.d_rast("roadsmajor")
spm_map.show_interactively(opacity=0.7)

@wenzeslaus wenzeslaus added this to In progress in Integration with Jupyter Notebooks via automation Jun 28, 2021
@wenzeslaus wenzeslaus added enhancement New feature or request gsoc Reserved for Google Summer of Code student(s) labels Jun 28, 2021
@wenzeslaus wenzeslaus changed the title Interactive display Jupyter: Interactive display Jul 2, 2021
@chaedri chaedri closed this Jul 8, 2021
Integration with Jupyter Notebooks automation moved this from In progress to Done Jul 8, 2021
@chaedri
Copy link
Contributor Author

chaedri commented Jul 8, 2021

These changes are in PR #1710.

@chaedri chaedri deleted the interactive-display branch August 17, 2021 01:46
@neteler neteler added this to the 8.0.0 milestone Dec 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request gsoc Reserved for Google Summer of Code student(s)
Development

Successfully merging this pull request may close these issues.

None yet

3 participants