All Projects → wenzeslaus → python-grass-addon

wenzeslaus / python-grass-addon

Licence: other
How to write a Python GRASS GIS 7 addon

Programming Languages

Jupyter Notebook
11667 projects
python
139335 projects - #7 most used programming language
shell
77523 projects

Projects that are alternatives of or similar to python-grass-addon

QGIS-visualization-workshop
QGIS visualization workshop materials.
Stars: ✭ 46 (+2.22%)
Mutual labels:  workshop, gis
actinia core
Actinia Core is an open source REST API for scalable, distributed, high performance processing of geographical data that uses mainly GRASS GIS for computational tasks (DOI: https://doi.org/10.5281/zenodo.5879231)
Stars: ✭ 41 (-8.89%)
Mutual labels:  gis, grass-gis
VJ-Base
An addon for Garry's mod that contains bunch of bases to make many different types of addons.
Stars: ✭ 57 (+26.67%)
Mutual labels:  workshop, addon
Blendergis
Blender addons to make the bridge between Blender and geographic data
Stars: ✭ 4,642 (+10215.56%)
Mutual labels:  addon, gis
gis-for-geoscientists
Repository for "GIS for Geoscientists" workshop series. This repo contains data, protocols, outputs, lectures, and resources used the workshop. Course taught by Nicholas Barber. Available for future booking upon request! Contact me ([email protected]) for a quote.
Stars: ✭ 19 (-57.78%)
Mutual labels:  workshop, gis
scala-3-crash-course
Scala 3 workshop presenting the top new features of the language.
Stars: ✭ 34 (-24.44%)
Mutual labels:  workshop
mesh-api
Database for managing a mesh network
Stars: ✭ 14 (-68.89%)
Mutual labels:  gis
AIO
AIO is a pure lua server-client communication system for Eluna and WoW.
Stars: ✭ 50 (+11.11%)
Mutual labels:  addon
Ovale
An add-on for World of Warcraft that displays icons based on scripts
Stars: ✭ 46 (+2.22%)
Mutual labels:  addon
ckad-workshop
Getting Certified as a Kubernetes Application Developer.
Stars: ✭ 16 (-64.44%)
Mutual labels:  workshop
blender-texture-tools
Various utilities for handling images inside Blender.
Stars: ✭ 69 (+53.33%)
Mutual labels:  addon
addon-zerotier
ZeroTier One - Home Assistant Community Add-ons
Stars: ✭ 103 (+128.89%)
Mutual labels:  addon
gitops-helm-workshop
Progressive Delivery for Kubernetes with Flux, Helm, Linkerd and Flagger
Stars: ✭ 59 (+31.11%)
Mutual labels:  workshop
Workshop-GraphQL
A GraphQL Server made for the workshop
Stars: ✭ 22 (-51.11%)
Mutual labels:  workshop
statamic-video-embed
A field type for embedding YouTube and Vimeo Videos
Stars: ✭ 16 (-64.44%)
Mutual labels:  addon
copy-selected-tabs-to-clipboard
Provides ability to copy title and URL of selected tabs to the clipboard for Firefox 63 and later.
Stars: ✭ 46 (+2.22%)
Mutual labels:  addon
localtileserver
🌐 dynamic tile server for visualizing rasters in Jupyter with ipyleaflet or folium
Stars: ✭ 190 (+322.22%)
Mutual labels:  gis
saturn2019-architecture-island-workshop
What are the most essential ideas in software architecture all developers should know?
Stars: ✭ 25 (-44.44%)
Mutual labels:  workshop
ofxRaycaster
Plane, 2D and 3D Ray objects for openFrameworks.It checks for the intersection of a ray with a segment, a sphere, a triangle, a plane, an ofPrimitive, an ofPolyline an with an ofMesh.
Stars: ✭ 54 (+20%)
Mutual labels:  addon
my eu
Code and data for myeu.uk - find out what the EU has done for your area
Stars: ✭ 18 (-60%)
Mutual labels:  ipython-notebook

How to write a Python GRASS GIS 7 addon

This material was developed for FOSS4G Europe 2015 workshop.

GRASS GIS logo FOSS4G-E 2015 logo

How to use this tutorial

Using only GRASS GIS

Start GRASS GIS on you computer. Browse through IPython Notebooks as rendered on GitHub. To do this you just need to click on one of the files with the suffix .ipynb. In GRASS GIS in Layer Manager window, select Python shell in the bottom to get an interactive Python console where you can input, edit and run the examples. You may want to make the window bigger to have more space for the code.

With IPython and Git

Navigate to the directory where you want to work and clone this repository (unless you already downloaded a copy):

git clone https://github.com/wenzeslaus/python-grass-addon.git

Navigate to the repository directory:

cd python-grass-addon

Start GRASS GIS, from command line, using the North Carolina sample dataset:

grass7

Run (supposing that you are already in a GRASS GIS session) on command line:

ipython notebook

You will get a website in a web browser where you can select individual Notebooks, edit and run the examples.

Abstract

GRASS GIS is a leading software in analysis of geodata, it offers more than 400 modules in its core version plus many addons (i.e., user contributed modules). But what if the tool you are looking for is not present in GRASS GIS? So, simply create your own, we will show you how to do that in this workshop.

In GRASS GIS 7, Python is the default language for creating addons. There are two main Python libraries included in GRASS GIS. Python Scripting Library allows you to perform analysis and compute new data by chaining existing modules to create your own workflow.

With PyGRASS library wrapping the C functions, you can create new data sets (vector and raster) directly through Python calls, increasing considerably the power and performance of your scripts. You can conveniently mix both GRASS Python libraries with other Python libraries like NumPy, or SciPy. In this workshop, we will guide you through the basic steps of writing your own Python scripts, starting with calling and chaining GRASS GIS modules, followed by a more pythonic experience when using PyGRASS to access and modify your data directly.

You will then upgrade your script into an addon by defining a simple interface to enable automatically generated GUI. The next part of workshop will look into more advanced usage of GRASS GIS 7 capabilities, including Python spatio-temporal API to handle time series in your addons, creating your own toolbox with your newly developed addons and finally, introducing the new testing framework you should use as a responsible person to make sure your addons are in great shape.

Don't worry if we won't cover all the topics during the workshop, all materials will be accessible online and GRASS GIS community is always prepared to answer your questions!

Required knowledge

Participants should have basic knowledge of GIS, basic knowledge of GRASS GIS and basic knowledge of Python.

Set up a server

When organizing a workshop, it might be advantageous to use a server with IPython Notebook rather then setting up the environment on participant's computers. When IPython Notebook is used on a server, participants will need only a browser. All server-side work is easy to do thanks to Docker.

mkdir workdir
cd workdir

wget http://grass.osgeo.org/sampledata/north_carolina/nc_basic_spm_grass7.tar.gz
wget https://github.com/wenzeslaus/python-grass-addon/archive/master.tar.gz

tar xvf nc_basic_spm_grass7.tar.gz
tar xvf master.tar.gz

Now you can get the basic GRASS GIS image. Note that if you user does not have permissions to use docker (the usual defaut), you have to prefix the docker command with sudo. The same applies for scripts used futher on which are using the docker command. If you already have the image, you can skip this step.

docker build github.com/wenzeslaus/grass-gis-docker

To create the image and containers we need some files from this repository (we got its content in previous steps). We use mv because we don't need those files to be compied to the containers later.

mv python-grass-addon-master/Dockerfile .
mv python-grass-addon-master/run_containers.sh .
mv python-grass-addon-master/command_containers.sh .

Build a Docker image with sample dataset and Notebooks. If you are using your image for GRASS GIS (see above), be sure you have the right image name in the Dockerfile (used by following command).

docker build -t wenzeslaus/python-grass-addon .

Create a file with users you want to create an container for. The file must contain emails at the beginning of each line (it can be for example CSV, double quote at the beginning is ignored).

Now you can start:

./run_containers.sh workshop_atendees.txt 9000

Alternatively, you can just specify number of conatiners you want to create:

./run_containers.sh 15 9000

This will give you list of URLs and passwords with associated usernames. Usernames are used only to keep track of containers and to distribute the credentials. Note that the atendees will have to get through "untrusted connection" dialog in their browsers because the certificate used is self-signed.

The above command will also create a file named containers_workshop_atendees.txt (or containers_dateandtime.txt) with names of conatiners. For further actions, if they are simple enough, you can use a prepared script. For example, to get rid of the containers use:

./command_conatiners.sh stop containers_workshop_atendees.txt
./command_conatiners.sh rm containers_workshop_atendees.txt

Instructions for participants when IPython Notebook server is used

You have obtained URL which looks like:

https://fatra.cnr.ncsu.edu:9503

Type it precisely to the web browser including the s at the end of https, note also that port number is specified (the number at the end separated from domain by a colon.

You browser will warn you about invalid security certificate. In this case, you can safely add security exception. The reason for the message is that the certificate is self-signed.

Finally, enter the password you were provided with. Then you should see a list of notebooks as displayed by IPython Notebook.

When and where the workshop was presented

  • North Carolina State Univeristy, test run (2 hours)
  • FOSS4G Europe 2015, Como, Italy (4 hours)
  • North Carolina State Univeristy, workshop for a geovisualization class (2 hours), recording available

Authors

  • Pietro Zambelli, European Research Academy
  • Markus Neteler, Fondazione Edmund Mach
  • Luca Delucchi, Fondazione Edmund Mach
  • Vaclav Petras, NCSU OSGeoREL
  • Anna Petrasova, NCSU OSGeoREL

Copyright (C) 2015 by authors.

License

The documentation is dual licensed under CC BY-SA and GNU FDL.

The code samples are under GNU GPL 2 or later (which is the license GRASS GIS is under).

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].