{"id":13751606,"url":"https://github.com/wenzeslaus/python-grass-addon","last_synced_at":"2025-10-28T02:31:14.170Z","repository":{"id":34208209,"uuid":"38065057","full_name":"wenzeslaus/python-grass-addon","owner":"wenzeslaus","description":"How to write a Python GRASS GIS 7 addon","archived":false,"fork":false,"pushed_at":"2018-03-05T21:06:19.000Z","size":134,"stargazers_count":51,"open_issues_count":11,"forks_count":27,"subscribers_count":13,"default_branch":"master","last_synced_at":"2024-09-28T23:40:56.208Z","etag":null,"topics":["addon","gis","grass-gis","ipython-notebook","python","workshop"],"latest_commit_sha":null,"homepage":null,"language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/wenzeslaus.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-06-25T17:57:22.000Z","updated_at":"2024-03-29T10:20:42.000Z","dependencies_parsed_at":"2022-09-04T11:11:27.691Z","dependency_job_id":null,"html_url":"https://github.com/wenzeslaus/python-grass-addon","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wenzeslaus%2Fpython-grass-addon","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wenzeslaus%2Fpython-grass-addon/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wenzeslaus%2Fpython-grass-addon/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wenzeslaus%2Fpython-grass-addon/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wenzeslaus","download_url":"https://codeload.github.com/wenzeslaus/python-grass-addon/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":219860225,"owners_count":16556023,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["addon","gis","grass-gis","ipython-notebook","python","workshop"],"created_at":"2024-08-03T09:00:49.737Z","updated_at":"2025-10-28T02:31:08.865Z","avatar_url":"https://github.com/wenzeslaus.png","language":"Jupyter Notebook","readme":"# How to write a Python GRASS GIS 7 addon\n\nThis material was developed for FOSS4G Europe 2015 workshop.\n\n\u003ca href='http://grass.osgeo.org' target='_blank'\u003e\n \u003cimg src=\"grass_gis_logo.png\" alt=\"GRASS GIS logo\" /\u003e\n\u003c/a\u003e\n\u003ca href='http://europe.foss4g.org/2015/' target='_blank'\u003e\n \u003cimg src=\"foss4g_europe_2015_logo.png\" alt=\"FOSS4G-E 2015 logo\" /\u003e\n\u003c/a\u003e\n\n## How to use this tutorial\n\n### Using only GRASS GIS\n\nStart GRASS GIS on you computer. Browse through IPython Notebooks as rendered on GitHub.\nTo do this you just need to click on one of the files with the suffix `.ipynb`.\nIn GRASS GIS in *Layer Manager* window, select *Python shell* in the bottom\nto get an interactive Python console where you can input, edit and run the examples.\nYou may want to make the window bigger to have more space for the code.\n\n### With IPython and Git\n\nNavigate to the directory where you want to work and clone this\nrepository (unless you already downloaded a copy):\n\n    git clone https://github.com/wenzeslaus/python-grass-addon.git\n\nNavigate to the repository directory:\n\n    cd python-grass-addon\n\nStart GRASS GIS, from command line, using the North Carolina sample dataset:\n\n    grass7\n\nRun (supposing that you are already in a GRASS GIS session) on command line:\n\n    ipython notebook\n\nYou will get a website in a web browser where you can select individual Notebooks,\nedit and run the examples.\n\n\n## Abstract\n\nGRASS 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.\n\nIn 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.\n\nWith 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.\n\nYou 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.\n\nDon'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!\n\n\n## Required knowledge\n\nParticipants should have basic knowledge of GIS, basic knowledge of GRASS GIS and basic knowledge of Python.\n\n\n## Set up a server\n\nWhen organizing a workshop, it might be advantageous to use a server with IPython Notebook\nrather then setting up the environment on participant's computers. When IPython Notebook\nis used on a server, participants will need only a browser. All server-side work is easy\nto do thanks to Docker.\n\n    mkdir workdir\n    cd workdir\n\n    wget http://grass.osgeo.org/sampledata/north_carolina/nc_basic_spm_grass7.tar.gz\n    wget https://github.com/wenzeslaus/python-grass-addon/archive/master.tar.gz\n\n    tar xvf nc_basic_spm_grass7.tar.gz\n    tar xvf master.tar.gz\n\nNow you can get the basic GRASS GIS image. Note that if you user does not have permissions\nto 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.\n\n    docker build github.com/wenzeslaus/grass-gis-docker\n\nTo 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.\n\n    mv python-grass-addon-master/Dockerfile .\n    mv python-grass-addon-master/run_containers.sh .\n    mv python-grass-addon-master/command_containers.sh .\n\nBuild 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).\n\n    docker build -t wenzeslaus/python-grass-addon .\n\nCreate a file with users you want to create an container for. The file must contain\nemails at the beginning of each line (it can be for example CSV, double quote at the beginning\nis ignored).\n\n    john@university.edu\n    jsmith@example.com\n\nNow you can start:\n\n    ./run_containers.sh workshop_atendees.txt 9000\n\nAlternatively, you can just specify number of conatiners you want to create:\n\n    ./run_containers.sh 15 9000\n\nThis will give you list of URLs and passwords with associated usernames. Usernames are\nused only to keep track of containers and to distribute the credentials. Note that\nthe atendees will have to get through \"untrusted connection\" dialog in their browsers\nbecause the certificate used is self-signed.\n\nThe above command will also create a file named `containers_workshop_atendees.txt`\n(or `containers_dateandtime.txt`) with names of conatiners.\nFor further actions, if they are simple enough,\nyou can use a prepared script. For example, to get rid of the containers use:\n\n    ./command_conatiners.sh stop containers_workshop_atendees.txt\n    ./command_conatiners.sh rm containers_workshop_atendees.txt\n\n\n## Instructions for participants when IPython Notebook server is used\n\nYou have obtained URL which looks like:\n\n    https://fatra.cnr.ncsu.edu:9503\n\nType it precisely to the web browser including the *s* at the end of\n`https`, note also that port number is specified (the number at the end\nseparated from domain by a colon.\n\nYou browser will warn you about invalid security certificate. In this\ncase, you can safely add security exception. The reason for\nthe message is that the certificate is self-signed.\n\nFinally, enter the password you were provided with. Then you should\nsee a list of notebooks as displayed by IPython Notebook.\n\n\n## When and where the workshop was presented\n\n* North Carolina State Univeristy, test run (2 hours)\n* FOSS4G Europe 2015, Como, Italy (4 hours)\n* North Carolina State Univeristy, workshop for a geovisualization class (2 hours), [recording available](https://www.youtube.com/watch?v=PX2UpMhp2hc)\n\n\n## Authors\n\n* Pietro Zambelli, European Research Academy\n* Markus Neteler, Fondazione Edmund Mach\n* Luca Delucchi, Fondazione Edmund Mach\n* Vaclav Petras, NCSU OSGeoREL\n* Anna Petrasova, NCSU OSGeoREL\n\nCopyright (C) 2015 by authors.\n\n\n## License\n\nThe documentation is dual licensed under CC BY-SA and GNU FDL.\n\nThe code samples are under GNU GPL 2 or later\n(which is the license GRASS GIS is under).\n","funding_links":[],"categories":["Addon Tools"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwenzeslaus%2Fpython-grass-addon","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwenzeslaus%2Fpython-grass-addon","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwenzeslaus%2Fpython-grass-addon/lists"}