forked from OSGeo/grass
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
r.stats.zonal manual: add screenshots (OSGeo#2577)
* r.stats.zonal manual: add figure to illustrate module functionality along with jupyter notebook * r.series: bugfix for labeling
- Loading branch information
Showing
5 changed files
with
126 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"# Graphics for description of r.stats.zonal\n", | ||
"\n", | ||
"To be run in a GRASS GIS session, North Carolina sample dataset.\n", | ||
"\n", | ||
"Requires _d.explanation.plot_ (GRASS GIS addon), _pngquant_, _optipng_ and ImageMagic _mogrify_." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"import os\n", | ||
"\n", | ||
"from IPython.display import Image\n", | ||
"\n", | ||
"import grass.script as gs\n", | ||
"import grass.jupyter as gj\n", | ||
"\n", | ||
"gs.set_raise_on_error(True)\n", | ||
"gs.set_capture_stderr(True)\n", | ||
"os.environ[\"GRASS_OVERWRITE\"] = \"1\"" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"# zoom to spatial subset of \"zipcodes\" map (5 x 5 pixels)\n", | ||
"!g.region n=225430 s=225380 w=640250 e=640300 res=10 -p\n", | ||
"\n", | ||
"# average elevation in zipcode areas\n", | ||
"!r.stats.zonal base=zipcodes cover=elevation method=average output=zipcodes_elev_avg\n", | ||
"!r.colors zipcodes_elev_avg color=elevation -g" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"plot = gj.Map(use_region=True, width=1100, height=1100)\n", | ||
"plot.d_background(color=\"white\")\n", | ||
"plot.run(\n", | ||
" \"d.explanation.plot\",\n", | ||
" a=\"zipcodes\",\n", | ||
" b=\"elevation\",\n", | ||
" c=\"zipcodes_elev_avg\",\n", | ||
" label_a=\"zipcode areas\",\n", | ||
" label_b=\"elevation\",\n", | ||
" label_c=\"Avg elev. / area\",\n", | ||
" operator_font=\"FreeMono:Regular\",\n", | ||
")\n", | ||
"plot.show()" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"filename = \"r_stats.zonal.png\"\n", | ||
"plot.save(filename)\n", | ||
"!mogrify -trim {filename}\n", | ||
"!pngquant --ext \".png\" -f {filename}\n", | ||
"!optipng -o7 {filename}\n", | ||
"Image(filename)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3 (ipykernel)", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.11.1" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 4 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.