https://grasswiki.osgeo.org/w/api.php?action=feedcontributions&user=Veroandreo&feedformat=atomGRASS-Wiki - User contributions [en]2024-03-28T14:51:49ZUser contributionsMediaWiki 1.41.0https://grasswiki.osgeo.org/w/index.php?title=GRASS_GSoC_Ideas_2024&diff=27470GRASS GSoC Ideas 20242024-03-19T21:42:57Z<p>Veroandreo: /* Add EODAG support to GRASS GIS */ add link to test of skills</p>
<hr />
<div><br />
== About ==<br />
<br />
* [https://wiki.osgeo.org/wiki/Google_Summer_of_Code_2024_Ideas The OSGeo GSoC 2024 main page]<br />
* [https://summerofcode.withgoogle.com/ Official GSoC page at Google]<br />
<br />
== Ideas ==<br />
If you are a student you can suggest a new idea or pick up an existing one. In any case write about it to [https://lists.osgeo.org/listinfo/grass-dev grass-dev mailing list],[https://github.com/OSGeo/grass/discussions GitHub Discussions], or [https://gitter.im/grassgis/community Gitter].<br />
<br />
You are invited as well to have a close look at ideas from previous years ([https://trac.osgeo.org/grass/wiki/GSoC/2014 2014], [https://trac.osgeo.org/grass/wiki/GSoC/2015 2015], [https://trac.osgeo.org/grass/wiki/GSoC/2016 2016],<br />
[https://trac.osgeo.org/grass/wiki/GSoC/2017 2017],<br />
[https://trac.osgeo.org/grass/wiki/GSoC/2018 2018],<br />
[https://trac.osgeo.org/grass/wiki/GSoC/2019 2019],<br />
[https://trac.osgeo.org/grass/wiki/GSoC/2020 2020],<br />
[https://trac.osgeo.org/grass/wiki/GSoC/2021 2021],<br />
[https://trac.osgeo.org/grass/wiki/GSoC/2022 2022],<br />
[https://trac.osgeo.org/grass/wiki/GSoC/2023 2023])<br />
which have not yet been implemented.<br />
You can also look at accepted GRASS GSoC [https://trac.osgeo.org/grass/wiki/GSoC projects from previous years] for an idea of scope.''<br />
<br />
Include "GRASS GIS" in the title of our idea to easily distinguish ideas and projects inside OSGeo.<br />
<br />
<br />
=== Parallelization of existing tools ===<br />
<br />
There are several tools that would benefit from parallelization with OpenMP, e.g. r.texture, r.horizon, r.fill.stats, r/v.surf.idw, r.viewshed, v.to.rast, r.grow.distance,...<br />
For overview of current state, see [[Raster_Parallelization_with_OpenMP]].<br />
<br />
* Requirements: familiarity with C, OpenMP<br />
* Mentor: Huidae Cho<br />
* Co-mentor: Vaclav Petras, Anna Petrasova<br />
* Project length: 175 or 350 hours (take your pick)<br />
* Rating: medium<br />
* Expected Outcomes: parallelized module or modules, depending on complexity<br />
* Test of skills: suggest/implement solution for https://github.com/OSGeo/grass/issues/2644<br />
<br />
=== Improve GRASS user experience in Jupyter Notebook ===<br />
[[File:Jupyter_interactive_viewshed.png|500px|thumb|right|InteractiveMap in grass.jupyter library]]<br />
Python package [https://grass.osgeo.org/grass-stable/manuals/libpython/grass.jupyter.html grass.jupyter] was developed during [https://trac.osgeo.org/grass/wiki/GSoC/2021/JupyterAndGRASS GSoC 2021] to simplify running GRASS from Jupyter Notebooks and displaying data. This project could focus on adding features such as adding parallelization for rendering, increasing interactivity of displayed data using ipyleaflet (e.g., capture mouse clicks to show information about vector line, pixel), adding API for managing projects and subprojects (i.e., locations/mapsets), simplifing display of attribute data, ...<br />
<br />
* Requirements: Python<br />
* Mentor: Anna Petrasova<br />
* Co-mentor: Vaclav Petras, Helena Mitasova<br />
* Project length: 175 or 350 hours (take your pick)<br />
* Rating: easy to medium<br />
* Expected Outcomes: improved user experience when using GRASS through notebooks<br />
* Test of skills: https://github.com/OSGeo/grass/issues/3276, or write a test for [https://github.com/OSGeo/grass/tree/main/python/grass/jupyter grass.jupyter library] using python unittest or pytest, more info [https://grass.osgeo.org/grass-devel/manuals/libpython/gunittest_testing.html here].<br />
<br />
=== Add JSON output to different tools in C ===<br />
There are several tools in GRASS that would benefit from a JSON-formatted output, see [https://github.com/OSGeo/grass/issues/3020 this issue for a list of tools]. Besides adding the JSON output, the work would also include adding tests and basic documentation.<br />
* Requirements: C, Python for tests<br />
* Mentor: Vaclav Petras<br />
* Co-mentor: Anna Petrasova, Corey White<br />
* Project length: 175 or 350 hours (take your pick)<br />
* Rating: easy to medium<br />
* Expected Outcomes: one or more (depending on project length and complexity of the tool) tools with well tested JSON output<br />
* Test of skills: Address https://github.com/OSGeo/grass/issues/1044 for r.surf.fractal<br />
<br />
=== Support writing tests with pytest ===<br />
<br />
* The current testing framework, ''[https://grass.osgeo.org/grass-stable/manuals/libpython/gunittest.html grass.gunittest]'', was written before migration to Git/GitHub and when long free runs in 3rd party services were unthinkable. Additionally, some no longer relevant goals were prioritized, such as independence on the current code, detailed custom HTML reports, success tracking over time, and high specialization towards GRASS-specifics.<br />
* ''grass.gunittest'' is based on Python ''unittest'' package and many projects since then migrated to //pytest//, e.g., GDAL and Numpy. While ''unittest'' is inspired by Java's JUnit, ''pytest'' is designed to support writing small, readable tests, and uses plain `assert` statements instead of many different assert methods.<br />
* Using ''pytest'' should lead to tests which feel more like Python scripts and to minimum of testing-specific code.<br />
* An example issue of ''grass.gunittest'' is that it doesn't work well with tests of the main GRASS executable (prominence of `grass ... --exec` is yet another new thing which changed since ''grass.gunittest'' was designed).<br />
* Two main things needed:<br />
** Create general comparison functions from the ''grass.gunittest'' assert methods so that they can be used with pytest.<br />
** Current grass.script.setup.init function and grass.script.core.create_location function don't work well in the context of a pytest test function. More <br />
* Additional things needed:<br />
** Fixture for pytest to set up and tear down a GRASS session in a temporary mapset.<br />
<br />
* Requirements: Python<br />
* Project length: 175 or 350 hours (take your pick)<br />
* Mentor: Vaclav Petras<br />
* Co-mentor: Stefan Blumentrath<br />
* Proposed by: Vaclav Petras<br />
* Rating: easy to medium<br />
* Expected Outcomes: Convenient way of writing tests with pytest<br />
* Test of skills: Fix failing tests and/or write new tests (more is better). Alternatively, addressing a smaller problem in the testing framework is a good task, too.<br />
<br />
=== New easy-to-use CLI and API for GRASS GIS ===<br />
<br />
* Make running of GRASS GIS modules as easy as it is to run GDAL commands.<br />
** `grass run r.slope.aspect elevation=elevation.tiff slope=slope.tiff aspect=aspect.tiff`<br />
** CLI like GDAL has.<br />
** No GRASS Database, Location, Mapset to deal with.<br />
** No import, export from user perspective.<br />
** Reasonable defaults for things like region.<br />
** CLI and API still allows user to specify any of the above.<br />
* Idea page with details: wiki:GSoC/2021/EasyToUseCliAndApiIdea<br />
* Project length: 350 hours<br />
* Rating: medium<br />
* Requirements:<br />
** Language: Python<br />
** Proposal: Student needs to show sufficient understanding of the GRASS GIS Database structure and significantly extend on text below in terms of more concrete formulation of ideas and identification of missing and existing parts.<br />
* Mentors: Vaclav Petras<br />
* Co-mentors: Stefan Blumentrath<br />
* Proposed by: Vaclav Petras<br />
* Expected outcomes: New subcommand which easily runs a GRASS module on GeoTiff and GeoPackage.<br />
* Test and training tasks:<br />
** Solve one of the tickets linked at the idea page.<br />
** Add features to `grass` executable interface:<br />
*** Make it possible to associate `*.gxw` files with `grass` executable (#1204) or at least add `--gui-workspace` or preferably just recognize it in the command line (distinguish it from database/location/mapset).<br />
** Extend `--exec` functionality:<br />
*** Add `--region` to set a temporary computational region for the execution, e.g. `--region="raster=raster_name"`<br />
*** Add `--import-raster=some/file.tiff` which imports (r.import) a raster file (same for vector and similarly for export).<br />
*** Add `--link-raster=some/file.tiff` which links (r.external) a raster file (same for vector and similarly for r.external.out).<br />
<br />
=== STAC (SpatioTemporal Asset Catalog) Integration ===<br />
<br />
Create new import and export capabilities for GRASS GIS which allow users to easily ingest data from STAC catalogs and export locations and mapsets as STAC specs for data discovery within STAC browsers. <br />
<br />
* Requirements: familiar with python, STAC specs<br />
* Mentor: Corey White<br />
* Co-mentor: Vaclav Petras, Anna Petrasova<br />
* Project length: 175 or 350 hours (take your pick)<br />
* Rating: medium<br />
* Expected Outcomes: completion of t.in.stac and t.out.stac<br />
* Test of skills:<br />
** suggest or implement solution for implementing t.out.stac using the prototype STAC spec https://github.com/tomorrownow/grass-stac-extension <br />
** suggest/implement solution for completing https://github.com/OSGeo/grass-addons/pull/802<br />
<br />
=== Add EODAG support to GRASS GIS ===<br />
<br />
[https://eodag.readthedocs.io/en/stable/ EODAG] is a Python library useful to download several satellite datasets from different providers (i.e., USGS, Copernicus, AWS, Planetary Computer, etc.). GRASS has various modules to download satellite data like i.sentinel.download, i.landsat.download, i.modis.download. However, they all use different libraries, some of them no longer maintained. Hence, implementing the use of EODAG as back-end for those tools would be very useful not only in terms of maintenance but also in terms of less code repetition. It would also open the possibility for new tools or a master tool to download other datasets directly from GRASS. <br />
<br />
* Requirements: familiar with Python<br />
* Project length: 175 or 350 hours<br />
* Mentor: Luca Delucchi<br />
* Co-mentor: Veronica Andreo<br />
* Proposed by: Luca Delucchi<br />
* Rating: medium<br />
* Expected Outcomes: 175 hours EODAG core library to be able to download products; 350 library + application at least to i.sentinel.download but hopefully also to i.landsat.download<br />
* Test of skills: https://github.com/OSGeo/grass-addons/issues/1033<br />
<br />
=== GUI: Add space-time datasets support in Data Catalog ===<br />
[[File:GUI_data_tab.png|400px|thumb|right|Data catalog]]<br />
Currently GRASS Data Catalog shows only raster and vector maps. The goal of this project is to add support for space-time datasets. It is mainly space-time raster datasets. In the next phase of the project support for other types of space-time datasets (vector and 3D raster) could be added. Besides displaying space-time datasets in the layer tree, it is also about adding the equivalent functionality currently available for raster and vector layers from the context menu. <br />
<br />
* Requirements: familiar with Python<br />
* Project length: 175 or 350 hours<br />
* Mentor: Martin Landa<br />
* Co-mentor: Anna Petrasova<br />
* Proposed by: Martin Landa<br />
* Rating: medium<br />
* Expected Outcomes: 175 hours basic support for space-time raster datasets; 350 extended support also for other space-time datasets types (vector, 3D raster)<br />
* Test of skills:<br />
** suggest/implement solution for completing https://github.com/OSGeo/grass/issues/2599<br />
<br />
=== Add {your research idea} to GRASS GIS ===<br />
<br />
* In general, you can propose any topic, but you can specifically propose integrating your research or research idea into GRASS GIS.<br />
* Requirements:<br />
** Language:<br />
*** Depends on the project, often Python, sometimes C.<br />
*** Adding your latest ecological analysis <br />
** Proposal:<br />
*** Discuss relevance to GRASS GIS.<br />
*** Describe technical steps needed for integration.<br />
*** Describe whether it is an addition of a tool (module) or a change in one of the libraries. If it is a tool, specify if it should be included in the core grass repository or in grass-addons repository and why.<br />
*** Specify what research was done and what needs to be accomplished in order to have usable product at the end of summer.<br />
*** Specify who will provide the research expertise.<br />
* Project length: 175 or 350 hours (take your pick)<br />
* Rating: from low to hard<br />
* Mentors:<br />
** GRASS GIS project will provide technical mentors, but it is up to the applicant to ensure the research part is mentored well. An exception may be granted to applicants which can demonstrate that the research is finished or that they have enough expertise themselves.<br />
** Possible technical mentors: Vaclav Petras, Anna Petrasova<br />
** Research mentors: Bring in an expert from your field, e.g., your academic advisor or project principal investigator (if needed).<br />
* Proposed by: Vaclav Petras<br />
* Expected outcome: Working feature which is integrated and merged at the end of the project.<br />
* Test and training tasks:<br />
** Create a test in Python for an existing tool in the grass-addons repository or in the core grass repository.<br />
<br />
=== Title of idea ===<br />
<br />
Description here<br />
<br />
* Requirements:<br />
* Project length: (175 or 350 hours) <br />
* Mentor: <br />
* Proposed by: <br />
* Rating: <br />
* Expected Outcomes: <br />
* Test of skills: <br />
* Other:<br />
<br />
== Tips for students ==<br />
<br />
* If you have your own ideas we encourage you to propose them. Explain them on the [https://lists.osgeo.org/listinfo/grass-dev grass-dev mailing list].<br />
* If you like some idea here or from previous yeas, write about it on [https://lists.osgeo.org/listinfo/grass-dev grass-dev mailing list] and any ideas of your own which could improve it.<br />
* Follow some good practices in your ideas and proposals:<br />
** Stress why the project would be useful.<br />
** Show that you know how you will proceed. That is, make sure that you can demonstrate that the proposal is feasible in the given time frame.<br />
** Be specific in the implementation (or at least as specific as you can).<br />
** Explain what the final product will look like and how it will work. You can add drawings or mock-ups.<br />
** Explain how the idea relates to existing GRASS GIS functions, features, and needs.<br />
** Do not include steps such as "install GRASS", "compile GRASS libraries (on my machine)", "read about the API". You should do this before applying to GSoC.<br />
* Compile GRASS GIS from source and prepare environment for development:<br />
** Read [https://github.com/OSGeo/grass/blob/main/CONTRIBUTING.md CONTRIBUTING file] and [https://grasswiki.osgeo.org/wiki/Compile_and_Install compilation instructions].<br />
** If you get stuck with the setup, feel free to consult the [https://lists.osgeo.org/listinfo/grass-user grass-user mailing list].<br />
** Familiarize yourself with wiki:Submitting rules.<br />
* Prove your worth by being active on the GRASS mailing lists ([https://lists.osgeo.org/listinfo/grass-user grass-user], [https://lists.osgeo.org/listinfo/grass-dev grass-dev]) or other channels ([https://github.com/OSGeo/grass/discussions GitHub Discussions], [https://gitter.im/grassgis/community Gitter]), fix some [https://github.com/OSGeo/grass/issues bugs], and/or implement some (smaller) features, or write some (simpler) GRASS module, and post it to mailing list. There's no better way to demonstrate your willingness and abilities. Do this before start you apply to GSoC. <br />
* Also note that fixing existing bugs and/or implementing enhancements will be a part of student evaluation.<br />
<br />
* Every year GRASS GIS hopes to participate and participates in GSoC as part of the [https://www.osgeo.org/ OSGeo Foundation]'s GSoC program umbrella. See the official OSGeo template for application details and other important information at the [https://wiki.osgeo.org/wiki/Google_Summer_of_Code_Recommendations_for_Students OSGeo Recommendations for Students].<br />
<br />
{{GSoC}}</div>Veroandreohttps://grasswiki.osgeo.org/w/index.php?title=GRASS_Community_Meeting_Prague_2024&diff=27458GRASS Community Meeting Prague 20242024-03-18T15:32:01Z<p>Veroandreo: /* Individual Preparation */</p>
<hr />
<div>{{toc|right}}<br />
The ''GRASS GIS Community Meeting'' for contributors and developers will be happening from '''June 14 to June 19, 2024''' in Prague, Czechia.<br />
<br />
[[File:Prague-Community-Meeting-2023-crop.jpg|500px|frameless|center]]<br />
<br />
== Sponsor us! ==<br />
<br />
We welcome financial contributions to support the meeting and we are looking for sponsors to cover costs such as meals or to help reducing travel and accommodation expenses for GRASS developers who volunteer their time. If you are interested in sponsoring the GRASS Community Meeting, please go to:<br />
<br />
::: '''[https://opencollective.com/osgeo/projects/grass/contribute OpenCollective]'''<br />
<br />
Any surplus at the end of the event will be used for future activities of the GRASS GIS project such as the [[Student Grants|Student Grant program]].<br />
<br />
This GRASS Community Meeting is a great occasion for you to support the development of GRASS. With your contribution you'll enable more developers to meet. Community meetings are important opportunities for developers to discuss, fix bugs, plan the direction for the project and work on new features. The developers and other contributors or their employers are donating their valuable time, so it would be great if funding can be made available from within the community to cover out-of-pocket expenses. All of the work that takes place at the community meeting will be directly contributed back into the GRASS project to the benefit of everyone who uses it. Note that while we have our general plan, we can't accept any earmarked donations, i.e., we can't make any promises for a specific work to be done, please contact specific developers or support commercial providers for that.<br />
<br />
We are grateful to the following sponsors for their support and commitment! <br />
<br />
* U.S. National Science Foundation, award 2303651. (Travel for 5 participants and their time, event venue.)<br />
<br />
[[File:NSF Official logo.png|none|left|200px|alt=Logo of US NSF|U.S. National Science Foundation]]<br />
<br />
* In-kind contributions will be acknowledged here.<br />
* Personal time and/or financial contributions will be acknowledged here.<br />
<br />
== Purpose ==<br />
<br />
The ''GRASS GIS Community Meeting'' is a great occasion for folks to support the development by actively contributing to the project in different ways. These include source code updates, documentation (manuals, wiki, tutorials), translations, website improvements or likewise. The community meeting is also a get-together where supporters, contributors, power users and developers make decisions and tackle larger problems related to the project, discuss and collaboratively resolve bugs, plan the direction for the project and work on new features. We welcome people committed to improving the GRASS GIS project and the interfaces to QGIS, GDAL, PostGIS, R, OGC Services and others.<br />
<br />
In this meeting, building on momentum from the 40th birthday meeting, we will continue the revisions of the maintenance processes and infrastructure - a process which highly benefits from the current maintainers being in one place (and time zone). Topics which require highly synchronous collaboration will be included such as Markdown documentation and CMake build transitions. Other contributors are expected to enhance existing tools and their documentation. A [https://grass.osgeo.org/news/2023_08_13_grass_community_meeting_prague_june_2023_report/ press release] gives an overview of last year's event.<br />
<br />
We do require participants to work on GRASS GIS or connections to other projects. However, we leave them the freedom to work on what they think is the best contribution to the project given their skills and time available.<br />
<br />
For the detailed agenda and individual's plans, see below.<br />
<br />
== Program ==<br />
<br />
=== Thursday, June 13 ===<br />
<br />
Day of arrival. Contact organizers if you are interested in individualized program or helping with organization.<br />
<br />
=== Friday, June 14 ===<br />
<br />
=== Saturday, June 15 ===<br />
<br />
=== Sunday, June 16 ===<br />
<br />
=== Monday, June 17 ===<br />
<br />
=== Tuesday, June 18 ===<br />
<br />
=== Wednesday, June 19 ===<br />
<br />
=== Thursday, June 20 ===<br />
<br />
Day of departure.<br />
<br />
== Participation ==<br />
<br />
We are planning for an attendance of 15 people at the same time but you are welcome to sign up regardless of capacity: We will find a space for you. Please add your name here or contact [[User:wenzeslaus|Vaclav Petras]] <tt><wenzeslaus at gmail com></tt>:<br />
<br />
=== In person ===<br />
<br />
{|class="wikitable sortable" border="2" cellspacing="0" cellpadding="4" rules="all" style="margin:1em 1em 1em 0; border:solid 1px #AAAAAA; border-collapse:collapse; background-color:#edf9c7; font-size:95%; empty-cells:show;" <br />
!width=50px|'''Number'''<br />
!width=130px|'''Participant '''<br />
!width=100px|'''Country'''<br />
!width=100px|'''Arrival'''<br />
!width=100px|'''Departure'''<br />
!'''Topics'''<br />
!'''Notes'''<br />
|-<br />
|1<br />
| [[User:wenzeslaus|Vaclav Petras]]<br />
| United States <br />
| June 13<br />
| June 20<br />
| review PR, reduce PR queue, Python API topics (also for QGIS and R), funding<br />
|<br />
|-<br />
|2<br />
| [[User:Annakrat|Anna Petrasova]]<br />
| United States <br />
| June 13<br />
| June 20<br />
| grass.jupyter, R and QGIS integration<br />
|<br />
|-<br />
|3<br />
| [[User:Ctwhite|Corey White]]<br />
| United States <br />
| June 13<br />
| June 20<br />
| STAC, JSON outputs, connections with other tools (OpenPlains) <br />
|-<br />
|4<br />
| [[User:Chaedri|Caitlin Haedrich]]<br />
| United States<br />
| June 13<br />
| June 20<br />
| grass.jupyter<br />
|<br />
|-<br />
|5<br />
| [[User:Veroandreo | Vero Andreo]]<br />
| United States<br />
| June 13<br />
| June 20<br />
| STAC, tutorials, website, documentation, contributing guidelines<br />
|<br />
|-<br />
|}<br />
<br />
If you are arriving or departing on the days of the event, please specify the time, too.<br />
<br />
=== Online ===<br />
<br />
Join our [https://app.gitter.im/#/room/#grassgis_community:gitter.im Gitter chatroom]<br />
<br />
Gitter has a video (and backup will be Zoom).<br />
<br />
Participating virtually:<br />
<br />
{|class="wikitable sortable" border="2" cellspacing="0" cellpadding="4" rules="all" style="margin:1em 1em 1em 0; border:solid 1px #AAAAAA; border-collapse:collapse; background-color:#edf9c7; font-size:95%; empty-cells:show;" <br />
!width=50px|'''Number'''<br />
!width=130px|'''Participant '''<br />
!width=100px|'''Country'''<br />
!'''Topics'''<br />
!'''Times, synchronous or fully asynchronous'''<br />
!'''Notes'''<br />
|-<br />
|1<br />
| Be The First<br />
| Your Country<br />
| Your Topic<br />
| When you will be available (timezone, days, times)<br />
|<br />
|-<br />
|}<br />
<br />
== Venue ==<br />
<br />
[[File:Ncsu logo.jpg|240px|frameless|left]]<br />
[https://prague.ncsu.edu/about/ NC State European Center in Prague]<br><br />
Malé náměstí 144/1<br><br />
Praha 1 – 110 00<br><br />
Prague, Czech Republic<br><br />
<br />
[https://en.mapy.cz/s/fohulovaha Map]<br><br />
<br />
Prague, the capital of Czechia (Czech Republic) has an international [http://www.prg.aero/en/ airport]. It's location in the middle of central Europe makes it easily reachable by train, bus or car. The city itself has great public transportation.<br />
<br />
== Accommodation and Costs ==<br />
<br />
''Participation is free of charge''. However, participants should plan for the following costs:<br />
<br />
* Travel<br />
* Lodging<br />
* Food and drink (some may be covered)<br />
<br />
<br />
'''Please note''': The currency in Czech Republic is {{wikipedia|Czech crown}} (CZK, koruna, Kč). 100 Czech crowns are about 4 Euros (see [https://www.cnb.cz/cs/financni-trhy/devizovy-trh/kurzy-devizoveho-trhu/kurzy-devizoveho-trhu/ current rates]).<br />
<br />
== Individual Preparation ==<br />
<br />
* Bring your own computer<br />
* Bring {{wikipedia|AC adapter|power connector adapter}} if needed (Czech Republic: 230V, 50Hz, {{wikipedia|File:Euro-Flachstecker_2.jpg|Type C Europlugs}} are common and also {{wikipedia|File:French_plug_and_socket.jpg|Type E}})<br />
* Install git and the compiler tools, and come with a working GRASS development environment if possible. See [https://github.com/OSGeo/grass/blob/main/CONTRIBUTING.md here] for details.<br />
<br />
== FAQ ==<br />
<br />
* '''How was it last time?'''<br />
** Splendid! See [[GRASS Community Meeting Prague 2023]]!<br />
* ''Is the meeting just a coding event?''<br />
** It is mainly a coding and documentation event. It is a working session for people who are already participants in the GRASS project and/or are committed to improving the GRASS project. Committed newcomers are welcome! <br />
** On demand we can do some presentations of current working GRASS implementation and new upcoming features to spread the idea of Open Source GIS software.<br />
* ''Is the GRASS Community Meeting for developers only?''<br />
** No: anybody can help, with testing, checking out bugs and fixes, documentation and more.<br />
* ''Where can I get help and more information about the community meeting?''<br />
** Contact [[User:Landa|Martin Landa]] <tt><landa.martin at gmail.com></tt></div>Veroandreohttps://grasswiki.osgeo.org/w/index.php?title=GRASS_Community_Meeting_Prague_2024&diff=27456GRASS Community Meeting Prague 20242024-03-18T15:27:54Z<p>Veroandreo: /* Accommodation and Costs */</p>
<hr />
<div>{{toc|right}}<br />
The ''GRASS GIS Community Meeting'' for contributors and developers will be happening from '''June 14 to June 19, 2024''' in Prague, Czechia.<br />
<br />
[[File:Prague-Community-Meeting-2023-crop.jpg|500px|frameless|center]]<br />
<br />
== Sponsor us! ==<br />
<br />
We welcome financial contributions to support the meeting and we are looking for sponsors to cover costs such as meals or to help reducing travel and accommodation expenses for GRASS developers who volunteer their time. If you are interested in sponsoring the GRASS Community Meeting, please go to:<br />
<br />
::: '''[https://opencollective.com/osgeo/projects/grass/contribute OpenCollective]'''<br />
<br />
Any surplus at the end of the event will be used for future activities of the GRASS GIS project such as the [[Student Grants|Student Grant program]].<br />
<br />
This GRASS Community Meeting is a great occasion for you to support the development of GRASS. With your contribution you'll enable more developers to meet. Community meetings are important opportunities for developers to discuss, fix bugs, plan the direction for the project and work on new features. The developers and other contributors or their employers are donating their valuable time, so it would be great if funding can be made available from within the community to cover out-of-pocket expenses. All of the work that takes place at the community meeting will be directly contributed back into the GRASS project to the benefit of everyone who uses it. Note that while we have our general plan, we can't accept any earmarked donations, i.e., we can't make any promises for a specific work to be done, please contact specific developers or support commercial providers for that.<br />
<br />
We are grateful to the following sponsors for their support and commitment! <br />
<br />
* U.S. National Science Foundation, award 2303651. (Travel for 5 participants and their time, event venue.)<br />
<br />
[[File:NSF Official logo.png|none|left|200px|alt=Logo of US NSF|U.S. National Science Foundation]]<br />
<br />
* In-kind contributions will be acknowledged here.<br />
* Personal time and/or financial contributions will be acknowledged here.<br />
<br />
== Purpose ==<br />
<br />
The ''GRASS GIS Community Meeting'' is a great occasion for folks to support the development by actively contributing to the project in different ways. These include source code updates, documentation (manuals, wiki, tutorials), translations, website improvements or likewise. The community meeting is also a get-together where supporters, contributors, power users and developers make decisions and tackle larger problems related to the project, discuss and collaboratively resolve bugs, plan the direction for the project and work on new features. We welcome people committed to improving the GRASS GIS project and the interfaces to QGIS, GDAL, PostGIS, R, OGC Services and others.<br />
<br />
In this meeting, building on momentum from the 40th birthday meeting, we will continue the revisions of the maintenance processes and infrastructure - a process which highly benefits from the current maintainers being in one place (and time zone). Topics which require highly synchronous collaboration will be included such as Markdown documentation and CMake build transitions. Other contributors are expected to enhance existing tools and their documentation. A [https://grass.osgeo.org/news/2023_08_13_grass_community_meeting_prague_june_2023_report/ press release] gives an overview of last year's event.<br />
<br />
We do require participants to work on GRASS GIS or connections to other projects. However, we leave them the freedom to work on what they think is the best contribution to the project given their skills and time available.<br />
<br />
For the detailed agenda and individual's plans, see below.<br />
<br />
== Program ==<br />
<br />
=== Thursday, June 13 ===<br />
<br />
Day of arrival. Contact organizers if you are interested in individualized program or helping with organization.<br />
<br />
=== Friday, June 14 ===<br />
<br />
=== Saturday, June 15 ===<br />
<br />
=== Sunday, June 16 ===<br />
<br />
=== Monday, June 17 ===<br />
<br />
=== Tuesday, June 18 ===<br />
<br />
=== Wednesday, June 19 ===<br />
<br />
=== Thursday, June 20 ===<br />
<br />
Day of departure.<br />
<br />
== Participation ==<br />
<br />
We are planning for an attendance of 20 people (i.e., coding places) but of course you are welcome to join us and bring new ideas with you: we'll make more places available. Please add your name here or contact [[User:Landa|Martin Landa]] <tt><landa.martin at gmail.com></tt>:<br />
<br />
=== In person ===<br />
<br />
{|class="wikitable sortable" border="2" cellspacing="0" cellpadding="4" rules="all" style="margin:1em 1em 1em 0; border:solid 1px #AAAAAA; border-collapse:collapse; background-color:#edf9c7; font-size:95%; empty-cells:show;" <br />
!width=50px|'''Number'''<br />
!width=130px|'''Participant '''<br />
!width=100px|'''Country'''<br />
!width=100px|'''Arrival'''<br />
!width=100px|'''Departure'''<br />
!'''Topics'''<br />
!'''Notes'''<br />
|-<br />
|1<br />
| [[User:wenzeslaus|Vaclav Petras]]<br />
| United States <br />
| June 13<br />
| June 20<br />
| review PR, reduce PR queue, Python API topics (also for QGIS and R), funding<br />
|<br />
|-<br />
|2<br />
| [[User:Annakrat|Anna Petrasova]]<br />
| United States <br />
| June 13<br />
| June 20<br />
| grass.jupyter, R and QGIS integration<br />
|<br />
|-<br />
|3<br />
| [[User:Ctwhite|Corey White]]<br />
| United States <br />
| June 13<br />
| June 20<br />
| STAC, JSON outputs, connections with other tools (OpenPlains) <br />
|-<br />
|4<br />
| [[User:Chaedri|Caitlin Haedrich]]<br />
| United States<br />
| June 13<br />
| June 20<br />
| grass.jupyter<br />
|<br />
|-<br />
|5<br />
| [[User:Veroandreo | Vero Andreo]]<br />
| United States<br />
| June 13<br />
| June 20<br />
| STAC, tutorials, website, documentation, contributing guidelines<br />
|<br />
|-<br />
|}<br />
<br />
If you are arriving or departing on the days of the event, please specify the time, too.<br />
<br />
=== Online ===<br />
<br />
Join our [https://app.gitter.im/#/room/#grassgis_community:gitter.im Gitter chatroom]<br />
<br />
Gitter has a video (and backup will be Zoom).<br />
<br />
Participating virtually:<br />
<br />
{|class="wikitable sortable" border="2" cellspacing="0" cellpadding="4" rules="all" style="margin:1em 1em 1em 0; border:solid 1px #AAAAAA; border-collapse:collapse; background-color:#edf9c7; font-size:95%; empty-cells:show;" <br />
!width=50px|'''Number'''<br />
!width=130px|'''Participant '''<br />
!width=100px|'''Country'''<br />
!'''Topics'''<br />
!'''Times, synchronous or fully asynchronous'''<br />
!'''Notes'''<br />
|-<br />
|1<br />
| Be The First<br />
| Your Country<br />
| Your Topic<br />
| When you will be available (timezone, days, times)<br />
|<br />
|-<br />
|}<br />
<br />
== Venue ==<br />
<br />
[[File:Ncsu logo.jpg|240px|frameless|left]]<br />
[https://prague.ncsu.edu/about/ NC State European Center in Prague]<br><br />
Malé náměstí 144/1<br><br />
Praha 1 – 110 00<br><br />
Prague, Czech Republic<br><br />
<br />
[https://en.mapy.cz/s/fohulovaha Map]<br><br />
<br />
Prague, the capital of Czechia (Czech Republic) has an international [http://www.prg.aero/en/ airport]. It's location in the middle of central Europe makes it easily reachable by train, bus or car. The city itself has great public transportation.<br />
<br />
== Accommodation and Costs ==<br />
<br />
''Participation is free of charge''. However, participants should plan for the following costs:<br />
<br />
* Travel<br />
* Lodging<br />
* Food and drink (some may be covered)<br />
<br />
<br />
'''Please note''': The currency in Czech Republic is {{wikipedia|Czech crown}} (CZK, koruna, Kč). 100 Czech crowns are about 4 Euros (see [https://www.cnb.cz/cs/financni-trhy/devizovy-trh/kurzy-devizoveho-trhu/kurzy-devizoveho-trhu/ current rates]).<br />
<br />
== Individual Preparation ==<br />
<br />
* Bring your own computer<br />
* Bring {{wikipedia|AC adapter|power connector adapter}} if needed (Czech Republic: 230V, 50Hz, {{wikipedia|File:Euro-Flachstecker_2.jpg|Type C Europlugs}} are common and also {{wikipedia|File:French_plug_and_socket.jpg|Type E}})<br />
* Install git and the compiler tools, and come with a working GRASS development environment if possible.<br />
<br />
== FAQ ==<br />
<br />
* '''How was it last time?'''<br />
** Splendid! See [[GRASS Community Meeting Prague 2023]]!<br />
* ''Is the meeting just a coding event?''<br />
** It is mainly a coding and documentation event. It is a working session for people who are already participants in the GRASS project and/or are committed to improving the GRASS project. Committed newcomers are welcome! <br />
** On demand we can do some presentations of current working GRASS implementation and new upcoming features to spread the idea of Open Source GIS software.<br />
* ''Is the GRASS Community Meeting for developers only?''<br />
** No: anybody can help, with testing, checking out bugs and fixes, documentation and more.<br />
* ''Where can I get help and more information about the community meeting?''<br />
** Contact [[User:Landa|Martin Landa]] <tt><landa.martin at gmail.com></tt></div>Veroandreohttps://grasswiki.osgeo.org/w/index.php?title=GRASS_Community_Meeting_Prague_2024&diff=27455GRASS Community Meeting Prague 20242024-03-18T15:26:01Z<p>Veroandreo: /* Venue */ add NC state logo</p>
<hr />
<div>{{toc|right}}<br />
The ''GRASS GIS Community Meeting'' for contributors and developers will be happening from '''June 14 to June 19, 2024''' in Prague, Czechia.<br />
<br />
[[File:Prague-Community-Meeting-2023-crop.jpg|500px|frameless|center]]<br />
<br />
== Sponsor us! ==<br />
<br />
We welcome financial contributions to support the meeting and we are looking for sponsors to cover costs such as meals or to help reducing travel and accommodation expenses for GRASS developers who volunteer their time. If you are interested in sponsoring the GRASS Community Meeting, please go to:<br />
<br />
::: '''[https://opencollective.com/osgeo/projects/grass/contribute OpenCollective]'''<br />
<br />
Any surplus at the end of the event will be used for future activities of the GRASS GIS project such as the [[Student Grants|Student Grant program]].<br />
<br />
This GRASS Community Meeting is a great occasion for you to support the development of GRASS. With your contribution you'll enable more developers to meet. Community meetings are important opportunities for developers to discuss, fix bugs, plan the direction for the project and work on new features. The developers and other contributors or their employers are donating their valuable time, so it would be great if funding can be made available from within the community to cover out-of-pocket expenses. All of the work that takes place at the community meeting will be directly contributed back into the GRASS project to the benefit of everyone who uses it. Note that while we have our general plan, we can't accept any earmarked donations, i.e., we can't make any promises for a specific work to be done, please contact specific developers or support commercial providers for that.<br />
<br />
We are grateful to the following sponsors for their support and commitment! <br />
<br />
* U.S. National Science Foundation, award 2303651. (Travel for 5 participants and their time, event venue.)<br />
<br />
[[File:NSF Official logo.png|none|left|200px|alt=Logo of US NSF|U.S. National Science Foundation]]<br />
<br />
* In-kind contributions will be acknowledged here.<br />
* Personal time and/or financial contributions will be acknowledged here.<br />
<br />
== Purpose ==<br />
<br />
The ''GRASS GIS Community Meeting'' is a great occasion for folks to support the development by actively contributing to the project in different ways. These include source code updates, documentation (manuals, wiki, tutorials), translations, website improvements or likewise. The community meeting is also a get-together where supporters, contributors, power users and developers make decisions and tackle larger problems related to the project, discuss and collaboratively resolve bugs, plan the direction for the project and work on new features. We welcome people committed to improving the GRASS GIS project and the interfaces to QGIS, GDAL, PostGIS, R, OGC Services and others.<br />
<br />
In this meeting, building on momentum from the 40th birthday meeting, we will continue the revisions of the maintenance processes and infrastructure - a process which highly benefits from the current maintainers being in one place (and time zone). Topics which require highly synchronous collaboration will be included such as Markdown documentation and CMake build transitions. Other contributors are expected to enhance existing tools and their documentation. A [https://grass.osgeo.org/news/2023_08_13_grass_community_meeting_prague_june_2023_report/ press release] gives an overview of last year's event.<br />
<br />
We do require participants to work on GRASS GIS or connections to other projects. However, we leave them the freedom to work on what they think is the best contribution to the project given their skills and time available.<br />
<br />
For the detailed agenda and individual's plans, see below.<br />
<br />
== Program ==<br />
<br />
=== Thursday, June 13 ===<br />
<br />
Day of arrival. Contact organizers if you are interested in individualized program or helping with organization.<br />
<br />
=== Friday, June 14 ===<br />
<br />
=== Saturday, June 15 ===<br />
<br />
=== Sunday, June 16 ===<br />
<br />
=== Monday, June 17 ===<br />
<br />
=== Tuesday, June 18 ===<br />
<br />
=== Wednesday, June 19 ===<br />
<br />
=== Thursday, June 20 ===<br />
<br />
Day of departure.<br />
<br />
== Participation ==<br />
<br />
We are planning for an attendance of 20 people (i.e., coding places) but of course you are welcome to join us and bring new ideas with you: we'll make more places available. Please add your name here or contact [[User:Landa|Martin Landa]] <tt><landa.martin at gmail.com></tt>:<br />
<br />
=== In person ===<br />
<br />
{|class="wikitable sortable" border="2" cellspacing="0" cellpadding="4" rules="all" style="margin:1em 1em 1em 0; border:solid 1px #AAAAAA; border-collapse:collapse; background-color:#edf9c7; font-size:95%; empty-cells:show;" <br />
!width=50px|'''Number'''<br />
!width=130px|'''Participant '''<br />
!width=100px|'''Country'''<br />
!width=100px|'''Arrival'''<br />
!width=100px|'''Departure'''<br />
!'''Topics'''<br />
!'''Notes'''<br />
|-<br />
|1<br />
| [[User:wenzeslaus|Vaclav Petras]]<br />
| United States <br />
| June 13<br />
| June 20<br />
| review PR, reduce PR queue, Python API topics (also for QGIS and R), funding<br />
|<br />
|-<br />
|2<br />
| [[User:Annakrat|Anna Petrasova]]<br />
| United States <br />
| June 13<br />
| June 20<br />
| grass.jupyter, R and QGIS integration<br />
|<br />
|-<br />
|3<br />
| [[User:Ctwhite|Corey White]]<br />
| United States <br />
| June 13<br />
| June 20<br />
| STAC, JSON outputs, connections with other tools (OpenPlains) <br />
|-<br />
|4<br />
| [[User:Chaedri|Caitlin Haedrich]]<br />
| United States<br />
| June 13<br />
| June 20<br />
| grass.jupyter<br />
|<br />
|-<br />
|5<br />
| [[User:Veroandreo | Vero Andreo]]<br />
| United States<br />
| June 13<br />
| June 20<br />
| STAC, tutorials, website, documentation, contributing guidelines<br />
|<br />
|-<br />
|}<br />
<br />
If you are arriving or departing on the days of the event, please specify the time, too.<br />
<br />
=== Online ===<br />
<br />
Join our [https://app.gitter.im/#/room/#grassgis_community:gitter.im Gitter chatroom]<br />
<br />
Gitter has a video (and backup will be Zoom).<br />
<br />
Participating virtually:<br />
<br />
{|class="wikitable sortable" border="2" cellspacing="0" cellpadding="4" rules="all" style="margin:1em 1em 1em 0; border:solid 1px #AAAAAA; border-collapse:collapse; background-color:#edf9c7; font-size:95%; empty-cells:show;" <br />
!width=50px|'''Number'''<br />
!width=130px|'''Participant '''<br />
!width=100px|'''Country'''<br />
!'''Topics'''<br />
!'''Times, synchronous or fully asynchronous'''<br />
!'''Notes'''<br />
|-<br />
|1<br />
| Be The First<br />
| Your Country<br />
| Your Topic<br />
| When you will be available (timezone, days, times)<br />
|<br />
|-<br />
|}<br />
<br />
== Venue ==<br />
<br />
[[File:Ncsu logo.jpg|240px|frameless|left]]<br />
[https://prague.ncsu.edu/about/ NC State European Center in Prague]<br><br />
Malé náměstí 144/1<br><br />
Praha 1 – 110 00<br><br />
Prague, Czech Republic<br><br />
<br />
[https://en.mapy.cz/s/fohulovaha Map]<br><br />
<br />
Prague, the capital of Czechia (Czech Republic) has an international [http://www.prg.aero/en/ airport]. It's location in the middle of central Europe makes it easily reachable by train, bus or car. The city itself has great public transportation.<br />
<br />
== Accommodation and Costs ==<br />
<br />
Participants should plan for the following costs:<br />
<br />
* Travel<br />
* Lodging<br />
* Food and drink (some may be covered)<br />
<br />
The participation is free of charge.<br />
<br />
'''Please note''': The currency in Czech Republic is {{wikipedia|Czech crown}} (CZK, koruna, Kč). 100 Czech crowns are about 4 Euros (see [https://www.cnb.cz/cs/financni-trhy/devizovy-trh/kurzy-devizoveho-trhu/kurzy-devizoveho-trhu/ current rates]).<br />
<br />
== Individual Preparation ==<br />
<br />
* Bring your own computer<br />
* Bring {{wikipedia|AC adapter|power connector adapter}} if needed (Czech Republic: 230V, 50Hz, {{wikipedia|File:Euro-Flachstecker_2.jpg|Type C Europlugs}} are common and also {{wikipedia|File:French_plug_and_socket.jpg|Type E}})<br />
* Install git and the compiler tools, and come with a working GRASS development environment if possible.<br />
<br />
== FAQ ==<br />
<br />
* '''How was it last time?'''<br />
** Splendid! See [[GRASS Community Meeting Prague 2023]]!<br />
* ''Is the meeting just a coding event?''<br />
** It is mainly a coding and documentation event. It is a working session for people who are already participants in the GRASS project and/or are committed to improving the GRASS project. Committed newcomers are welcome! <br />
** On demand we can do some presentations of current working GRASS implementation and new upcoming features to spread the idea of Open Source GIS software.<br />
* ''Is the GRASS Community Meeting for developers only?''<br />
** No: anybody can help, with testing, checking out bugs and fixes, documentation and more.<br />
* ''Where can I get help and more information about the community meeting?''<br />
** Contact [[User:Landa|Martin Landa]] <tt><landa.martin at gmail.com></tt></div>Veroandreohttps://grasswiki.osgeo.org/w/index.php?title=File:Ncsu_logo.jpg&diff=27454File:Ncsu logo.jpg2024-03-18T15:23:59Z<p>Veroandreo: </p>
<hr />
<div>NCSU logo</div>Veroandreohttps://grasswiki.osgeo.org/w/index.php?title=GRASS_Community_Meeting_Prague_2024&diff=27448GRASS Community Meeting Prague 20242024-03-18T15:08:12Z<p>Veroandreo: /* In person */</p>
<hr />
<div>{{toc|right}}<br />
The ''GRASS GIS Community Meeting'' for contributors and developers will be happening from '''June 14 to June 19, 2024''' in Prague, Czechia.<br />
<br />
[[File:Prague-Community-Meeting-2023-crop.jpg|500px|frameless|center]]<br />
<br />
== Sponsor us! ==<br />
<br />
We welcome financial contributions to support the meeting and we are looking for sponsors to cover costs such as meals or to help reducing travel and accommodation expenses for GRASS developers who volunteer their time. If you are interested in sponsoring the GRASS Community Meeting, please go to:<br />
<br />
::: '''[https://opencollective.com/osgeo/projects/grass/contribute OpenCollective]'''<br />
<br />
Any surplus at the end of the event will be used for future activities of the GRASS GIS project such as the [[Student Grants|Student Grant program]].<br />
<br />
This GRASS Community Meeting is a great occasion for you to support the development of GRASS. With your contribution you'll enable more developers to meet. Community meetings are important opportunities for developers to discuss, fix bugs, plan the direction for the project and work on new features. The developers and other contributors or their employers are donating their valuable time, so it would be great if funding can be made available from within the community to cover out-of-pocket expenses. All of the work that takes place at the community meeting will be directly contributed back into the GRASS project to the benefit of everyone who uses it. Note that while we have our general plan, we can't accept any earmarked donations, i.e., we can't make any promises for a specific work to be done, please contact specific developers or support commercial providers for that.<br />
<br />
* Sponsors will be acknowledged here.<br />
* In-kind contributions will be acknowledged here.<br />
* Personal time and/or financial contributions will be acknowledged here.<br />
<br />
== Purpose ==<br />
<br />
The ''GRASS GIS Community Meeting'' is a great occasion for folks to support the development by actively contributing to the project in different ways. These include source code updates, documentation (manuals, wiki, tutorials), translations, website improvements or likewise. The community meeting is also a get-together where supporters, contributors, power users and developers make decisions and tackle larger problems related to the project, discuss and collaboratively resolve bugs, plan the direction for the project and work on new features. We welcome people committed to improving the GRASS GIS project and the interfaces to QGIS, GDAL, PostGIS, R, OGC Services and others.<br />
<br />
In this meeting, building on momentum from the 40th birthday meeting, we will continue the revisions of the maintenance processes and infrastructure - a process which highly benefits from the current maintainers being in one place (and time zone). Topics which require highly synchronous collaboration will be included such as Markdown documentation and CMake build transitions. Other contributors are expected to enhance existing tools and their documentation. A [https://grass.osgeo.org/news/2023_08_13_grass_community_meeting_prague_june_2023_report/ press release] gives an overview of last year's event.<br />
<br />
We do require participants to work on GRASS GIS or connections to other projects. However, we leave them the freedom to work on what they think is the best contribution to the project given their skills and time available.<br />
<br />
For the detailed agenda and individual's plans, see below.<br />
<br />
== Program ==<br />
<br />
=== Thursday, June 13 ===<br />
<br />
Day of arrival. Contact organizers if you are interested in individualized program or helping with organization.<br />
<br />
=== Friday, June 14 ===<br />
<br />
=== Saturday, June 15 ===<br />
<br />
=== Sunday, June 16 ===<br />
<br />
=== Monday, June 17 ===<br />
<br />
=== Tuesday, June 18 ===<br />
<br />
=== Wednesday, June 19 ===<br />
<br />
=== Thursday, June 20 ===<br />
<br />
Day of departure.<br />
<br />
== Participation ==<br />
<br />
We are planning for an attendance of 20 people (i.e., coding places) but of course you are welcome to join us and bring new ideas with you: we'll make more places available. Please add your name here or contact [[User:Landa|Martin Landa]] <tt><landa.martin at gmail.com></tt>:<br />
<br />
=== In person ===<br />
<br />
{|class="wikitable sortable" border="2" cellspacing="0" cellpadding="4" rules="all" style="margin:1em 1em 1em 0; border:solid 1px #AAAAAA; border-collapse:collapse; background-color:#edf9c7; font-size:95%; empty-cells:show;" <br />
!width=50px|'''Number'''<br />
!width=130px|'''Participant '''<br />
!width=100px|'''Country'''<br />
!width=100px|'''Arrival'''<br />
!width=100px|'''Departure'''<br />
!'''Topics'''<br />
!'''Notes'''<br />
|-<br />
|1<br />
| [[User:wenzeslaus|Vaclav Petras]]<br />
| United States <br />
| June 13<br />
| June 20<br />
| review PR, reduce PR queue, Python API topics (also for QGIS and R), funding<br />
|<br />
|-<br />
|2<br />
| [[User:Annakrat|Anna Petrasova]]<br />
| United States <br />
| June 13<br />
| June 20<br />
| grass.jupyter, R and QGIS integration<br />
|<br />
|-<br />
|3<br />
| [[User:Ctwhite|Corey White]]<br />
| United States <br />
| June 13<br />
| June 20<br />
| STAC, JSON outputs, connections with other tools (OpenPlains) <br />
|-<br />
|4<br />
| Caitlin Haedrich<br />
| United States<br />
| June 13<br />
| June 20<br />
| grass.jupyter<br />
|<br />
|-<br />
|5<br />
| [[User:Veroandreo | Vero Andreo]]<br />
| United States<br />
| June 13<br />
| June 20<br />
| STAC, tutorials, website, documentation, contributing guidelines<br />
|<br />
|-<br />
|}<br />
<br />
If you are arriving or departing on the days of the event, please specify the time, too.<br />
<br />
=== Online ===<br />
<br />
Join our [https://app.gitter.im/#/room/#grassgis_community:gitter.im Gitter chatroom]<br />
<br />
Gitter has a video (and backup will be Zoom).<br />
<br />
Participating virtually:<br />
<br />
{|class="wikitable sortable" border="2" cellspacing="0" cellpadding="4" rules="all" style="margin:1em 1em 1em 0; border:solid 1px #AAAAAA; border-collapse:collapse; background-color:#edf9c7; font-size:95%; empty-cells:show;" <br />
!width=50px|'''Number'''<br />
!width=130px|'''Participant '''<br />
!width=100px|'''Country'''<br />
!'''Topics'''<br />
!'''Times, synchronous or fully asynchronous'''<br />
!'''Notes'''<br />
|-<br />
|1<br />
| Be The First<br />
| Your Country<br />
| Your Topic<br />
| When you will be available (timezone, days, times)<br />
|<br />
|-<br />
|}<br />
<br />
== Venue ==<br />
<br />
[https://prague.ncsu.edu/about/ NC State European Center in Prague]<br><br />
Malé náměstí 144/1<br><br />
Praha 1 – 110 00<br><br />
Prague<br><br />
Czech Republic<br><br />
<br />
[https://en.mapy.cz/s/fohulovaha Map]<br><br />
<br />
Prague, the capital of Czechia (Czech Republic) has an international [http://www.prg.aero/en/ airport]. It's location in the middle of central Europe makes it easily reachable by train, bus or car. The city itself has great public transportation.<br />
<br />
== Accommodation and Costs ==<br />
<br />
Participants should plan for the following costs:<br />
<br />
* The participation is free of charge<br />
* Travel<br />
* Lodging<br />
<br />
'''Please note''': The currency in Czech Republic is {{wikipedia|Czech crown}} (CZK, koruna, Kč). 100 Czech crowns are about 4 Euros (see [https://www.cnb.cz/cs/financni-trhy/devizovy-trh/kurzy-devizoveho-trhu/kurzy-devizoveho-trhu/ current rates]).<br />
<br />
== Individual Preparation ==<br />
<br />
* Bring your own computer<br />
* Bring {{wikipedia|AC adapter|power connector adapter}} if needed (Czech Republic: 230V, 50Hz, {{wikipedia|File:Euro-Flachstecker_2.jpg|Type C Europlugs}} are common and also {{wikipedia|File:French_plug_and_socket.jpg|Type E}})<br />
* Install git and the compiler tools, and come with a working GRASS development environment if possible.<br />
<br />
== FAQ ==<br />
<br />
* '''How was it last time?'''<br />
** Splendid! See [[GRASS Community Meeting Prague 2023]]!<br />
* ''Is the meeting just a coding event?''<br />
** It is mainly a coding and documentation event. It is a working session for people who are already participants in the GRASS project and/or are committed to improving the GRASS project. Committed newcomers are welcome! <br />
** On demand we can do some presentations of current working GRASS implementation and new upcoming features to spread the idea of Open Source GIS software.<br />
* ''Is the GRASS Community Meeting for developers only?''<br />
** No: anybody can help, with testing, checking out bugs and fixes, documentation and more.<br />
* ''Where can I get help and more information about the community meeting?''<br />
** Contact [[User:Landa|Martin Landa]] <tt><landa.martin at gmail.com></tt></div>Veroandreohttps://grasswiki.osgeo.org/w/index.php?title=GRASS_Community_Meeting_Prague_2024&diff=27447GRASS Community Meeting Prague 20242024-03-18T15:06:26Z<p>Veroandreo: /* Purpose */</p>
<hr />
<div>{{toc|right}}<br />
The ''GRASS GIS Community Meeting'' for contributors and developers will be happening from '''June 14 to June 19, 2024''' in Prague, Czechia.<br />
<br />
[[File:Prague-Community-Meeting-2023-crop.jpg|500px|frameless|center]]<br />
<br />
== Sponsor us! ==<br />
<br />
We welcome financial contributions to support the meeting and we are looking for sponsors to cover costs such as meals or to help reducing travel and accommodation expenses for GRASS developers who volunteer their time. If you are interested in sponsoring the GRASS Community Meeting, please go to:<br />
<br />
::: '''[https://opencollective.com/osgeo/projects/grass/contribute OpenCollective]'''<br />
<br />
Any surplus at the end of the event will be used for future activities of the GRASS GIS project such as the [[Student Grants|Student Grant program]].<br />
<br />
This GRASS Community Meeting is a great occasion for you to support the development of GRASS. With your contribution you'll enable more developers to meet. Community meetings are important opportunities for developers to discuss, fix bugs, plan the direction for the project and work on new features. The developers and other contributors or their employers are donating their valuable time, so it would be great if funding can be made available from within the community to cover out-of-pocket expenses. All of the work that takes place at the community meeting will be directly contributed back into the GRASS project to the benefit of everyone who uses it. Note that while we have our general plan, we can't accept any earmarked donations, i.e., we can't make any promises for a specific work to be done, please contact specific developers or support commercial providers for that.<br />
<br />
* Sponsors will be acknowledged here.<br />
* In-kind contributions will be acknowledged here.<br />
* Personal time and/or financial contributions will be acknowledged here.<br />
<br />
== Purpose ==<br />
<br />
The ''GRASS GIS Community Meeting'' is a great occasion for folks to support the development by actively contributing to the project in different ways. These include source code updates, documentation (manuals, wiki, tutorials), translations, website improvements or likewise. The community meeting is also a get-together where supporters, contributors, power users and developers make decisions and tackle larger problems related to the project, discuss and collaboratively resolve bugs, plan the direction for the project and work on new features. We welcome people committed to improving the GRASS GIS project and the interfaces to QGIS, GDAL, PostGIS, R, OGC Services and others.<br />
<br />
In this meeting, building on momentum from the 40th birthday meeting, we will continue the revisions of the maintenance processes and infrastructure - a process which highly benefits from the current maintainers being in one place (and time zone). Topics which require highly synchronous collaboration will be included such as Markdown documentation and CMake build transitions. Other contributors are expected to enhance existing tools and their documentation. A [https://grass.osgeo.org/news/2023_08_13_grass_community_meeting_prague_june_2023_report/ press release] gives an overview of last year's event.<br />
<br />
We do require participants to work on GRASS GIS or connections to other projects. However, we leave them the freedom to work on what they think is the best contribution to the project given their skills and time available.<br />
<br />
For the detailed agenda and individual's plans, see below.<br />
<br />
== Program ==<br />
<br />
=== Thursday, June 13 ===<br />
<br />
Day of arrival. Contact organizers if you are interested in individualized program or helping with organization.<br />
<br />
=== Friday, June 14 ===<br />
<br />
=== Saturday, June 15 ===<br />
<br />
=== Sunday, June 16 ===<br />
<br />
=== Monday, June 17 ===<br />
<br />
=== Tuesday, June 18 ===<br />
<br />
=== Wednesday, June 19 ===<br />
<br />
=== Thursday, June 20 ===<br />
<br />
Day of departure.<br />
<br />
== Participation ==<br />
<br />
We are planning for an attendance of 20 people (i.e., coding places) but of course you are welcome to join us and bring new ideas with you: we'll make more places available. Please add your name here or contact [[User:Landa|Martin Landa]] <tt><landa.martin at gmail.com></tt>:<br />
<br />
=== In person ===<br />
<br />
{|class="wikitable sortable" border="2" cellspacing="0" cellpadding="4" rules="all" style="margin:1em 1em 1em 0; border:solid 1px #AAAAAA; border-collapse:collapse; background-color:#edf9c7; font-size:95%; empty-cells:show;" <br />
!width=50px|'''Number'''<br />
!width=130px|'''Participant '''<br />
!width=100px|'''Country'''<br />
!width=100px|'''Arrival'''<br />
!width=100px|'''Departure'''<br />
!'''Topics'''<br />
!'''Notes'''<br />
|-<br />
|1<br />
| [[User:wenzeslaus|Vaclav Petras]]<br />
| United States <br />
| June 13<br />
| June 20<br />
| review PR, reduce PR queue, Python API topics (also for QGIS and R), funding<br />
|<br />
|-<br />
|2<br />
| [[User:Annakrat|Anna Petrasova]]<br />
| United States <br />
| June 13<br />
| June 20<br />
| grass.jupyter, R and QGIS integration<br />
|<br />
|-<br />
|3<br />
| [[User:Ctwhite|Corey White]]<br />
| United States <br />
| June 13<br />
| June 20<br />
| STAC, JSON outputs, connections with other tools (OpenPlains) <br />
|-<br />
|4<br />
| Caitlin Haedrich<br />
| United States<br />
| June 13<br />
| June 20<br />
| grass.jupyter<br />
|<br />
|-<br />
|5<br />
| Vero Andreo<br />
| United States<br />
| June 13<br />
| June 20<br />
| STAC, tutorials, website, documentation, contributing guidelines<br />
|<br />
|-<br />
|}<br />
<br />
If you are arriving or departing on the days of the event, please specify the time, too.<br />
<br />
=== Online ===<br />
<br />
Join our [https://app.gitter.im/#/room/#grassgis_community:gitter.im Gitter chatroom]<br />
<br />
Gitter has a video (and backup will be Zoom).<br />
<br />
Participating virtually:<br />
<br />
{|class="wikitable sortable" border="2" cellspacing="0" cellpadding="4" rules="all" style="margin:1em 1em 1em 0; border:solid 1px #AAAAAA; border-collapse:collapse; background-color:#edf9c7; font-size:95%; empty-cells:show;" <br />
!width=50px|'''Number'''<br />
!width=130px|'''Participant '''<br />
!width=100px|'''Country'''<br />
!'''Topics'''<br />
!'''Times, synchronous or fully asynchronous'''<br />
!'''Notes'''<br />
|-<br />
|1<br />
| Be The First<br />
| Your Country<br />
| Your Topic<br />
| When you will be available (timezone, days, times)<br />
|<br />
|-<br />
|}<br />
<br />
== Venue ==<br />
<br />
[https://prague.ncsu.edu/about/ NC State European Center in Prague]<br><br />
Malé náměstí 144/1<br><br />
Praha 1 – 110 00<br><br />
Prague<br><br />
Czech Republic<br><br />
<br />
[https://en.mapy.cz/s/fohulovaha Map]<br><br />
<br />
Prague, the capital of Czechia (Czech Republic) has an international [http://www.prg.aero/en/ airport]. It's location in the middle of central Europe makes it easily reachable by train, bus or car. The city itself has great public transportation.<br />
<br />
== Accommodation and Costs ==<br />
<br />
Participants should plan for the following costs:<br />
<br />
* The participation is free of charge<br />
* Travel<br />
* Lodging<br />
<br />
'''Please note''': The currency in Czech Republic is {{wikipedia|Czech crown}} (CZK, koruna, Kč). 100 Czech crowns are about 4 Euros (see [https://www.cnb.cz/cs/financni-trhy/devizovy-trh/kurzy-devizoveho-trhu/kurzy-devizoveho-trhu/ current rates]).<br />
<br />
== Individual Preparation ==<br />
<br />
* Bring your own computer<br />
* Bring {{wikipedia|AC adapter|power connector adapter}} if needed (Czech Republic: 230V, 50Hz, {{wikipedia|File:Euro-Flachstecker_2.jpg|Type C Europlugs}} are common and also {{wikipedia|File:French_plug_and_socket.jpg|Type E}})<br />
* Install git and the compiler tools, and come with a working GRASS development environment if possible.<br />
<br />
== FAQ ==<br />
<br />
* '''How was it last time?'''<br />
** Splendid! See [[GRASS Community Meeting Prague 2023]]!<br />
* ''Is the meeting just a coding event?''<br />
** It is mainly a coding and documentation event. It is a working session for people who are already participants in the GRASS project and/or are committed to improving the GRASS project. Committed newcomers are welcome! <br />
** On demand we can do some presentations of current working GRASS implementation and new upcoming features to spread the idea of Open Source GIS software.<br />
* ''Is the GRASS Community Meeting for developers only?''<br />
** No: anybody can help, with testing, checking out bugs and fixes, documentation and more.<br />
* ''Where can I get help and more information about the community meeting?''<br />
** Contact [[User:Landa|Martin Landa]] <tt><landa.martin at gmail.com></tt></div>Veroandreohttps://grasswiki.osgeo.org/w/index.php?title=GRASS_Community_Meeting_Prague_2024&diff=27445GRASS Community Meeting Prague 20242024-03-18T14:55:53Z<p>Veroandreo: /* Sponsor us! */</p>
<hr />
<div>{{toc|right}}<br />
The ''GRASS GIS Community Meeting'' for contributors and developers will be happening from '''June 14 to June 19, 2024''' in Prague, Czechia.<br />
<br />
[[File:Prague-Community-Meeting-2023-crop.jpg|frameless|alt=Group of smiling people in GRASS GIS t-shirts|Participants in 2023]]<br />
<br />
== Sponsor us! ==<br />
<br />
We welcome financial contributions to support the meeting and we are looking for sponsors to cover costs such as meals or to help reducing travel and accommodation expenses for GRASS developers who volunteer their time. If you are interested in sponsoring the GRASS Community Meeting, please go to:<br />
<br />
::: '''[https://opencollective.com/osgeo/projects/grass/contribute OpenCollective]'''<br />
<br />
Any surplus at the end of the event will be used for future activities of the GRASS GIS project such as the [[Student Grants|Student Grant program]].<br />
<br />
This GRASS Community Meeting is a great occasion for you to support the development of GRASS. With your contribution you'll enable more developers to meet. Community meetings are important opportunities for developers to discuss, fix bugs, plan the direction for the project and work on new features. The developers and other contributors or their employers are donating their valuable time, so it would be great if funding can be made available from within the community to cover out-of-pocket expenses. All of the work that takes place at the community meeting will be directly contributed back into the GRASS project to the benefit of everyone who uses it. Note that while we have our general plan, we can't accept any earmarked donations, i.e., we can't make any promises for a specific work to be done, please contact specific developers or support commercial providers for that.<br />
<br />
* Sponsors will be acknowledged here.<br />
* In-kind contributions will be acknowledged here.<br />
* Personal time and/or financial contributions will be acknowledged here.<br />
<br />
== Purpose ==<br />
<br />
''GRASS GIS Community Meeting'' is a great occasion for folks to support the development by actively contributing to the project by various activities including but not limited to source code updates, documentation (manuals, wiki, tutorials), translations, website improvements or likewise. The community meeting is also a get-together where supporters, contributors, power users and developers make decisions and tackle larger problems related to the project, discuss and collaboratively resolve bugs, plan the direction for the project and work on new features. We welcome people committed to improving the GRASS GIS project and the interfaces to QGIS, GDAL, PostGIS, R, OGC Services and others.<br />
<br />
In this meeting, building on momentum from the 40th birthday meeting, we will continue the revisions of the maintenance processes and infrastructure - a process which highly benefits from the current maintainers being in one place (and time zone). Other topics which require highly synchronous collaboration will be included such as Markdown documentation and CMake build transitions. Other contributors are expected to enhance the collection of processing tools and their documentation. A [https://grass.osgeo.org/news/2023_08_13_grass_community_meeting_prague_june_2023_report/ press release] gives an overview of last year's event.<br />
<br />
We do require participants to work on GRASS GIS or connections to other projects. However, we leave them the freedom to work on what they think is the best contribution to the project at that time given their skills and time available.<br />
<br />
For the detailed agenda and individual's plans, see below.<br />
<br />
== Program ==<br />
<br />
=== Thursday, June 13 ===<br />
<br />
Day of arrival. Contact organizers if you are interested in individualized program or helping with organization.<br />
<br />
=== Friday, June 14 ===<br />
<br />
=== Saturday, June 15 ===<br />
<br />
=== Sunday, June 16 ===<br />
<br />
=== Monday, June 17 ===<br />
<br />
=== Tuesday, June 18 ===<br />
<br />
=== Wednesday, June 19 ===<br />
<br />
=== Thursday, June 20 ===<br />
<br />
Day of departure.<br />
<br />
== Participation ==<br />
<br />
We are planning for an attendance of 20 people (i.e., coding places) but of course you are welcome to join us and bring new ideas with you: we'll make more places available. Please add your name here or contact [[User:Landa|Martin Landa]] <tt><landa.martin at gmail.com></tt>:<br />
<br />
=== In person ===<br />
<br />
{|class="wikitable sortable" border="2" cellspacing="0" cellpadding="4" rules="all" style="margin:1em 1em 1em 0; border:solid 1px #AAAAAA; border-collapse:collapse; background-color:#edf9c7; font-size:95%; empty-cells:show;" <br />
!width=50px|'''Number'''<br />
!width=130px|'''Participant '''<br />
!width=100px|'''Country'''<br />
!width=100px|'''Arrival'''<br />
!width=100px|'''Departure'''<br />
!'''Topics'''<br />
!'''Notes'''<br />
|-<br />
|1<br />
| [[User:wenzeslaus|Vaclav Petras]]<br />
| United States <br />
| June 13<br />
| June 20<br />
| review PR, reduce PR queue, Python API topics (also for QGIS and R), funding<br />
|<br />
|-<br />
|2<br />
| [[User:Annakrat|Anna Petrasova]]<br />
| United States <br />
| June 13<br />
| June 20<br />
| grass.jupyter, R and QGIS integration<br />
|<br />
|-<br />
|3<br />
| [[User:Ctwhite|Corey White]]<br />
| United States <br />
| June 13<br />
| June 20<br />
| STAC, JSON outputs, connections with other tools (OpenPlains) <br />
|-<br />
|4<br />
| Caitlin Haedrich<br />
| United States<br />
| June 13<br />
| June 20<br />
| grass.jupyter<br />
|<br />
|-<br />
|5<br />
| Vero Andreo<br />
| United States<br />
| June 13<br />
| June 20<br />
| STAC, tutorials, website, documentation, contributing guidelines<br />
|<br />
|-<br />
|}<br />
<br />
If you are arriving or departing on the days of the event, please specify the time, too.<br />
<br />
=== Online ===<br />
<br />
Join our [https://app.gitter.im/#/room/#grassgis_community:gitter.im Gitter chatroom]<br />
<br />
Gitter has a video (and backup will be Zoom).<br />
<br />
Participating virtually:<br />
<br />
{|class="wikitable sortable" border="2" cellspacing="0" cellpadding="4" rules="all" style="margin:1em 1em 1em 0; border:solid 1px #AAAAAA; border-collapse:collapse; background-color:#edf9c7; font-size:95%; empty-cells:show;" <br />
!width=50px|'''Number'''<br />
!width=130px|'''Participant '''<br />
!width=100px|'''Country'''<br />
!'''Topics'''<br />
!'''Times, synchronous or fully asynchronous'''<br />
!'''Notes'''<br />
|-<br />
|1<br />
| Be The First<br />
| Your Country<br />
| Your Topic<br />
| When you will be available (timezone, days, times)<br />
|<br />
|-<br />
|}<br />
<br />
== Venue ==<br />
<br />
[https://prague.ncsu.edu/about/ NC State European Center in Prague]<br><br />
Malé náměstí 144/1<br><br />
Praha 1 – 110 00<br><br />
Prague<br><br />
Czech Republic<br><br />
<br />
[https://en.mapy.cz/s/fohulovaha Map]<br><br />
<br />
Prague, the capital of Czechia (Czech Republic) has an international [http://www.prg.aero/en/ airport]. It's location in the middle of central Europe makes it easily reachable by train, bus or car. The city itself has great public transportation.<br />
<br />
== Accommodation and Costs ==<br />
<br />
Participants should plan for the following costs:<br />
<br />
* The participation is free of charge<br />
* Travel<br />
* Lodging<br />
<br />
'''Please note''': The currency in Czech Republic is {{wikipedia|Czech crown}} (CZK, koruna, Kč). 100 Czech crowns are about 4 Euros (see [https://www.cnb.cz/cs/financni-trhy/devizovy-trh/kurzy-devizoveho-trhu/kurzy-devizoveho-trhu/ current rates]).<br />
<br />
== Individual Preparation ==<br />
<br />
* Bring your own computer<br />
* Bring {{wikipedia|AC adapter|power connector adapter}} if needed (Czech Republic: 230V, 50Hz, {{wikipedia|File:Euro-Flachstecker_2.jpg|Type C Europlugs}} are common and also {{wikipedia|File:French_plug_and_socket.jpg|Type E}})<br />
* Install git and the compiler tools, and come with a working GRASS development environment if possible.<br />
<br />
== FAQ ==<br />
<br />
* '''How was it last time?'''<br />
** Splendid! See [[GRASS Community Meeting Prague 2023]]!<br />
* ''Is the meeting just a coding event?''<br />
** It is mainly a coding and documentation event. It is a working session for people who are already participants in the GRASS project and/or are committed to improving the GRASS project. Committed newcomers are welcome! <br />
** On demand we can do some presentations of current working GRASS implementation and new upcoming features to spread the idea of Open Source GIS software.<br />
* ''Is the GRASS Community Meeting for developers only?''<br />
** No: anybody can help, with testing, checking out bugs and fixes, documentation and more.<br />
* ''Where can I get help and more information about the community meeting?''<br />
** Contact [[User:Landa|Martin Landa]] <tt><landa.martin at gmail.com></tt></div>Veroandreohttps://grasswiki.osgeo.org/w/index.php?title=GRASS_Community_Meeting_Prague_2024&diff=27444GRASS Community Meeting Prague 20242024-03-18T14:55:11Z<p>Veroandreo: /* Sponsors */</p>
<hr />
<div>{{toc|right}}<br />
The ''GRASS GIS Community Meeting'' for contributors and developers will be happening from '''June 14 to June 19, 2024''' in Prague, Czechia.<br />
<br />
[[File:Prague-Community-Meeting-2023-crop.jpg|frameless|alt=Group of smiling people in GRASS GIS t-shirts|Participants in 2023]]<br />
<br />
== Sponsor us! ==<br />
<br />
We welcome financial contributions to support the meeting and we are looking for sponsors to cover costs such as meals or to help reducing travel and accommodation expenses for GRASS developers who volunteer their time. If you are interested in sponsoring the GRASS Community Meeting, please go to:<br />
<br />
::: '''[https://opencollective.com/osgeo/projects/grass/contribute OpenCollective]'''<br />
<br />
Any surplus at the end of the event will be used for future activities of the GRASS GIS project such as the [[Student Grants|Student Grant program]].<br />
<br />
This GRASS Community Meeting is a great occasion for you to support the development of GRASS. With your contribution you'll enable more developers to meet. Community meetings are important opportunities for developers to discuss, fix bugs, plan the direction for the project and work on new features. The developers and other contributors or their employers are donating their valuable time, so it would be great if funding can be made available from within the community to cover out-of-pocket expenses. All of the work that takes place at the community meeting will be directly contributed back into the GRASS project to the benefit of everyone who uses it. Note that while we have our general plan, we can't accept any earmarked donations, i.e., we can't make any promises for a specific work to be done, please contact specific developers or support commercial providers for that.<br />
<br />
Sponsors will be acknowledged here.<br />
<br />
In-kind contributions will be acknowledged here.<br />
<br />
Personal time and/or financial contributions will be acknowledged here.<br />
<br />
== Purpose ==<br />
<br />
''GRASS GIS Community Meeting'' is a great occasion for folks to support the development by actively contributing to the project by various activities including but not limited to source code updates, documentation (manuals, wiki, tutorials), translations, website improvements or likewise. The community meeting is also a get-together where supporters, contributors, power users and developers make decisions and tackle larger problems related to the project, discuss and collaboratively resolve bugs, plan the direction for the project and work on new features. We welcome people committed to improving the GRASS GIS project and the interfaces to QGIS, GDAL, PostGIS, R, OGC Services and others.<br />
<br />
In this meeting, building on momentum from the 40th birthday meeting, we will continue the revisions of the maintenance processes and infrastructure - a process which highly benefits from the current maintainers being in one place (and time zone). Other topics which require highly synchronous collaboration will be included such as Markdown documentation and CMake build transitions. Other contributors are expected to enhance the collection of processing tools and their documentation. A [https://grass.osgeo.org/news/2023_08_13_grass_community_meeting_prague_june_2023_report/ press release] gives an overview of last year's event.<br />
<br />
We do require participants to work on GRASS GIS or connections to other projects. However, we leave them the freedom to work on what they think is the best contribution to the project at that time given their skills and time available.<br />
<br />
For the detailed agenda and individual's plans, see below.<br />
<br />
== Program ==<br />
<br />
=== Thursday, June 13 ===<br />
<br />
Day of arrival. Contact organizers if you are interested in individualized program or helping with organization.<br />
<br />
=== Friday, June 14 ===<br />
<br />
=== Saturday, June 15 ===<br />
<br />
=== Sunday, June 16 ===<br />
<br />
=== Monday, June 17 ===<br />
<br />
=== Tuesday, June 18 ===<br />
<br />
=== Wednesday, June 19 ===<br />
<br />
=== Thursday, June 20 ===<br />
<br />
Day of departure.<br />
<br />
== Participation ==<br />
<br />
We are planning for an attendance of 20 people (i.e., coding places) but of course you are welcome to join us and bring new ideas with you: we'll make more places available. Please add your name here or contact [[User:Landa|Martin Landa]] <tt><landa.martin at gmail.com></tt>:<br />
<br />
=== In person ===<br />
<br />
{|class="wikitable sortable" border="2" cellspacing="0" cellpadding="4" rules="all" style="margin:1em 1em 1em 0; border:solid 1px #AAAAAA; border-collapse:collapse; background-color:#edf9c7; font-size:95%; empty-cells:show;" <br />
!width=50px|'''Number'''<br />
!width=130px|'''Participant '''<br />
!width=100px|'''Country'''<br />
!width=100px|'''Arrival'''<br />
!width=100px|'''Departure'''<br />
!'''Topics'''<br />
!'''Notes'''<br />
|-<br />
|1<br />
| [[User:wenzeslaus|Vaclav Petras]]<br />
| United States <br />
| June 13<br />
| June 20<br />
| review PR, reduce PR queue, Python API topics (also for QGIS and R), funding<br />
|<br />
|-<br />
|2<br />
| [[User:Annakrat|Anna Petrasova]]<br />
| United States <br />
| June 13<br />
| June 20<br />
| grass.jupyter, R and QGIS integration<br />
|<br />
|-<br />
|3<br />
| [[User:Ctwhite|Corey White]]<br />
| United States <br />
| June 13<br />
| June 20<br />
| STAC, JSON outputs, connections with other tools (OpenPlains) <br />
|-<br />
|4<br />
| Caitlin Haedrich<br />
| United States<br />
| June 13<br />
| June 20<br />
| grass.jupyter<br />
|<br />
|-<br />
|5<br />
| Vero Andreo<br />
| United States<br />
| June 13<br />
| June 20<br />
| STAC, tutorials, website, documentation, contributing guidelines<br />
|<br />
|-<br />
|}<br />
<br />
If you are arriving or departing on the days of the event, please specify the time, too.<br />
<br />
=== Online ===<br />
<br />
Join our [https://app.gitter.im/#/room/#grassgis_community:gitter.im Gitter chatroom]<br />
<br />
Gitter has a video (and backup will be Zoom).<br />
<br />
Participating virtually:<br />
<br />
{|class="wikitable sortable" border="2" cellspacing="0" cellpadding="4" rules="all" style="margin:1em 1em 1em 0; border:solid 1px #AAAAAA; border-collapse:collapse; background-color:#edf9c7; font-size:95%; empty-cells:show;" <br />
!width=50px|'''Number'''<br />
!width=130px|'''Participant '''<br />
!width=100px|'''Country'''<br />
!'''Topics'''<br />
!'''Times, synchronous or fully asynchronous'''<br />
!'''Notes'''<br />
|-<br />
|1<br />
| Be The First<br />
| Your Country<br />
| Your Topic<br />
| When you will be available (timezone, days, times)<br />
|<br />
|-<br />
|}<br />
<br />
== Venue ==<br />
<br />
[https://prague.ncsu.edu/about/ NC State European Center in Prague]<br><br />
Malé náměstí 144/1<br><br />
Praha 1 – 110 00<br><br />
Prague<br><br />
Czech Republic<br><br />
<br />
[https://en.mapy.cz/s/fohulovaha Map]<br><br />
<br />
Prague, the capital of Czechia (Czech Republic) has an international [http://www.prg.aero/en/ airport]. It's location in the middle of central Europe makes it easily reachable by train, bus or car. The city itself has great public transportation.<br />
<br />
== Accommodation and Costs ==<br />
<br />
Participants should plan for the following costs:<br />
<br />
* The participation is free of charge<br />
* Travel<br />
* Lodging<br />
<br />
'''Please note''': The currency in Czech Republic is {{wikipedia|Czech crown}} (CZK, koruna, Kč). 100 Czech crowns are about 4 Euros (see [https://www.cnb.cz/cs/financni-trhy/devizovy-trh/kurzy-devizoveho-trhu/kurzy-devizoveho-trhu/ current rates]).<br />
<br />
== Individual Preparation ==<br />
<br />
* Bring your own computer<br />
* Bring {{wikipedia|AC adapter|power connector adapter}} if needed (Czech Republic: 230V, 50Hz, {{wikipedia|File:Euro-Flachstecker_2.jpg|Type C Europlugs}} are common and also {{wikipedia|File:French_plug_and_socket.jpg|Type E}})<br />
* Install git and the compiler tools, and come with a working GRASS development environment if possible.<br />
<br />
== FAQ ==<br />
<br />
* '''How was it last time?'''<br />
** Splendid! See [[GRASS Community Meeting Prague 2023]]!<br />
* ''Is the meeting just a coding event?''<br />
** It is mainly a coding and documentation event. It is a working session for people who are already participants in the GRASS project and/or are committed to improving the GRASS project. Committed newcomers are welcome! <br />
** On demand we can do some presentations of current working GRASS implementation and new upcoming features to spread the idea of Open Source GIS software.<br />
* ''Is the GRASS Community Meeting for developers only?''<br />
** No: anybody can help, with testing, checking out bugs and fixes, documentation and more.<br />
* ''Where can I get help and more information about the community meeting?''<br />
** Contact [[User:Landa|Martin Landa]] <tt><landa.martin at gmail.com></tt></div>Veroandreohttps://grasswiki.osgeo.org/w/index.php?title=GRASS_Community_Meeting_Prague_2024&diff=27442GRASS Community Meeting Prague 20242024-03-18T14:51:14Z<p>Veroandreo: </p>
<hr />
<div>{{toc|right}}<br />
The ''GRASS GIS Community Meeting'' for contributors and developers will be happening from '''June 14 to June 19, 2024''' in Prague, Czechia.<br />
<br />
<gallery mode="slideshow"><br />
Image:Prague-Community-Meeting-2023-crop.jpg|Participants in 2023<br />
</gallery><br />
<br />
== Sponsors ==<br />
<br />
We welcome financial contributions to support the meeting and we are looking for sponsors to cover costs such as meals or to help reducing travel and accommodation expenses for GRASS developers who volunteer their time. If you are interested in sponsoring the GRASS Community Meeting, please go to:<br />
<br />
::: '''[https://opencollective.com/osgeo/projects/grass/contribute OpenCollective]'''<br />
<br />
Any surplus at the end of the event will be used for future activities of the GRASS GIS project such as the student mini grant program.<br />
<br />
This GRASS Community Meeting is a great occasion for you to support the development of GRASS. With your contribution you'll enable more developers to meet. Community meetings are important opportunities for developers to discuss, fix bugs, plan the direction for the project and work on new features. The developers and other contributors or their employers are donating their valuable time, so it would be great if funding can be made available from within the community to cover out-of-pocket expenses. All of the work that takes place at the community meeting will be directly contributed back into the GRASS project to the benefit of everyone who uses it. Note that while we have our general plan, we can't accept any earmarked donations, i.e., we can't make any promises for a specific work to be done, please contact specific developers or support commercial providers for that.<br />
<br />
Sponsors will be acknowledged here.<br />
<br />
In-kind contributions will be acknowledged here.<br />
<br />
Personal time and/or financial contributions will be acknowledged here.<br />
<br />
== Purpose ==<br />
<br />
''GRASS GIS Community Meeting'' is a great occasion for folks to support the development by actively contributing to the project by various activities including but not limited to source code updates, documentation (manuals, wiki, tutorials), translations, website improvements or likewise. The community meeting is also a get-together where supporters, contributors, power users and developers make decisions and tackle larger problems related to the project, discuss and collaboratively resolve bugs, plan the direction for the project and work on new features. We welcome people committed to improving the GRASS GIS project and the interfaces to QGIS, GDAL, PostGIS, R, OGC Services and others.<br />
<br />
In this meeting, building on momentum from the 40th birthday meeting, we will continue the revisions of the maintenance processes and infrastructure - a process which highly benefits from the current maintainers being in one place (and time zone). Other topics which require highly synchronous collaboration will be included such as Markdown documentation and CMake build transitions. Other contributors are expected to enhance the collection of processing tools and their documentation. A [https://grass.osgeo.org/news/2023_08_13_grass_community_meeting_prague_june_2023_report/ press release] gives an overview of last year's event.<br />
<br />
We do require participants to work on GRASS GIS or connections to other projects. However, we leave them the freedom to work on what they think is the best contribution to the project at that time given their skills and time available.<br />
<br />
For the detailed agenda and individual's plans, see below.<br />
<br />
== Program ==<br />
<br />
=== Thursday, June 13 ===<br />
<br />
Day of arrival. Contact organizers if you are interested in individualized program or helping with organization.<br />
<br />
=== Friday, June 14 ===<br />
<br />
=== Saturday, June 15 ===<br />
<br />
=== Sunday, June 16 ===<br />
<br />
=== Monday, June 17 ===<br />
<br />
=== Tuesday, June 18 ===<br />
<br />
=== Wednesday, June 19 ===<br />
<br />
=== Thursday, June 20 ===<br />
<br />
Day of departure.<br />
<br />
== Participation ==<br />
<br />
We are planning for an attendance of 20 people (i.e., coding places) but of course you are welcome to join us and bring new ideas with you: we'll make more places available. Please add your name here or contact [[User:Landa|Martin Landa]] <tt><landa.martin at gmail.com></tt>:<br />
<br />
=== In person ===<br />
<br />
{|class="wikitable sortable" border="2" cellspacing="0" cellpadding="4" rules="all" style="margin:1em 1em 1em 0; border:solid 1px #AAAAAA; border-collapse:collapse; background-color:#edf9c7; font-size:95%; empty-cells:show;" <br />
!width=50px|'''Number'''<br />
!width=130px|'''Participant '''<br />
!width=100px|'''Country'''<br />
!width=100px|'''Arrival'''<br />
!width=100px|'''Departure'''<br />
!'''Topics'''<br />
!'''Notes'''<br />
|-<br />
|1<br />
| [[User:wenzeslaus|Vaclav Petras]]<br />
| United States <br />
| June 13<br />
| June 20<br />
| review PR, reduce PR queue, Python API topics (also for QGIS and R), funding<br />
|<br />
|-<br />
|2<br />
| [[User:Annakrat|Anna Petrasova]]<br />
| United States <br />
| June 13<br />
| June 20<br />
| grass.jupyter, R and QGIS integration<br />
|<br />
|-<br />
|3<br />
| [[User:Ctwhite|Corey White]]<br />
| United States <br />
| June 13<br />
| June 20<br />
| STAC, JSON outputs, connections with other tools (OpenPlains) <br />
|-<br />
|4<br />
| Caitlin Haedrich<br />
| United States<br />
| June 13<br />
| June 20<br />
| grass.jupyter<br />
|<br />
|-<br />
|5<br />
| Vero Andreo<br />
| United States<br />
| June 13<br />
| June 20<br />
| STAC, tutorials, website, documentation, contributing guidelines<br />
|<br />
|-<br />
|}<br />
<br />
If you are arriving or departing on the days of the event, please specify the time, too.<br />
<br />
=== Online ===<br />
<br />
Join our [https://app.gitter.im/#/room/#grassgis_community:gitter.im Gitter chatroom]<br />
<br />
Gitter has a video (and backup will be Zoom).<br />
<br />
Participating virtually:<br />
<br />
{|class="wikitable sortable" border="2" cellspacing="0" cellpadding="4" rules="all" style="margin:1em 1em 1em 0; border:solid 1px #AAAAAA; border-collapse:collapse; background-color:#edf9c7; font-size:95%; empty-cells:show;" <br />
!width=50px|'''Number'''<br />
!width=130px|'''Participant '''<br />
!width=100px|'''Country'''<br />
!'''Topics'''<br />
!'''Times, synchronous or fully asynchronous'''<br />
!'''Notes'''<br />
|-<br />
|1<br />
| Be The First<br />
| Your Country<br />
| Your Topic<br />
| When you will be available (timezone, days, times)<br />
|<br />
|-<br />
|}<br />
<br />
== Venue ==<br />
<br />
[https://prague.ncsu.edu/about/ NC State European Center in Prague]<br><br />
Malé náměstí 144/1<br><br />
Praha 1 – 110 00<br><br />
Prague<br><br />
Czech Republic<br><br />
<br />
[https://en.mapy.cz/s/fohulovaha Map]<br><br />
<br />
Prague, the capital of Czechia (Czech Republic) has an international [http://www.prg.aero/en/ airport]. It's location in the middle of central Europe makes it easily reachable by train, bus or car. The city itself has great public transportation.<br />
<br />
== Accommodation and Costs ==<br />
<br />
Participants should plan for the following costs:<br />
<br />
* The participation is free of charge<br />
* Travel<br />
* Lodging<br />
<br />
'''Please note''': The currency in Czech Republic is {{wikipedia|Czech crown}} (CZK, koruna, Kč). 100 Czech crowns are about 4 Euros (see [https://www.cnb.cz/cs/financni-trhy/devizovy-trh/kurzy-devizoveho-trhu/kurzy-devizoveho-trhu/ current rates]).<br />
<br />
== Individual Preparation ==<br />
<br />
* Bring your own computer<br />
* Bring {{wikipedia|AC adapter|power connector adapter}} if needed (Czech Republic: 230V, 50Hz, {{wikipedia|File:Euro-Flachstecker_2.jpg|Type C Europlugs}} are common and also {{wikipedia|File:French_plug_and_socket.jpg|Type E}})<br />
* Install git and the compiler tools, and come with a working GRASS development environment if possible.<br />
<br />
== FAQ ==<br />
<br />
* '''How was it last time?'''<br />
** Splendid! See [[GRASS Community Meeting Prague 2023]]!<br />
* ''Is the meeting just a coding event?''<br />
** It is mainly a coding and documentation event. It is a working session for people who are already participants in the GRASS project and/or are committed to improving the GRASS project. Committed newcomers are welcome! <br />
** On demand we can do some presentations of current working GRASS implementation and new upcoming features to spread the idea of Open Source GIS software.<br />
* ''Is the GRASS Community Meeting for developers only?''<br />
** No: anybody can help, with testing, checking out bugs and fixes, documentation and more.<br />
* ''Where can I get help and more information about the community meeting?''<br />
** Contact [[User:Landa|Martin Landa]] <tt><landa.martin at gmail.com></tt></div>Veroandreohttps://grasswiki.osgeo.org/w/index.php?title=Compile_and_Install_Ubuntu&diff=27437Compile and Install Ubuntu2024-03-12T18:17:52Z<p>Veroandreo: /* Compilation */ update instructions, remove unrecognized and outdated</p>
<hr />
<div><div class="boilerplate metadata" id="attention" style="-moz-border-radius:30px; border: 1px double #35824B; margin-bottom: 1.5em; padding: 1em; background-color: #f9f9f9;"><br />
<p style="font-size: 150%; text-align: left;"><span style="color:#35824B">'''Attention'''</span>&nbsp;</p><span style="color:#333333">'''The following instructions describe the compilation and installation of GRASS GIS and its required dependencies completely from the source on Ubuntu based systems. Please, prefer pre-compiled packages over the manual way described below unless you know ''what'' and ''how'', you want to learn and help testing.'''</span><br />
</div><br />
<br />
== Quick instructions ==<br />
<br />
These instructions should work fine on Ubuntu distributions:<br />
<br />
=== Install geospatial dependencies ===<br />
<br />
1. Install some dependencies (PROJ, GEOS, GDAL libraries) and the compiler tools <br /><br />
(note: you need Python 3!)<br />
<br />
<source lang="bash"><br />
# be sure to have an updated system<br />
sudo apt update && sudo apt upgrade -y<br />
<br />
# install PROJ<br />
sudo apt install libproj-dev proj-data proj-bin unzip -y<br />
</source><br />
<br />
<source lang="bash"><br />
# optionally, install (selected) datum grid files<br />
sudo apt-get install proj-data<br />
<br />
# install GEOS<br />
sudo apt install libgeos-dev -y<br />
<br />
# install GDAL<br />
sudo apt install libgdal-dev python3-gdal gdal-bin -y<br />
<br />
# install PDAL (optional)<br />
sudo apt install libpdal-dev pdal libpdal-plugin-python -y<br />
<br />
# recommended to give Python3 precedence over Python2 (which is end-of-life since 2019)<br />
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3 1<br />
</source><br />
<br />
Install compiler stuff and further dependencies.<br />
Note: this is a single command, please copy-paste it entirely into the terminal:<br />
<br />
=== Install further compilation dependencies (Ubuntu 19.04) ===<br />
<br />
For Ubuntu 19.04<br />
<source lang="bash"><br />
sudo apt-get install \<br />
build-essential \<br />
flex make bison gcc libgcc1 g++ ccache \<br />
python3 python3-dev \<br />
python3-opengl \<br />
python-wxversion python-wxtools python-wxgtk3.0 python3-wxgtk4.0 \<br />
python3-dateutil libgsl-dev python3-numpy \<br />
wx3.0-headers wx-common libwxgtk3.0-dev \<br />
libwxbase3.0-dev \<br />
libncurses5-dev \<br />
libbz2-dev \<br />
zlib1g-dev gettext \<br />
libtiff5-dev libpnglite-dev \<br />
libcairo2 libcairo2-dev \<br />
sqlite3 libsqlite3-dev \<br />
libpq-dev \<br />
libreadline6-dev libfreetype6-dev \<br />
libfftw3-3 libfftw3-dev \<br />
libboost-thread-dev libboost-program-options-dev liblas-c-dev \<br />
subversion libzstd-dev \<br />
checkinstall \<br />
libglu1-mesa-dev libxmu-dev \<br />
ghostscript wget -y<br />
</source><br />
<br />
This are optional video codec libraries for NVIZ video output for Ubuntu 19.04:<br />
<source lang="bash"><br />
sudo apt-get install \<br />
libav-tools libavutil-dev ffmpeg2theora \<br />
libffmpegthumbnailer-dev \<br />
libavcodec-dev \<br />
libxmu-dev \<br />
libavformat-dev libswscale-dev <br />
</source><br />
<br />
=== Install further compilation dependencies (Ubuntu 20.04) ===<br />
<br />
For Ubuntu 20.04:<br />
<source lang="bash"><br />
sudo apt-get install \<br />
build-essential \<br />
flex make bison gcc libgcc1 g++ ccache \<br />
python3 python3-dev \<br />
python3-opengl python3-wxgtk4.0 \<br />
python3-dateutil libgsl-dev python3-numpy \<br />
wx3.0-headers wx-common libwxgtk3.0-gtk3-dev \<br />
libwxbase3.0-dev \<br />
libncurses5-dev \<br />
libbz2-dev \<br />
zlib1g-dev gettext \<br />
libtiff5-dev libpnglite-dev \<br />
libcairo2 libcairo2-dev \<br />
sqlite3 libsqlite3-dev \<br />
libpq-dev \<br />
libreadline6-dev libfreetype6-dev \<br />
libfftw3-3 libfftw3-dev \<br />
libboost-thread-dev libboost-program-options-dev libpdal-dev\<br />
subversion libzstd-dev \<br />
checkinstall \<br />
libglu1-mesa-dev libxmu-dev \<br />
ghostscript wget -y<br />
</source><br />
<br />
For NVIZ on Ubuntu 20.04:<br />
<source lang="bash"><br />
sudo apt-get install \<br />
ffmpeg libavutil-dev ffmpeg2theora \<br />
libffmpegthumbnailer-dev \<br />
libavcodec-dev \<br />
libxmu-dev \<br />
libavformat-dev libswscale-dev<br />
</source><br />
<br />
=== Install further compilation dependencies (Ubuntu 22.04) ===<br />
<br />
For Ubuntu 22.04:<br />
<source lang="bash"><br />
sudo apt-get install \<br />
build-essential \<br />
flex make bison gcc libgcc1 g++ ccache \<br />
python3 python3-dev \<br />
python3-opengl python3-wxgtk4.0 \<br />
python3-dateutil libgsl-dev python3-numpy \<br />
wx3.0-headers wx-common libwxgtk3.0-gtk3-dev \<br />
libwxbase3.0-dev \<br />
libncurses5-dev \<br />
libbz2-dev \<br />
zlib1g-dev gettext \<br />
libtiff5-dev libpnglite-dev \<br />
libcairo2 libcairo2-dev \<br />
sqlite3 libsqlite3-dev \<br />
libpdal-dev libpq-dev \<br />
libreadline-dev libfreetype6-dev \<br />
libfftw3-3 libfftw3-dev \<br />
libboost-thread-dev libboost-program-options-dev \<br />
subversion libzstd-dev \<br />
checkinstall \<br />
libglu1-mesa-dev libxmu-dev \<br />
ghostscript wget -y<br />
</source><br />
<br />
For NVIZ on Ubuntu 22.04:<br />
<source lang="bash"><br />
sudo apt-get install \<br />
ffmpeg libavutil-dev ffmpeg2theora \<br />
libffmpegthumbnailer-dev \<br />
libavcodec-dev \<br />
libxmu-dev \<br />
libavformat-dev libswscale-dev<br />
</source><br />
<br />
Update wxpython:<br />
<br />
<source lang="bash"><br />
pip3 install -U -f https://extras.wxpython.org/wxPython4/extras/linux/gtk3/ubuntu-22.04 wxPython<br />
</source><br />
<br />
=== Source code download ===<br />
Now we have all "ingredients" readily installed on our system.<br />
<br />
'''Source code download''':<br />
<br />
There a two ways of getting the source code: either use a) the weekly snapshot (cannot be updated, or b) the source code from the GitHub repository (you can update your local copy easily in future):<br />
<br />
'''a) Download of the weekly source code snapshot (not recommended):'''<br />
<source lang="bash"><br />
# download latest GRASS GIS 8.x stable release source code:<br />
mkdir $HOME/src/<br />
cd $HOME/src/<br />
wget https://grass.osgeo.org/grass82/source/snapshot/grass-8.2.git_src_snapshot_latest.tar.gz<br />
<br />
# Unpack source code package and remove tarball archive:<br />
tar xvfz grass-8.2.git_src_snapshot_latest.tar.gz<br />
rm -f grass-8.2.git_src_snapshot_latest.tar.gz <br />
<br />
# rename source code directory (yes, with the questionmarks!)<br />
mv grass-8.2.git_src_snapshot_20??_??_?? grass-8.2.latest<br />
cd grass-8.2.latest/<br />
</source><br />
<br />
'''b) Download of the current development version from GitHub (adopt the path below accordingly)'''<br />
<source lang="bash"><br />
sudo apt-get install git<br />
git clone https://github.com/OSGeo/grass.git grass-8.2.latest.git<br />
cd grass-8.2.latest.git/<br />
git checkout releasebranch_8_2<br />
</source><br />
<br />
=== Compilation ===<br />
Now we can '''compile''' the source code in order to generate the GRASS GIS binaries:<br />
<br />
For Ubuntu 19.04<br />
<source lang="bash"><br />
# "configure" source code for local machine (checks for CPU type etc):<br />
MYCFLAGS='-O2 -fPIC -fno-common -fexceptions -std=gnu99 -fstack-protector -m64'<br />
#MYCXXFLAGS=''<br />
MYLDFLAGS='-Wl,--no-undefined -Wl,-z,now'<br />
<br />
LDFLAGS="$MYLDFLAGS" CFLAGS="$MYCFLAGS" CXXFLAGS="$MYCXXFLAGS" ./configure \<br />
--with-cxx \<br />
--enable-largefile \<br />
--with-proj --with-proj-share=/usr/share/proj \<br />
--with-gdal=/usr/bin/gdal-config \<br />
--with-python \<br />
--with-geos \<br />
--with-sqlite \<br />
--with-nls \<br />
--with-zstd \<br />
--with-liblas \<br />
--with-pdal \<br />
--with-cairo --with-cairo-ldflags=-lfontconfig \<br />
--with-freetype=yes --with-freetype-includes="/usr/include/freetype2/" \<br />
--with-wxwidgets \<br />
--with-fftw \<br />
--with-motif \<br />
--with-opengl-libs=/usr/include/GL \<br />
--with-postgres=yes --with-postgres-includes="/usr/include/postgresql" \<br />
--without-netcdf \<br />
--without-mysql \<br />
--without-odbc \<br />
--without-openmp \<br />
--without-ffmpeg<br />
</source><br />
<br />
Ubuntu 20.04/22.04 (without liblas but with PDAL):<br />
<source lang="bash"><br />
# "configure" source code for local machine (checks for CPU type etc):<br />
MYCFLAGS='-O2 -fPIC -fno-common -fexceptions -std=gnu99 -fstack-protector -m64'<br />
#MYCXXFLAGS=''<br />
MYLDFLAGS='-Wl,--no-undefined -Wl,-z,now'<br />
<br />
LDFLAGS="$MYLDFLAGS" CFLAGS="$MYCFLAGS" CXXFLAGS="$MYCXXFLAGS" ./configure \<br />
--with-cxx \<br />
--enable-largefile \<br />
--with-proj-share=/usr/share/proj \<br />
--with-gdal=/usr/bin/gdal-config \<br />
--with-geos \<br />
--with-sqlite \<br />
--with-nls \<br />
--with-zstd \<br />
--with-pdal \<br />
--with-cairo --with-cairo-ldflags=-lfontconfig \<br />
--with-freetype=yes --with-freetype-includes="/usr/include/freetype2/" \<br />
--with-fftw \<br />
--with-opengl-libs=/usr/include/GL \<br />
--with-postgres=yes --with-postgres-includes="/usr/include/postgresql" \<br />
--without-netcdf \<br />
--without-mysql \<br />
--without-odbc \<br />
--without-openmp<br />
</source><br />
<br />
Now compile the source code (this will take some time as it generates binary code from the source code):<br />
<source lang="bash"><br />
# note: the more CPUs you have, the higher the -j number may be set to<br />
# here: build using 4 CPU cores<br />
make -j4<br />
</source><br />
<br />
=== Installation ===<br />
<br />
Install resulting GRASS GIS binaries into /usr/local/:<br />
<source lang="bash"><br />
sudo make install<br />
</source><br />
<br />
Start GRASS GIS in the terminal:<br />
<source lang="bash"><br />
grass<br />
</source><br />
<br />
'''Done & enjoy!'''<br />
<br />
== Hints ==<br />
<br />
* Usually, the installation of compiled code is done by using the <source lang="bash" enclose="none">make</source> tool. Alternatively, this can be done by using the ''checkinstall'' tool (i.e., <source lang="bash" enclose="none">sudo checkinstall</source> instead of <source lang="bash" enclose="none">sudo make install</source>) which eases off removal of packages. If ''checkinstall'' fails to deliver, please note some related bugs: [https://bugs.launchpad.net/ubuntu/+source/checkinstall/+bug/78455 78455] and [https://bugs.launchpad.net/ubuntu/+source/checkinstall/+bug/599163 599163]. Useful information on using ''checkinstall'': [https://help.ubuntu.com/community/CompilingEasyHowTo Compiling things on Ubuntu the Easy Way].<br />
<br />
* In multi-core processors, the compilation performance can be boosted by using ''-j'' switches (e.g. <source lang="bash" enclose="none">make -j2</source> or <source lang="bash" enclose="none">make -j3</source> or even <source lang="bash" enclose="none">make -j4</source>) which specify the number of jobs (commands) to run simultaneously.<br />
<br />
== Pre-compiled packages and backports ==<br />
<br />
'''Pre-compiled packages and backports''' are available from [https://wiki.ubuntu.com/UbuntuGIS UbuntuGIS] via their [https://launchpad.net/~ubuntugis/+archive/ppa/ ppa.launchpad stable] and [https://launchpad.net/~ubuntugis/+archive/ubuntu/ubuntugis-unstable ppa.launchpad unstable] repositories. '''This is by far the simplest and fastest solution. Please prefer it over the manual way of compiling source code yourself as described below.'''<br />
<br />
Version overview:<br />
* jammy (22.04): 8.2<br />
* focal (20.04 LTS): 8.2<br />
* bionic (18.04 LTS): 7.8<br />
* xenial (16.04 LTS): 7.6<br />
* trusty (14.04 LTS): 7.4<br />
<br />
a) Daily ready-to-install GRASS GIS builds of the 7.x release branch and master are available from ''ppa:grass/grass-devel'':<br />
<br />
<source lang=bash><br />
sudo add-apt-repository ppa:ubuntugis/ubuntugis-unstable<br />
sudo add-apt-repository ppa:grass/grass-devel<br />
</source><br />
<br />
b) Latest stable version of GRASS 7.x is available from ''ppa:grass/grass-stable'':<br />
<source lang=bash><br />
sudo add-apt-repository ppa:ubuntugis/ppa<br />
sudo add-apt-repository ppa:grass/grass-stable<br />
sudo apt-get update<br />
sudo apt-get install grass78<br />
</source><br />
<br />
== Dependencies ==<br />
<br />
=== Current stable Ubuntu version ===<br />
First, update the system from the repositories<source lang="bash"><br />
sudo apt-get update && sudo apt-get upgrade<br />
</source><br />
<br />
Then, install ''SQLite'', ''SVN'' and ''dependencies'' for compiling PROJ, GEOS, GDAL/OGR, GRASS, GDAL-GRASS-PLUGIN (some additional packages may be required in this case); the following action will also install various dependencies (listed in the command line as <source lang="bash" enclose="none">The following extra packages will be installed:</source>...):<br/><br />
<br />
The following dependencies concern [http://releases.ubuntu.com/xenial/ Ubuntu Xenial Xerus (16.04 LTS)]<br />
<br />
<source lang="bash"><br />
# this is a single command, please copy-paste it entirely into the terminal:<br />
sudo apt-get install \<br />
build-essential \<br />
flex make bison gcc libgcc1 g++ cmake ccache \<br />
python python-dev \<br />
python-opengl \<br />
python-wxversion python-wxtools python-wxgtk3.0 \<br />
python-dateutil libgsl-dev python-numpy \<br />
wx3.0-headers wx-common libwxgtk3.0-dev \<br />
libwxbase3.0-dev \<br />
libncurses5-dev \<br />
zlib1g-dev gettext \<br />
libtiff5-dev libpnglite-dev \<br />
libcairo2 libcairo2-dev \<br />
sqlite3 libsqlite3-dev \<br />
libpq-dev \<br />
libreadline6 libreadline6-dev libfreetype6-dev \<br />
libfftw3-3 libfftw3-dev \<br />
libboost-thread-dev libboost-program-options-dev liblas-c-dev \<br />
resolvconf \<br />
libjasper-dev \<br />
subversion \<br />
libav-tools libavutil-dev ffmpeg2theora \<br />
libffmpegthumbnailer-dev \<br />
libavcodec-dev \<br />
libxmu-dev \<br />
libavformat-dev libswscale-dev \<br />
checkinstall \<br />
libglu1-mesa-dev libxmu-dev \<br />
ghostscript<br />
</source><br />
<br />
The following dependencies concern [http://releases.ubuntu.com/trusty/ Ubuntu Trusty Tahr (14.04 LTS)]<br />
<br />
<source lang="bash"><br />
# this is a single command, please copy-paste it entirely into the terminal:<br />
sudo apt-get install \<br />
build-essential \<br />
flex make bison gcc libgcc1 g++ \<br />
python python-dev \<br />
python-dateutil libgsl0-dev python-numpy \<br />
zlib1g-dev gettext \<br />
libtiff-dev libpnglite-dev \<br />
sqlite3 libsqlite3-dev \<br />
libboost-thread-dev libboost-program-options-dev liblas-c-dev \<br />
resolvconf \<br />
subversion \<br />
checkinstall \<br />
cmake ccache \<br />
python-opengl \<br />
python-wxversion python-wxtools python-wxgtk2.8 \<br />
wx2.8-headers wx-common libwxgtk2.8-dev libwxgtk2.8-dbg \<br />
libwxbase2.8-dev libwxbase2.8-dbg \<br />
libncurses5-dev \<br />
libcairo2 libcairo2-dev \<br />
libpq-dev \<br />
libreadline6 libreadline6-dev libfreetype6-dev \<br />
libfftw3-3 libfftw3-dev \<br />
libjasper-dev \<br />
libav-tools libavutil-dev ffmpeg2theora \<br />
libffmpegthumbnailer-dev \<br />
libavcodec-dev \<br />
libxmu-dev \<br />
libavformat-dev libswscale-dev \<br />
libglu1-mesa-dev libxmu-dev \<br />
ghostscript</source><br />
<br />
<br />
* See the additional packages bellow and in other sections and install them. Note that some of them are [http://grass.osgeo.org/grass70/source/REQUIREMENTS.html required], namely PROJ.4, GEOS and GDAL. If you don't have special requirements, it is usually enough just to install PROJ.4, GEOS and GDAL from repository (rather then compile them manually).<br />
<br />
* for mysql support, <source lang="bash" enclose="none">libmysqlclient-dev</source> is required<br />
<source lang="bash"><br />
sudo apt-get install libmysqlclient-dev<br />
</source><br />
<br />
* for netcdf support, <source lang="bash" enclose="none">netcdf-bin</source> and <source lang="bash" enclose="none">libnetcdf-dev</source> is required<br />
<source lang="bash"><br />
sudo apt-get install netcdf-bin libnetcdf-dev<br />
</source><br />
<br />
* for {{AddonCmd|i.spec.unmix}} Addon support, install LAPACK and BLAS:<br />
<source lang="bash"><br />
sudo apt-get install libatlas-dev libblas-dev liblapack-dev<br />
</source><br />
<br />
* create a directory as a simple user where all source code is going to be stored -- in this example, a directory named <source lang="bash" enclose="none">src</source> under <source lang="bash" enclose="none">/usr/local</source> is created <source lang="bash"><br />
sudo mkdir /usr/local/src<br />
</source><br />
<br />
* take over directories ownerships ('''replace''' below the terms ''userid'' and ''groupid'' with a real <source lang="bash" enclose="none">userid</source>): <source lang="bash"><br />
sudo chown userid:groupid /usr/local/src</source><br />
<br />
* similarly, grant <source lang="bash" enclose="none">rwx</source> (read-write-execute) permissions for our ''userid'' and ''groupid'' onto the <source lang="bash" enclose="none">src</source> directory: <source lang="bash"><br />
sudo chmod ug+rwx /usr/local/src</source><br />
<br />
=== Earlier Ubuntu versions ===<br />
<br />
For [http://old-releases.ubuntu.com/releases/ earlier Ubuntu versions], '''watch out for dependency differences!''' Modify the dependency list given above as instructed below.<br />
<br />
* for [http://releases.ubuntu.com/raring/ Ubuntu Raring Ringtail (13.04]), change the following dependencies:<br />
** <source lang="bash" enclose="none">libav-tools libavutil-dev --> ffmpeg</source> <br />
** <source lang="bash" enclose="none"> --> lesstif2-dev</source><br />
<br />
* for [http://releases.ubuntu.com/precise/ Ubuntu Precise Pangolin (12.04)], change the following dependencies:<br />
** <source lang="bash" enclose="none">libpnglite-dev --> libpngwriter-dev</source><br />
** <source lang="bash" enclose="none">libtiff5-dev --> libtiff4-dev</source><br />
<br />
* for [http://old-releases.ubuntu.com/releases/maverick/ Ubuntu Maverick Meerkat (10.10)] or later, change the following dependencies:<br />
** <source lang="bash" enclose="none">libpngwriter-dev --> libpngwriter0-dev</source><br />
** <source lang="bash" enclose="none">libcairo-dev --> libcairo2-dev</source><br />
** <source lang="bash" enclose="none">fftw3 --> libfftw3-3</source><br />
** <source lang="bash" enclose="none">fftw3-dev --> libfftw3-dev</source><br />
<br />
* for [http://old-releases.ubuntu.com/releases/lucid/ Ubuntu Lucid Lynx (10.04)] or later, also install: <source lang="bash">sudo apt-get install libhdf4-alt-dev libhdf4-0-alt</source><br />
<br />
* for [http://old-releases.ubuntu.com/releases/ earlier Ubuntu versions], also install: <source lang="bash"> sudo apt-get install libhdf4g-dev libhdf4g-run</source><br />
<br />
== Using pre-compiled dev Packages for PROJ.4, GEOS and GDAL ==<br />
<br />
=== PROJ.4 ===<br />
<br />
Install the <source lang="bash" enclose="none">dev</source> package:<br />
<br />
<source lang="bash"><br />
sudo apt-get install libproj-dev proj-data proj-bin<br />
</source><br />
<br />
* In the call to <source lang="bash" enclose="none">./configure</source> for [[#GRASS|GRASS]], replace <source lang="bash" enclose="none">--with-proj-share=/usr/local/share/proj/</source> by <source lang="bash" enclose="none">--with-proj-share=/usr/share/proj/</source><br />
<br />
=== GEOS ===<br />
<br />
Install the <source lang="bash" enclose="none">dev</source> package:<br />
<br />
<source lang="bash"><br />
# probably you also need to additionally install "libgeos-c1v5"<br />
sudo apt-get install libgeos-dev<br />
</source><br />
<br />
* In the call to <source lang="bash" enclose="none">./configure</source> for [[#GRASS|GRASS]], replace <source lang="bash" enclose="none">--with-geos=/usr/local/bin/geos-config</source> by <source lang="bash" enclose="none">--with-geos=/usr/bin/geos-config</source><br />
<br />
=== GDAL ===<br />
<br />
Install the <source lang="bash" enclose="none">dev</source> package (possibly without support for datumgrid):<br />
<br />
<source lang="bash"><br />
sudo apt-get install libgdal-dev<br />
</source><br />
<br />
For support of WMS in wxGUI install Python GDAL bindings and GDAL executables:<br />
<source lang="bash"><br />
sudo apt-get install python-gdal gdal-bin<br />
</source><br />
<br />
* Install also the required extra packages (note the message: <source lang="bash" enclose="none">The following extra packages will be installed:</source>)<br />
* Look out for packages to be removed by this operation -- this is most likely caused by incompatible package versions. Fix these problems in advance using commands like the following: <source lang="bash"><br />
sudo apt-get install <package>=<required.version></source><br />
<br />
=== GRASS-GIS ===<br />
<br />
[[Compile_and_Install_Ubuntu#GRASS_GIS|Jump to sub-section GRASS-GIS below]]<br />
<br />
== Using pre-compiled dev Packages for PROJ.4, GEOS and GDAL from GIS.lab PPA==<br />
<br />
Ivan Mincik has made all required packages available in his [https://launchpad.net/~imincik/+archive/ubuntu/gis PPA]:<br />
<br />
<source lang="bash"><br />
sudo add-apt-repository ppa:imincik/gis<br />
sudo apt-get install libproj-dev libgdal-dev python-gdal libgeos-dev<br />
</source><br />
<br />
Now you can either also install GRASS GIS 7 from there or compile it yourself (see [[Compile_and_Install_Ubuntu#GRASS_GIS|Jump to sub-section GRASS-GIS below]])<br />
<br />
== Compile from source ==<br />
<br />
<br />
=== PROJ4 ===<br />
<br />
* within the directory <source lang="bash" enclose="none">/usr/local/src</source> (create it if it does not exist) checkout <source lang="bash" enclose="none">proj</source> from its Subversion repository: <source lang="bash"><br />
svn co http://svn.osgeo.org/metacrs/proj/branches/4.8/proj/<br />
</source><br />
<br />
* get [http://download.osgeo.org/proj/proj-datumgrid-1.5.zip '''proj-datumgrid-1.5.zip'''] from [http://trac.osgeo.org/proj proj' trac] and move it under <source lang="bash" enclose="none">proj/nad</source><br />
<ul><source lang="bash"><br />
wget http://download.osgeo.org/proj/proj-datumgrid-1.5.zip<br />
mv proj-datumgrid-1.5.zip /usr/local/src/proj/nad<br />
cd /usr/local/src/proj/nad<br />
</source><br />
</ul><br />
<br />
* decompress it <source lang="bash"><br />
unzip proj-datumgrid-1.5.zip<br />
</source><br />
<br />
* go back to the <source lang="bash" enclose="none">proj</source> directory <source lang="bash"><br />
cd /usr/local/src/proj<br />
</source><br />
<br />
* if required, clean previous configuration & compilation <source lang="bash"><br />
make distclean<br />
</source><br />
<br />
* simple configure, compile and install <source lang="bash"><br />
./configure && make && sudo make install<br />
</source><br />
<ul> or <source lang="bash"><br />
./configure && make -j2 && sudo checkinstall<br />
</source><br />
</ul><br />
<br />
* ensure that <source lang="bash" enclose="none">/usr/local/lib</source> is added to <source lang="bash" enclose="none">/etc/ld.so.conf</source> and afterwards run <source lang="bash"><br />
sudo ldconfig<br />
</source><br />
<br />
* finally, go back to the parent directory simply by instructing<source lang="bash"><br />
cd ..<br />
</source><br />
<br />
=== GEOS ===<br />
<br />
* download '''geos-3.4.2.tar.bz2''' from [http://trac.osgeo.org/geos/ http://trac.osgeo.org/geos] using <source lang="bash" enclose="none">wget</source> <source lang="bash"><br />
wget http://download.osgeo.org/geos/geos-3.4.2.tar.bz2<br />
</source><br />
<br />
* move to the "source-code" directory and decompress<br />
<ul><source lang="bash"><br />
cd /usr/local/src/<br />
bunzip2 geos-3.4.2.tar.bz2<br />
tar xvf geos-3.4.2.tar<br />
</source><br />
</ul><br />
<br />
* if required, clean previous configuration & compilation <source lang="bash"><br />
make distclean<br />
</source><br />
<br />
* move to geos directory <source lang="bash"><br />
cd geos-3.4.2<br />
</source><br />
<br />
* simple configure, compile and install <source lang="bash"><br />
./configure && make && sudo make install<br />
</source><br />
<ul> or <source lang="bash"><br />
./configure && make -j2 && sudo checkinstall<br />
</source><br />
</ul><br />
<br />
* do not forget to execute <source lang="bash"><br />
sudo ldconfig<br />
</source><br />
<br />
=== GDAL ===<br />
<br />
'''Note''', GDAL must be compiled '''without''' GRASS support<br />
<br />
* download the current stable version <source lang="bash"><br />
svn co https://svn.osgeo.org/gdal/branches/1.11/gdal gdal_stable<br />
</source><br />
<br />
* enter in the <source lang="bash" enclose="none">gdal_stable</source> directory <source lang="bash"><br />
cd /usr/local/src/gdal_stable<br />
</source><br />
<br />
* optionally, update the source code <source lang="bash"><br />
svn up<br />
</source><br />
<br />
* if required, clean previous configurations/compilations <source lang="bash"><br />
make distclean<br />
</source><br />
<br />
* a simple configuration without any parameters will detect and support various installed libraries <source lang="bash"><br />
./configure<br />
</source><br />
<br />
* skip to the ''compile and install'' step or check the following customised configuration example<br />
<ul><br />
<source lang="bash"><br />
CFLAGS="-g -Wall" LDFLAGS="-s" ./configure \<br />
--with-png=internal \<br />
--with-libtiff=internal \<br />
--with-geotiff=internal \<br />
--with-jpeg=internal \<br />
--with-gif=internal \<br />
--with-ecw=no \<br />
--with-expat=yes \<br />
--with-sqlite3=yes \<br />
--with-geos=yes \<br />
--with-python \<br />
--with-libz=internal \<br />
--with-netcdf \<br />
--with-threads=yes \<br />
--without-grass \<br />
--without-ogdi \<br />
--with-pg=/usr/bin/pg_config \<br />
--with-xerces=yes<br />
</source><br />
</ul><br />
<br />
* compile, install & ldconfig <source lang="bash"><br />
make -j2 && sudo make install && sudo ldconfig<br />
</source><br />
<ul> or <source lang="bash"><br />
make -j2 && sudo checkinstall && sudo ldconfig<br />
</source><br />
</ul><br />
<br />
=== GRASS GIS ===<br />
<br />
Note the differences between different GRASS version (SVN branches) in download and cofiguration. Note also the changes required if you installed some of the dependencies from packages (rather then compiled them yourself).<br />
<br />
To fully understand the build process, read the <code>INSTALL</code> file, which is located in GRASS' source code root directory. For example, if you have problems related to 32bit versus 64bit, pay attention to section <code>(C)</code>, entitled <code>COMPILATION NOTES for 64bit platforms</code>.<br />
<br />
''' Getting GRASS' source code '''<br />
<br />
Select from one of the GRASS GIS versions and download (using SVN) the source code:<br />
<br />
* VERY OLD STABLE VERSION: current state of the 6.4.x release branch version (stable) <source lang="bash"><br />
svn co https://svn.osgeo.org/grass/grass/branches/releasebranch_6_4 grass64_release<br />
</source><br />
<br />
* STABLE VERSION: current state of the 7.2.x release branch version (current stable) <source lang="bash"><br />
svn co https://svn.osgeo.org/grass/grass/branches/releasebranch_7_2 grass72_release<br />
</source><br />
<br />
* DEVELOPMENT VERSION: current state of the trunk (latest version of code where the development happens) <source lang="bash"><br />
svn co https://svn.osgeo.org/grass/grass/trunk grass7_trunk<br />
</source><br />
<br />
* for other versions see [http://trac.osgeo.org/grass/wiki/DownloadSource GRASS Trac wiki].<br />
<br />
''' Configure, Compile and Install'''<br />
<br />
Enter the directory with the source code (downloaded by svn client), for example:<br />
<br />
<source lang="bash"><br />
cd grass72_release<br />
</source><br />
<br />
* '''GRASS GIS 6 example configuration''' (which can/should be adjusted according to specific needs):<br />
<ul><br />
<source lang="bash"><br />
CFLAGS="-O2 -Wall" LDFLAGS="-s" ./configure \<br />
--enable-largefile=yes \<br />
--with-nls \<br />
--with-cxx \<br />
--with-proj-share=/usr/local/share/proj/ \<br />
--with-geos=/usr/local/bin/geos-config \<br />
--with-readline \<br />
--with-python=yes \<br />
--with-wxwidgets \<br />
--with-cairo \<br />
--with-opengl-libs=/usr/include/GL \<br />
--with-motif \<br />
--with-tcltk-includes="/usr/include/tcl8.5" \<br />
--with-ffmpeg=yes --with-ffmpeg-includes="/usr/include/libavcodec /usr/include/libavformat /usr/include/libswscale /usr/include/libavutil" \<br />
--with-freetype=yes --with-freetype-includes="/usr/include/freetype2/" \<br />
--with-postgres=yes --with-postgres-includes="/usr/include/postgresql" \<br />
--with-sqlite=yes \<br />
--with-mysql=yes --with-mysql-includes="/usr/include/mysql" \<br />
--with-odbc=no<br />
</source><br />
</ul><br />
<ul><br />
'''Note''', the above configuration uses the <code>Proj4</code> and <code>GEOS</code> packages compiled from the source. In the case that pre-compiled versions from the repository are required, remove the above corresponding lines to use the "defaults", i.e. <source lang="bash"><br />
--with-proj-share=/usr/share/proj \<br />
--with-geos=/usr/bin/geos-config \<br />
</source><br />
</ul><br />
<br />
* '''GRASS GIS 7 example configuration''' (which can/should be adjusted according to specific needs):<br />
<ul><br />
<source lang="bash"><br />
CFLAGS="-O2 -Wall" LDFLAGS="-s" ./configure \<br />
--enable-largefile=yes \<br />
--with-nls \<br />
--with-cxx \<br />
--with-readline \<br />
--with-proj-share=/usr/local/share/proj/ \<br />
--with-geos=/usr/local/bin/geos-config \<br />
--with-wxwidgets \<br />
--with-cairo \<br />
--with-opengl-libs=/usr/include/GL \<br />
--with-freetype=yes --with-freetype-includes="/usr/include/freetype2/" \<br />
--with-postgres=yes --with-postgres-includes="/usr/include/postgresql" \<br />
--with-sqlite=yes \<br />
--with-mysql=yes --with-mysql-includes="/usr/include/mysql" \<br />
--with-odbc=no \<br />
--with-liblas=yes --with-liblas-config=/usr/bin/liblas-config<br />
</source><br />
</ul><br />
<ul><br />
'''Note''', the above configuration uses the <code>Proj4</code> and <code>GEOS</code> packages compiled from the source. In the case that pre-compiled versions from the repository are required, remove the above corresponding lines to use the "defaults", i.e. (note the backslashe at the end of each line)<br />
<source lang="bash"><br />
--with-proj-share=/usr/share/proj \<br />
--with-geos=/usr/bin/geos-config \<br />
</source><br />
'''Note 2''', if compiling with liblas, you will want liblas compiled with laszip support. liblas will look for laszip includes in /usr/local/include/laszip by default. Creating the laszip directory in /usr/local/include and making a soft link. ln -s /usr/local/include/lasz*.hpp /usr/local/include/laszip and ln -s /usr/local/include/lasunz*.hpp /usr/local/include/laszip should allow liblas to compile with laszip support <br />
</ul><br />
<br />
* compile & install <source lang="bash"><br />
make -j2 && sudo make install && sudo ldconfig<br />
</source><br />
<br />
<ul> or <source lang="bash"><br />
make -j2 && sudo checkinstall && sudo ldconfig<br />
</source><br />
</ul><br />
<br />
For subsequent updates execute (not need for the first time):<br />
<source lang="bash"><br />
svn up<br />
make -j2 && sudo make install && sudo ldconfig<br />
</source><br />
<br />
Sometimes, it is required to clean previous configuration and compilation:<br />
<source lang="bash"><br />
make distclean<br />
svn up<br />
./configure ... # (use the configure command above)<br />
make -j2 && sudo make install && sudo ldconfig<br />
</source><br />
<br />
=== GDAL-GRASS-Plugin ===<br />
<br />
* get the plugin from [http://download.osgeo.org/gdal/ OSGeo's Download Server]: "gdal-grass-X.Y.Z.tar.gz" using <source lang="bash" enclose="none">wget</source><br />
<ul><source lang="bash"><br />
# update version number accordingly!<br />
wget http://download.osgeo.org/gdal/3.2.3/gdal-grass-3.2.3.tar.gz<br />
tar xvzf gdal-grass-3.2.3.tar.gz<br />
cd gdal-grass-3.2.3<br />
</source></ul><br />
<br />
* create <source lang="bash" enclose="none">/etc/ld.so.conf.d/grass.conf</source> or add in <source lang="bash" enclose="none">/etc/ld.so.conf</source> the GRASS library path: <br />
<ul><source lang="bash"><br />
# GRASS 7.8 library path (adapt as needed)<br />
/usr/local/src/releasebranch_7_8/lib<br />
<br />
# GRASS 7 (development version) library path (adapt as needed)<br />
/usr/local/src/grass_master/lib<br />
</source></ul><br />
<br />
* optionally, clean previous configurations/compilations<source lang="bash"><br />
make distclean</source><br />
<br />
* configure -- point to GRASS installation/binaries<br />
<ul><source lang="bash"> ./configure \<br />
--prefix=/usr/local \<br />
--with-gdal=/usr/local/bin/gdal-config \<br />
--with-grass=/usr/local/grass-7.8.git/ \<br />
--with-autoload="/usr/local/lib64/gdalplugins/" \<br />
--with-ld-shared="g++ -shared"</source></ul><br />
<ul><br />
* for GRASS 7.6, replace with <source lang="bash" enclose="none"> --with-grass=/usr/local/grass-7.6.3/</source><br />
* for GRASS 7.x...<br />
</ul><br />
<br />
* compile & install using checkinstall<source lang="bash"><br />
make -j2 && sudo checkinstall</source><br />
<br />
= Post compilation/installation control =<br />
<br />
* For a recommended quick-check read the [http://grass.osgeo.org/wiki/Compile_and_install_GRASS_and_QGIS_with_GDAL/OGR_Plugin#Troubleshooting Troubleshooting] section at [http://grass.osgeo.org/wiki/Compile_and_install_GDAL-GRASS_plugin Compile_and_install_GDAL-GRASS_plugin]<br />
<br />
* in case of errors in future compilation attempts, remember to remove program binaries and files created with the "configuration" from previous compilations with<br />
make distclean<br />
<br />
* another common mistake is compiling a module against some GRASS version and then try to run it through another GRASS version. The solution is to recompile the affected module or, in case there are multiple GRASS installations, set up properly LD_LIBRARY_PATH paths.<br />
<br />
<br />
= Removal of GRASS =<br />
<br />
<br />
To get rid of a GRASS binaries installation, delete (update version numbers accordingly)<br />
* <source lang="bash" enclose="none">/usr/local/grass-7.8.1.dev</source> (directory, binaries location)<br />
* <source lang="bash" enclose="none">/usr/local/bin/grass78</source> (file)<br />
* <source lang="bash" enclose="none">/home/username/.grassrc7</source> (file)<br />
<br />
<br />
If wanted, delete also the complete source code:<br />
* <source lang="bash" enclose="none">/usr/local/src/grass78_release</source> (directory, source code location)<br />
<br />
<br />
To remove <code>grass</code> (or any other package) which was installed by <source lang="bash" enclose="none">checkinstall</source>, use <source lang="bash" enclose="none">dpkg</source>, e.g.<source lang="bash"><br />
sudo dpkg -r grass78 # package name defined at installation is important</source><br />
<br />
= Packaging of GRASS =<br />
<br />
* See https://salsa.debian.org/debian-gis-team/grass/tree/master/debian for directions on rolling your own packages.<br />
<br />
For details about the auto-nightly-builds and after-market supplied packages from UbuntuGIS, please refer to the [[Ubuntu Packaging]] wiki page.<br />
<br />
== See also ==<br />
<br />
* Docker: https://grass.osgeo.org/download/software/docker-images/<br />
* [[Ubuntu Packaging]]<br />
* [[GRASS in Debian]]<br />
<br />
= Archived Notes =<br />
<br />
Notes that concern the configuration and compilation of GRASS GIS and its dependencies for older versions of Ubuntu-Linux.<br />
<br />
== Ubuntu 7.10 64-bit ==<br />
<br />
* Compiling latest GRASS source code on a 64-bit machine (with an ATI graphic card) under Ubuntu 7.10 64-bit with support for: 64-bit, SQLite, OpenGL, PYTHON, FFMPEG<br />
(Based on "Ubuntu 6.06 LTS - GRASS 6.1 Compilation Script" by David Finlayson)<br />
''Assuming it is the first time attempting to compile GRASS' source code & installing SVN, PROJ, GDAL/OGR''<br />
<br />
'''Preparation'''<br />
sudo apt-get update && sudo apt-get upgrade<br />
<br />
* install dependencies for compiling (in general) and dependencies for GRASS: PROJ, GDAL/OGR<br />
sudo apt-get install grass build-essential flex bison libncurses5-dev zlib1g-dev \<br />
libgdal1-dev libtiff4-dev libgcc1 libpng12-dev tcl8.4-dev tk8.4-dev fftw3-dev \<br />
libfreetype6-dev libavcodec-dev libxmu-dev gdal-bin libreadline5 libreadline5-dev \<br />
make python-dev python-wxversion<br />
<br />
* install SQLite<br />
sudo apt-get install sqlite3 libsqlite3-dev<br />
<br />
* install SVN<br />
sudo apt-get install subversion<br />
<br />
* create a directory as a simple user where source code(s) are going to be stored (in our example we use a directory called '''src''' under '''/usr/local''')<br />
<br />
sudo mkdir /usr/local/src<br />
<br />
* grant rwx (read-write-execute) permissions for our userid/ groupid on the directory (replace words userid and groupid with real userid):<br />
sudo chown ''userid'':''groupid'' /usr/local/src<br />
<br />
sudo chmod ug+rwx /usr/local/src<br />
<br />
* download latest source code from GRASS SVN repository in a directory on the system (e.g. /usr/local/src)<br />
svn checkout https://svn.osgeo.org/grass/grass/trunk grass_trunk<br />
<br />
* Above command places GRASS' source code in '''/usr/local/src/grass_trunk'''. In case of a subsequent update use the command: '''svn up''' from within the grass_trunk directory<br />
<br />
----<br />
'''Before''' attempting to compile GRASS, READ section (C) in the '''INSTALL''' file located in the main directory of GRASS source code entitled:<br />
'''(C) COMPILATION NOTES for 64bit platforms'''<br />
----<br />
<br />
* installing FFTW3 if not already on system<br />
sudo apt-get install fftw3 fftw3-dev<br />
<br />
'''FFMPEG'''<br />
<br />
Note: Back in Ubuntu 7.10, installing ffmpeg through the repositories wouldn't work with grass. The following steps were successfully used.<br />
<br />
* install FFMPEG (information taken from: http://stream0.org/2008/01/install-ffmpeg-on-ubuntu-gutsy.html)<br />
* download source code with svn<br />
svn checkout svn://svn.mplayerhq.hu/ffmpeg/trunk ffmpeg<br />
<br />
* install dependencies<br />
sudo apt-get install liblame-dev libfaad2-dev libfaac-dev libxvidcore4-dev \<br />
liba52-0.7.4 liba52-0.7.4-dev libx264-dev libdts-dev checkinstall \<br />
build-essential subversion<br />
<br />
* guide to ffmpeg directory<br />
cd ffmpeg<br />
<br />
if necessary: '''make distclean''' before configuration (look at notes below)<br />
<br />
* configuration ('''note:''' the configuration parameter "'''--enable-pp'''" does not work anymore)<br />
# configure FFMPEG<br />
./configure --enable-gpl --enable-libvorbis --enable-libtheora \<br />
--enable-liba52 --enable-libdc1394 --enable-libgsm \<br />
--enable-libmp3lame --enable-libfaad --enable-libfaac \<br />
--enable-libxvid --enable-libx264 \<br />
--enable-shared<br />
<br />
* compilation<br />
make<br />
<br />
* installation on /usr/local/bin -- important to remember when configuring GRASS' source code for compilation<br />
sudo checkinstall<br />
<br />
'''Go for GRASS!'''<br />
* in our example we used the /usr/local/src directory to store GRASS' source code, so:<br />
cd /usr/local/src/grass_trunk<br />
<br />
* configuration<br />
CFLAGS="-g -Wall" ./configure --enable-64bit \<br />
--with-libs=/usr/lib64 --with-cxx --with-freetype=yes \<br />
--with-postgres=no --with-sqlite=yes --enable-largefile=yes \<br />
--with-tcltk-includes=/usr/include/tcl8.4 \<br />
--with-freetype-includes=/usr/include/freetype2 \<br />
--with-opengl-libs=/usr/include/GL --with-readline \<br />
--with-python=yes --with-ffmpeg=yes \<br />
--with-ffmpeg-includes=/usr/local/include/ffmpeg<br />
<br />
*if OpenGL fails then maybe it is necessary to link '''glxATI.h''' with '''glx.h''' and re-run the configuration<br />
<br />
cd /usr/include/GL<br />
<br />
sudo ln glxATI.h glx.h<br />
<br />
* compilation<br />
make<br />
<br />
* compilation is expected to end with a statement similar to the following:<br />
<br />
Started compilation: Wed Feb 27 00:24:36 CET 2008<br />
--<br />
Errors in:<br />
No errors detected.<br />
<br />
* installation<br />
sudo checkinstall<br />
<br />
* launch 64-bit GRASS.6.4.svn<br />
grass64<br />
<br />
'''Notes'''<br />
* in case of errors in future compilation attempts, remember to remove program binaries with<br />
make clean<br />
* and the files created with the "configuration" from previous compilations with<br />
make distclean<br />
<br />
== Ubuntu 6.06, 7.10 ==<br />
<br />
* [http://david.p.finlayson.googlepages.com/makegrass.sh makegrass.sh] is script designed to automate most of the download, configuration and compilation of GRASS 6.x-CVS<br />
** it is advised use [https://help.ubuntu.com/community/CheckInstall checkinstall] (''sudo apt-get install checkinstall'') instead of ''make install'' to keep track of installed software <br />
** Think twice before using this script. Some users experienced problems such as disabled XGL etc.<br />
* [[User:Steko/Automated_CVS_compiling|Here]] is another of these scripts, it's homemade so probably you'll find the above more useful for production sites.<br />
<br />
<br />
[[Category: Compilation]]<br />
[[Category: Installation]]<br />
[[Category: Ubuntu]]<br />
[[Category: FAQ]]</div>Veroandreohttps://grasswiki.osgeo.org/w/index.php?title=Compile_and_Install_Ubuntu&diff=27429Compile and Install Ubuntu2024-03-07T19:45:24Z<p>Veroandreo: apt instead of apt-get, remove striked out text</p>
<hr />
<div><div class="boilerplate metadata" id="attention" style="-moz-border-radius:30px; border: 1px double #35824B; margin-bottom: 1.5em; padding: 1em; background-color: #f9f9f9;"><br />
<p style="font-size: 150%; text-align: left;"><span style="color:#35824B">'''Attention'''</span>&nbsp;</p><span style="color:#333333">'''The following instructions describe the compilation and installation of GRASS GIS and its required dependencies completely from the source on Ubuntu based systems. Please, prefer pre-compiled packages over the manual way described below unless you know ''what'' and ''how'', you want to learn and help testing.'''</span><br />
</div><br />
<br />
== Quick instructions ==<br />
<br />
These instructions should work fine on Ubuntu distributions:<br />
<br />
=== Install geospatial dependencies ===<br />
<br />
1. Install some dependencies (PROJ, GEOS, GDAL libraries) and the compiler tools <br /><br />
(note: you need Python 3!)<br />
<br />
<source lang="bash"><br />
# be sure to have an updated system<br />
sudo apt update && sudo apt upgrade -y<br />
<br />
# install PROJ<br />
sudo apt install libproj-dev proj-data proj-bin unzip -y<br />
</source><br />
<br />
<source lang="bash"><br />
# optionally, install (selected) datum grid files<br />
sudo apt-get install proj-data<br />
<br />
# install GEOS<br />
sudo apt install libgeos-dev -y<br />
<br />
# install GDAL<br />
sudo apt install libgdal-dev python3-gdal gdal-bin -y<br />
<br />
# install PDAL (optional)<br />
sudo apt install libpdal-dev pdal libpdal-plugin-python -y<br />
<br />
# recommended to give Python3 precedence over Python2 (which is end-of-life since 2019)<br />
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3 1<br />
</source><br />
<br />
Install compiler stuff and further dependencies.<br />
Note: this is a single command, please copy-paste it entirely into the terminal:<br />
<br />
=== Install further compilation dependencies (Ubuntu 19.04) ===<br />
<br />
For Ubuntu 19.04<br />
<source lang="bash"><br />
sudo apt-get install \<br />
build-essential \<br />
flex make bison gcc libgcc1 g++ ccache \<br />
python3 python3-dev \<br />
python3-opengl \<br />
python-wxversion python-wxtools python-wxgtk3.0 python3-wxgtk4.0 \<br />
python3-dateutil libgsl-dev python3-numpy \<br />
wx3.0-headers wx-common libwxgtk3.0-dev \<br />
libwxbase3.0-dev \<br />
libncurses5-dev \<br />
libbz2-dev \<br />
zlib1g-dev gettext \<br />
libtiff5-dev libpnglite-dev \<br />
libcairo2 libcairo2-dev \<br />
sqlite3 libsqlite3-dev \<br />
libpq-dev \<br />
libreadline6-dev libfreetype6-dev \<br />
libfftw3-3 libfftw3-dev \<br />
libboost-thread-dev libboost-program-options-dev liblas-c-dev \<br />
subversion libzstd-dev \<br />
checkinstall \<br />
libglu1-mesa-dev libxmu-dev \<br />
ghostscript wget -y<br />
</source><br />
<br />
This are optional video codec libraries for NVIZ video output for Ubuntu 19.04:<br />
<source lang="bash"><br />
sudo apt-get install \<br />
libav-tools libavutil-dev ffmpeg2theora \<br />
libffmpegthumbnailer-dev \<br />
libavcodec-dev \<br />
libxmu-dev \<br />
libavformat-dev libswscale-dev <br />
</source><br />
<br />
=== Install further compilation dependencies (Ubuntu 20.04) ===<br />
<br />
For Ubuntu 20.04:<br />
<source lang="bash"><br />
sudo apt-get install \<br />
build-essential \<br />
flex make bison gcc libgcc1 g++ ccache \<br />
python3 python3-dev \<br />
python3-opengl python3-wxgtk4.0 \<br />
python3-dateutil libgsl-dev python3-numpy \<br />
wx3.0-headers wx-common libwxgtk3.0-gtk3-dev \<br />
libwxbase3.0-dev \<br />
libncurses5-dev \<br />
libbz2-dev \<br />
zlib1g-dev gettext \<br />
libtiff5-dev libpnglite-dev \<br />
libcairo2 libcairo2-dev \<br />
sqlite3 libsqlite3-dev \<br />
libpq-dev \<br />
libreadline6-dev libfreetype6-dev \<br />
libfftw3-3 libfftw3-dev \<br />
libboost-thread-dev libboost-program-options-dev libpdal-dev\<br />
subversion libzstd-dev \<br />
checkinstall \<br />
libglu1-mesa-dev libxmu-dev \<br />
ghostscript wget -y<br />
</source><br />
<br />
For NVIZ on Ubuntu 20.04:<br />
<source lang="bash"><br />
sudo apt-get install \<br />
ffmpeg libavutil-dev ffmpeg2theora \<br />
libffmpegthumbnailer-dev \<br />
libavcodec-dev \<br />
libxmu-dev \<br />
libavformat-dev libswscale-dev<br />
</source><br />
<br />
=== Install further compilation dependencies (Ubuntu 22.04) ===<br />
<br />
For Ubuntu 22.04:<br />
<source lang="bash"><br />
sudo apt-get install \<br />
build-essential \<br />
flex make bison gcc libgcc1 g++ ccache \<br />
python3 python3-dev \<br />
python3-opengl python3-wxgtk4.0 \<br />
python3-dateutil libgsl-dev python3-numpy \<br />
wx3.0-headers wx-common libwxgtk3.0-gtk3-dev \<br />
libwxbase3.0-dev \<br />
libncurses5-dev \<br />
libbz2-dev \<br />
zlib1g-dev gettext \<br />
libtiff5-dev libpnglite-dev \<br />
libcairo2 libcairo2-dev \<br />
sqlite3 libsqlite3-dev \<br />
libpdal-dev libpq-dev \<br />
libreadline-dev libfreetype6-dev \<br />
libfftw3-3 libfftw3-dev \<br />
libboost-thread-dev libboost-program-options-dev \<br />
subversion libzstd-dev \<br />
checkinstall \<br />
libglu1-mesa-dev libxmu-dev \<br />
ghostscript wget -y<br />
</source><br />
<br />
For NVIZ on Ubuntu 22.04:<br />
<source lang="bash"><br />
sudo apt-get install \<br />
ffmpeg libavutil-dev ffmpeg2theora \<br />
libffmpegthumbnailer-dev \<br />
libavcodec-dev \<br />
libxmu-dev \<br />
libavformat-dev libswscale-dev<br />
</source><br />
<br />
Update wxpython:<br />
<br />
<source lang="bash"><br />
pip3 install -U -f https://extras.wxpython.org/wxPython4/extras/linux/gtk3/ubuntu-22.04 wxPython<br />
</source><br />
<br />
=== Source code download ===<br />
Now we have all "ingredients" readily installed on our system.<br />
<br />
'''Source code download''':<br />
<br />
There a two ways of getting the source code: either use a) the weekly snapshot (cannot be updated, or b) the source code from the GitHub repository (you can update your local copy easily in future):<br />
<br />
'''a) Download of the weekly source code snapshot (not recommended):'''<br />
<source lang="bash"><br />
# download latest GRASS GIS 8.x stable release source code:<br />
mkdir $HOME/src/<br />
cd $HOME/src/<br />
wget https://grass.osgeo.org/grass82/source/snapshot/grass-8.2.git_src_snapshot_latest.tar.gz<br />
<br />
# Unpack source code package and remove tarball archive:<br />
tar xvfz grass-8.2.git_src_snapshot_latest.tar.gz<br />
rm -f grass-8.2.git_src_snapshot_latest.tar.gz <br />
<br />
# rename source code directory (yes, with the questionmarks!)<br />
mv grass-8.2.git_src_snapshot_20??_??_?? grass-8.2.latest<br />
cd grass-8.2.latest/<br />
</source><br />
<br />
'''b) Download of the current development version from GitHub (adopt the path below accordingly)'''<br />
<source lang="bash"><br />
sudo apt-get install git<br />
git clone https://github.com/OSGeo/grass.git grass-8.2.latest.git<br />
cd grass-8.2.latest.git/<br />
git checkout releasebranch_8_2<br />
</source><br />
<br />
=== Compilation ===<br />
Now we can '''compile''' the source code in order to generate the GRASS GIS binaries:<br />
<br />
For Ubuntu 19.04<br />
<source lang="bash"><br />
# "configure" source code for local machine (checks for CPU type etc):<br />
MYCFLAGS='-O2 -fPIC -fno-common -fexceptions -std=gnu99 -fstack-protector -m64'<br />
#MYCXXFLAGS=''<br />
MYLDFLAGS='-Wl,--no-undefined -Wl,-z,now'<br />
<br />
LDFLAGS="$MYLDFLAGS" CFLAGS="$MYCFLAGS" CXXFLAGS="$MYCXXFLAGS" ./configure \<br />
--with-cxx \<br />
--enable-largefile \<br />
--with-proj --with-proj-share=/usr/share/proj \<br />
--with-gdal=/usr/bin/gdal-config \<br />
--with-python \<br />
--with-geos \<br />
--with-sqlite \<br />
--with-nls \<br />
--with-zstd \<br />
--with-liblas \<br />
--with-pdal \<br />
--with-cairo --with-cairo-ldflags=-lfontconfig \<br />
--with-freetype=yes --with-freetype-includes="/usr/include/freetype2/" \<br />
--with-wxwidgets \<br />
--with-fftw \<br />
--with-motif \<br />
--with-opengl-libs=/usr/include/GL \<br />
--with-postgres=yes --with-postgres-includes="/usr/include/postgresql" \<br />
--without-netcdf \<br />
--without-mysql \<br />
--without-odbc \<br />
--without-openmp \<br />
--without-ffmpeg<br />
</source><br />
<br />
Ubuntu 20.04/22.04 (without liblas but with PDAL):<br />
<source lang="bash"><br />
# "configure" source code for local machine (checks for CPU type etc):<br />
MYCFLAGS='-O2 -fPIC -fno-common -fexceptions -std=gnu99 -fstack-protector -m64'<br />
#MYCXXFLAGS=''<br />
MYLDFLAGS='-Wl,--no-undefined -Wl,-z,now'<br />
<br />
LDFLAGS="$MYLDFLAGS" CFLAGS="$MYCFLAGS" CXXFLAGS="$MYCXXFLAGS" ./configure \<br />
--with-cxx \<br />
--enable-largefile \<br />
--with-proj --with-proj-share=/usr/share/proj \<br />
--with-gdal=/usr/bin/gdal-config \<br />
--with-python \<br />
--with-geos \<br />
--with-sqlite \<br />
--with-nls \<br />
--with-zstd \<br />
--with-pdal \<br />
--with-cairo --with-cairo-ldflags=-lfontconfig \<br />
--with-freetype=yes --with-freetype-includes="/usr/include/freetype2/" \<br />
--with-wxwidgets \<br />
--with-fftw \<br />
--with-motif \<br />
--with-opengl-libs=/usr/include/GL \<br />
--with-postgres=yes --with-postgres-includes="/usr/include/postgresql" \<br />
--without-netcdf \<br />
--without-mysql \<br />
--without-odbc \<br />
--without-openmp \<br />
--without-ffmpeg<br />
</source><br />
<br />
Now compile the source code (this will take some time as it generates binary code from the source code):<br />
<source lang="bash"><br />
# note: the more CPUs you have, the higher the -j number may be set to<br />
# here: build using 4 CPU cores<br />
make -j4<br />
</source><br />
<br />
=== Installation ===<br />
<br />
Install resulting GRASS GIS binaries into /usr/local/:<br />
<source lang="bash"><br />
sudo make install<br />
</source><br />
<br />
Start GRASS GIS in the terminal:<br />
<source lang="bash"><br />
grass<br />
</source><br />
<br />
'''Done & enjoy!'''<br />
<br />
== Hints ==<br />
<br />
* Usually, the installation of compiled code is done by using the <source lang="bash" enclose="none">make</source> tool. Alternatively, this can be done by using the ''checkinstall'' tool (i.e., <source lang="bash" enclose="none">sudo checkinstall</source> instead of <source lang="bash" enclose="none">sudo make install</source>) which eases off removal of packages. If ''checkinstall'' fails to deliver, please note some related bugs: [https://bugs.launchpad.net/ubuntu/+source/checkinstall/+bug/78455 78455] and [https://bugs.launchpad.net/ubuntu/+source/checkinstall/+bug/599163 599163]. Useful information on using ''checkinstall'': [https://help.ubuntu.com/community/CompilingEasyHowTo Compiling things on Ubuntu the Easy Way].<br />
<br />
* In multi-core processors, the compilation performance can be boosted by using ''-j'' switches (e.g. <source lang="bash" enclose="none">make -j2</source> or <source lang="bash" enclose="none">make -j3</source> or even <source lang="bash" enclose="none">make -j4</source>) which specify the number of jobs (commands) to run simultaneously.<br />
<br />
== Pre-compiled packages and backports ==<br />
<br />
'''Pre-compiled packages and backports''' are available from [https://wiki.ubuntu.com/UbuntuGIS UbuntuGIS] via their [https://launchpad.net/~ubuntugis/+archive/ppa/ ppa.launchpad stable] and [https://launchpad.net/~ubuntugis/+archive/ubuntu/ubuntugis-unstable ppa.launchpad unstable] repositories. '''This is by far the simplest and fastest solution. Please prefer it over the manual way of compiling source code yourself as described below.'''<br />
<br />
Version overview:<br />
* jammy (22.04): 8.2<br />
* focal (20.04 LTS): 8.2<br />
* bionic (18.04 LTS): 7.8<br />
* xenial (16.04 LTS): 7.6<br />
* trusty (14.04 LTS): 7.4<br />
<br />
a) Daily ready-to-install GRASS GIS builds of the 7.x release branch and master are available from ''ppa:grass/grass-devel'':<br />
<br />
<source lang=bash><br />
sudo add-apt-repository ppa:ubuntugis/ubuntugis-unstable<br />
sudo add-apt-repository ppa:grass/grass-devel<br />
</source><br />
<br />
b) Latest stable version of GRASS 7.x is available from ''ppa:grass/grass-stable'':<br />
<source lang=bash><br />
sudo add-apt-repository ppa:ubuntugis/ppa<br />
sudo add-apt-repository ppa:grass/grass-stable<br />
sudo apt-get update<br />
sudo apt-get install grass78<br />
</source><br />
<br />
== Dependencies ==<br />
<br />
=== Current stable Ubuntu version ===<br />
First, update the system from the repositories<source lang="bash"><br />
sudo apt-get update && sudo apt-get upgrade<br />
</source><br />
<br />
Then, install ''SQLite'', ''SVN'' and ''dependencies'' for compiling PROJ, GEOS, GDAL/OGR, GRASS, GDAL-GRASS-PLUGIN (some additional packages may be required in this case); the following action will also install various dependencies (listed in the command line as <source lang="bash" enclose="none">The following extra packages will be installed:</source>...):<br/><br />
<br />
The following dependencies concern [http://releases.ubuntu.com/xenial/ Ubuntu Xenial Xerus (16.04 LTS)]<br />
<br />
<source lang="bash"><br />
# this is a single command, please copy-paste it entirely into the terminal:<br />
sudo apt-get install \<br />
build-essential \<br />
flex make bison gcc libgcc1 g++ cmake ccache \<br />
python python-dev \<br />
python-opengl \<br />
python-wxversion python-wxtools python-wxgtk3.0 \<br />
python-dateutil libgsl-dev python-numpy \<br />
wx3.0-headers wx-common libwxgtk3.0-dev \<br />
libwxbase3.0-dev \<br />
libncurses5-dev \<br />
zlib1g-dev gettext \<br />
libtiff5-dev libpnglite-dev \<br />
libcairo2 libcairo2-dev \<br />
sqlite3 libsqlite3-dev \<br />
libpq-dev \<br />
libreadline6 libreadline6-dev libfreetype6-dev \<br />
libfftw3-3 libfftw3-dev \<br />
libboost-thread-dev libboost-program-options-dev liblas-c-dev \<br />
resolvconf \<br />
libjasper-dev \<br />
subversion \<br />
libav-tools libavutil-dev ffmpeg2theora \<br />
libffmpegthumbnailer-dev \<br />
libavcodec-dev \<br />
libxmu-dev \<br />
libavformat-dev libswscale-dev \<br />
checkinstall \<br />
libglu1-mesa-dev libxmu-dev \<br />
ghostscript<br />
</source><br />
<br />
The following dependencies concern [http://releases.ubuntu.com/trusty/ Ubuntu Trusty Tahr (14.04 LTS)]<br />
<br />
<source lang="bash"><br />
# this is a single command, please copy-paste it entirely into the terminal:<br />
sudo apt-get install \<br />
build-essential \<br />
flex make bison gcc libgcc1 g++ \<br />
python python-dev \<br />
python-dateutil libgsl0-dev python-numpy \<br />
zlib1g-dev gettext \<br />
libtiff-dev libpnglite-dev \<br />
sqlite3 libsqlite3-dev \<br />
libboost-thread-dev libboost-program-options-dev liblas-c-dev \<br />
resolvconf \<br />
subversion \<br />
checkinstall \<br />
cmake ccache \<br />
python-opengl \<br />
python-wxversion python-wxtools python-wxgtk2.8 \<br />
wx2.8-headers wx-common libwxgtk2.8-dev libwxgtk2.8-dbg \<br />
libwxbase2.8-dev libwxbase2.8-dbg \<br />
libncurses5-dev \<br />
libcairo2 libcairo2-dev \<br />
libpq-dev \<br />
libreadline6 libreadline6-dev libfreetype6-dev \<br />
libfftw3-3 libfftw3-dev \<br />
libjasper-dev \<br />
libav-tools libavutil-dev ffmpeg2theora \<br />
libffmpegthumbnailer-dev \<br />
libavcodec-dev \<br />
libxmu-dev \<br />
libavformat-dev libswscale-dev \<br />
libglu1-mesa-dev libxmu-dev \<br />
ghostscript</source><br />
<br />
<br />
* See the additional packages bellow and in other sections and install them. Note that some of them are [http://grass.osgeo.org/grass70/source/REQUIREMENTS.html required], namely PROJ.4, GEOS and GDAL. If you don't have special requirements, it is usually enough just to install PROJ.4, GEOS and GDAL from repository (rather then compile them manually).<br />
<br />
* for mysql support, <source lang="bash" enclose="none">libmysqlclient-dev</source> is required<br />
<source lang="bash"><br />
sudo apt-get install libmysqlclient-dev<br />
</source><br />
<br />
* for netcdf support, <source lang="bash" enclose="none">netcdf-bin</source> and <source lang="bash" enclose="none">libnetcdf-dev</source> is required<br />
<source lang="bash"><br />
sudo apt-get install netcdf-bin libnetcdf-dev<br />
</source><br />
<br />
* for {{AddonCmd|i.spec.unmix}} Addon support, install LAPACK and BLAS:<br />
<source lang="bash"><br />
sudo apt-get install libatlas-dev libblas-dev liblapack-dev<br />
</source><br />
<br />
* create a directory as a simple user where all source code is going to be stored -- in this example, a directory named <source lang="bash" enclose="none">src</source> under <source lang="bash" enclose="none">/usr/local</source> is created <source lang="bash"><br />
sudo mkdir /usr/local/src<br />
</source><br />
<br />
* take over directories ownerships ('''replace''' below the terms ''userid'' and ''groupid'' with a real <source lang="bash" enclose="none">userid</source>): <source lang="bash"><br />
sudo chown userid:groupid /usr/local/src</source><br />
<br />
* similarly, grant <source lang="bash" enclose="none">rwx</source> (read-write-execute) permissions for our ''userid'' and ''groupid'' onto the <source lang="bash" enclose="none">src</source> directory: <source lang="bash"><br />
sudo chmod ug+rwx /usr/local/src</source><br />
<br />
=== Earlier Ubuntu versions ===<br />
<br />
For [http://old-releases.ubuntu.com/releases/ earlier Ubuntu versions], '''watch out for dependency differences!''' Modify the dependency list given above as instructed below.<br />
<br />
* for [http://releases.ubuntu.com/raring/ Ubuntu Raring Ringtail (13.04]), change the following dependencies:<br />
** <source lang="bash" enclose="none">libav-tools libavutil-dev --> ffmpeg</source> <br />
** <source lang="bash" enclose="none"> --> lesstif2-dev</source><br />
<br />
* for [http://releases.ubuntu.com/precise/ Ubuntu Precise Pangolin (12.04)], change the following dependencies:<br />
** <source lang="bash" enclose="none">libpnglite-dev --> libpngwriter-dev</source><br />
** <source lang="bash" enclose="none">libtiff5-dev --> libtiff4-dev</source><br />
<br />
* for [http://old-releases.ubuntu.com/releases/maverick/ Ubuntu Maverick Meerkat (10.10)] or later, change the following dependencies:<br />
** <source lang="bash" enclose="none">libpngwriter-dev --> libpngwriter0-dev</source><br />
** <source lang="bash" enclose="none">libcairo-dev --> libcairo2-dev</source><br />
** <source lang="bash" enclose="none">fftw3 --> libfftw3-3</source><br />
** <source lang="bash" enclose="none">fftw3-dev --> libfftw3-dev</source><br />
<br />
* for [http://old-releases.ubuntu.com/releases/lucid/ Ubuntu Lucid Lynx (10.04)] or later, also install: <source lang="bash">sudo apt-get install libhdf4-alt-dev libhdf4-0-alt</source><br />
<br />
* for [http://old-releases.ubuntu.com/releases/ earlier Ubuntu versions], also install: <source lang="bash"> sudo apt-get install libhdf4g-dev libhdf4g-run</source><br />
<br />
== Using pre-compiled dev Packages for PROJ.4, GEOS and GDAL ==<br />
<br />
=== PROJ.4 ===<br />
<br />
Install the <source lang="bash" enclose="none">dev</source> package:<br />
<br />
<source lang="bash"><br />
sudo apt-get install libproj-dev proj-data proj-bin<br />
</source><br />
<br />
* In the call to <source lang="bash" enclose="none">./configure</source> for [[#GRASS|GRASS]], replace <source lang="bash" enclose="none">--with-proj-share=/usr/local/share/proj/</source> by <source lang="bash" enclose="none">--with-proj-share=/usr/share/proj/</source><br />
<br />
=== GEOS ===<br />
<br />
Install the <source lang="bash" enclose="none">dev</source> package:<br />
<br />
<source lang="bash"><br />
# probably you also need to additionally install "libgeos-c1v5"<br />
sudo apt-get install libgeos-dev<br />
</source><br />
<br />
* In the call to <source lang="bash" enclose="none">./configure</source> for [[#GRASS|GRASS]], replace <source lang="bash" enclose="none">--with-geos=/usr/local/bin/geos-config</source> by <source lang="bash" enclose="none">--with-geos=/usr/bin/geos-config</source><br />
<br />
=== GDAL ===<br />
<br />
Install the <source lang="bash" enclose="none">dev</source> package (possibly without support for datumgrid):<br />
<br />
<source lang="bash"><br />
sudo apt-get install libgdal-dev<br />
</source><br />
<br />
For support of WMS in wxGUI install Python GDAL bindings and GDAL executables:<br />
<source lang="bash"><br />
sudo apt-get install python-gdal gdal-bin<br />
</source><br />
<br />
* Install also the required extra packages (note the message: <source lang="bash" enclose="none">The following extra packages will be installed:</source>)<br />
* Look out for packages to be removed by this operation -- this is most likely caused by incompatible package versions. Fix these problems in advance using commands like the following: <source lang="bash"><br />
sudo apt-get install <package>=<required.version></source><br />
<br />
=== GRASS-GIS ===<br />
<br />
[[Compile_and_Install_Ubuntu#GRASS_GIS|Jump to sub-section GRASS-GIS below]]<br />
<br />
== Using pre-compiled dev Packages for PROJ.4, GEOS and GDAL from GIS.lab PPA==<br />
<br />
Ivan Mincik has made all required packages available in his [https://launchpad.net/~imincik/+archive/ubuntu/gis PPA]:<br />
<br />
<source lang="bash"><br />
sudo add-apt-repository ppa:imincik/gis<br />
sudo apt-get install libproj-dev libgdal-dev python-gdal libgeos-dev<br />
</source><br />
<br />
Now you can either also install GRASS GIS 7 from there or compile it yourself (see [[Compile_and_Install_Ubuntu#GRASS_GIS|Jump to sub-section GRASS-GIS below]])<br />
<br />
== Compile from source ==<br />
<br />
<br />
=== PROJ4 ===<br />
<br />
* within the directory <source lang="bash" enclose="none">/usr/local/src</source> (create it if it does not exist) checkout <source lang="bash" enclose="none">proj</source> from its Subversion repository: <source lang="bash"><br />
svn co http://svn.osgeo.org/metacrs/proj/branches/4.8/proj/<br />
</source><br />
<br />
* get [http://download.osgeo.org/proj/proj-datumgrid-1.5.zip '''proj-datumgrid-1.5.zip'''] from [http://trac.osgeo.org/proj proj' trac] and move it under <source lang="bash" enclose="none">proj/nad</source><br />
<ul><source lang="bash"><br />
wget http://download.osgeo.org/proj/proj-datumgrid-1.5.zip<br />
mv proj-datumgrid-1.5.zip /usr/local/src/proj/nad<br />
cd /usr/local/src/proj/nad<br />
</source><br />
</ul><br />
<br />
* decompress it <source lang="bash"><br />
unzip proj-datumgrid-1.5.zip<br />
</source><br />
<br />
* go back to the <source lang="bash" enclose="none">proj</source> directory <source lang="bash"><br />
cd /usr/local/src/proj<br />
</source><br />
<br />
* if required, clean previous configuration & compilation <source lang="bash"><br />
make distclean<br />
</source><br />
<br />
* simple configure, compile and install <source lang="bash"><br />
./configure && make && sudo make install<br />
</source><br />
<ul> or <source lang="bash"><br />
./configure && make -j2 && sudo checkinstall<br />
</source><br />
</ul><br />
<br />
* ensure that <source lang="bash" enclose="none">/usr/local/lib</source> is added to <source lang="bash" enclose="none">/etc/ld.so.conf</source> and afterwards run <source lang="bash"><br />
sudo ldconfig<br />
</source><br />
<br />
* finally, go back to the parent directory simply by instructing<source lang="bash"><br />
cd ..<br />
</source><br />
<br />
=== GEOS ===<br />
<br />
* download '''geos-3.4.2.tar.bz2''' from [http://trac.osgeo.org/geos/ http://trac.osgeo.org/geos] using <source lang="bash" enclose="none">wget</source> <source lang="bash"><br />
wget http://download.osgeo.org/geos/geos-3.4.2.tar.bz2<br />
</source><br />
<br />
* move to the "source-code" directory and decompress<br />
<ul><source lang="bash"><br />
cd /usr/local/src/<br />
bunzip2 geos-3.4.2.tar.bz2<br />
tar xvf geos-3.4.2.tar<br />
</source><br />
</ul><br />
<br />
* if required, clean previous configuration & compilation <source lang="bash"><br />
make distclean<br />
</source><br />
<br />
* move to geos directory <source lang="bash"><br />
cd geos-3.4.2<br />
</source><br />
<br />
* simple configure, compile and install <source lang="bash"><br />
./configure && make && sudo make install<br />
</source><br />
<ul> or <source lang="bash"><br />
./configure && make -j2 && sudo checkinstall<br />
</source><br />
</ul><br />
<br />
* do not forget to execute <source lang="bash"><br />
sudo ldconfig<br />
</source><br />
<br />
=== GDAL ===<br />
<br />
'''Note''', GDAL must be compiled '''without''' GRASS support<br />
<br />
* download the current stable version <source lang="bash"><br />
svn co https://svn.osgeo.org/gdal/branches/1.11/gdal gdal_stable<br />
</source><br />
<br />
* enter in the <source lang="bash" enclose="none">gdal_stable</source> directory <source lang="bash"><br />
cd /usr/local/src/gdal_stable<br />
</source><br />
<br />
* optionally, update the source code <source lang="bash"><br />
svn up<br />
</source><br />
<br />
* if required, clean previous configurations/compilations <source lang="bash"><br />
make distclean<br />
</source><br />
<br />
* a simple configuration without any parameters will detect and support various installed libraries <source lang="bash"><br />
./configure<br />
</source><br />
<br />
* skip to the ''compile and install'' step or check the following customised configuration example<br />
<ul><br />
<source lang="bash"><br />
CFLAGS="-g -Wall" LDFLAGS="-s" ./configure \<br />
--with-png=internal \<br />
--with-libtiff=internal \<br />
--with-geotiff=internal \<br />
--with-jpeg=internal \<br />
--with-gif=internal \<br />
--with-ecw=no \<br />
--with-expat=yes \<br />
--with-sqlite3=yes \<br />
--with-geos=yes \<br />
--with-python \<br />
--with-libz=internal \<br />
--with-netcdf \<br />
--with-threads=yes \<br />
--without-grass \<br />
--without-ogdi \<br />
--with-pg=/usr/bin/pg_config \<br />
--with-xerces=yes<br />
</source><br />
</ul><br />
<br />
* compile, install & ldconfig <source lang="bash"><br />
make -j2 && sudo make install && sudo ldconfig<br />
</source><br />
<ul> or <source lang="bash"><br />
make -j2 && sudo checkinstall && sudo ldconfig<br />
</source><br />
</ul><br />
<br />
=== GRASS GIS ===<br />
<br />
Note the differences between different GRASS version (SVN branches) in download and cofiguration. Note also the changes required if you installed some of the dependencies from packages (rather then compiled them yourself).<br />
<br />
To fully understand the build process, read the <code>INSTALL</code> file, which is located in GRASS' source code root directory. For example, if you have problems related to 32bit versus 64bit, pay attention to section <code>(C)</code>, entitled <code>COMPILATION NOTES for 64bit platforms</code>.<br />
<br />
''' Getting GRASS' source code '''<br />
<br />
Select from one of the GRASS GIS versions and download (using SVN) the source code:<br />
<br />
* VERY OLD STABLE VERSION: current state of the 6.4.x release branch version (stable) <source lang="bash"><br />
svn co https://svn.osgeo.org/grass/grass/branches/releasebranch_6_4 grass64_release<br />
</source><br />
<br />
* STABLE VERSION: current state of the 7.2.x release branch version (current stable) <source lang="bash"><br />
svn co https://svn.osgeo.org/grass/grass/branches/releasebranch_7_2 grass72_release<br />
</source><br />
<br />
* DEVELOPMENT VERSION: current state of the trunk (latest version of code where the development happens) <source lang="bash"><br />
svn co https://svn.osgeo.org/grass/grass/trunk grass7_trunk<br />
</source><br />
<br />
* for other versions see [http://trac.osgeo.org/grass/wiki/DownloadSource GRASS Trac wiki].<br />
<br />
''' Configure, Compile and Install'''<br />
<br />
Enter the directory with the source code (downloaded by svn client), for example:<br />
<br />
<source lang="bash"><br />
cd grass72_release<br />
</source><br />
<br />
* '''GRASS GIS 6 example configuration''' (which can/should be adjusted according to specific needs):<br />
<ul><br />
<source lang="bash"><br />
CFLAGS="-O2 -Wall" LDFLAGS="-s" ./configure \<br />
--enable-largefile=yes \<br />
--with-nls \<br />
--with-cxx \<br />
--with-proj-share=/usr/local/share/proj/ \<br />
--with-geos=/usr/local/bin/geos-config \<br />
--with-readline \<br />
--with-python=yes \<br />
--with-wxwidgets \<br />
--with-cairo \<br />
--with-opengl-libs=/usr/include/GL \<br />
--with-motif \<br />
--with-tcltk-includes="/usr/include/tcl8.5" \<br />
--with-ffmpeg=yes --with-ffmpeg-includes="/usr/include/libavcodec /usr/include/libavformat /usr/include/libswscale /usr/include/libavutil" \<br />
--with-freetype=yes --with-freetype-includes="/usr/include/freetype2/" \<br />
--with-postgres=yes --with-postgres-includes="/usr/include/postgresql" \<br />
--with-sqlite=yes \<br />
--with-mysql=yes --with-mysql-includes="/usr/include/mysql" \<br />
--with-odbc=no<br />
</source><br />
</ul><br />
<ul><br />
'''Note''', the above configuration uses the <code>Proj4</code> and <code>GEOS</code> packages compiled from the source. In the case that pre-compiled versions from the repository are required, remove the above corresponding lines to use the "defaults", i.e. <source lang="bash"><br />
--with-proj-share=/usr/share/proj \<br />
--with-geos=/usr/bin/geos-config \<br />
</source><br />
</ul><br />
<br />
* '''GRASS GIS 7 example configuration''' (which can/should be adjusted according to specific needs):<br />
<ul><br />
<source lang="bash"><br />
CFLAGS="-O2 -Wall" LDFLAGS="-s" ./configure \<br />
--enable-largefile=yes \<br />
--with-nls \<br />
--with-cxx \<br />
--with-readline \<br />
--with-proj-share=/usr/local/share/proj/ \<br />
--with-geos=/usr/local/bin/geos-config \<br />
--with-wxwidgets \<br />
--with-cairo \<br />
--with-opengl-libs=/usr/include/GL \<br />
--with-freetype=yes --with-freetype-includes="/usr/include/freetype2/" \<br />
--with-postgres=yes --with-postgres-includes="/usr/include/postgresql" \<br />
--with-sqlite=yes \<br />
--with-mysql=yes --with-mysql-includes="/usr/include/mysql" \<br />
--with-odbc=no \<br />
--with-liblas=yes --with-liblas-config=/usr/bin/liblas-config<br />
</source><br />
</ul><br />
<ul><br />
'''Note''', the above configuration uses the <code>Proj4</code> and <code>GEOS</code> packages compiled from the source. In the case that pre-compiled versions from the repository are required, remove the above corresponding lines to use the "defaults", i.e. (note the backslashe at the end of each line)<br />
<source lang="bash"><br />
--with-proj-share=/usr/share/proj \<br />
--with-geos=/usr/bin/geos-config \<br />
</source><br />
'''Note 2''', if compiling with liblas, you will want liblas compiled with laszip support. liblas will look for laszip includes in /usr/local/include/laszip by default. Creating the laszip directory in /usr/local/include and making a soft link. ln -s /usr/local/include/lasz*.hpp /usr/local/include/laszip and ln -s /usr/local/include/lasunz*.hpp /usr/local/include/laszip should allow liblas to compile with laszip support <br />
</ul><br />
<br />
* compile & install <source lang="bash"><br />
make -j2 && sudo make install && sudo ldconfig<br />
</source><br />
<br />
<ul> or <source lang="bash"><br />
make -j2 && sudo checkinstall && sudo ldconfig<br />
</source><br />
</ul><br />
<br />
For subsequent updates execute (not need for the first time):<br />
<source lang="bash"><br />
svn up<br />
make -j2 && sudo make install && sudo ldconfig<br />
</source><br />
<br />
Sometimes, it is required to clean previous configuration and compilation:<br />
<source lang="bash"><br />
make distclean<br />
svn up<br />
./configure ... # (use the configure command above)<br />
make -j2 && sudo make install && sudo ldconfig<br />
</source><br />
<br />
=== GDAL-GRASS-Plugin ===<br />
<br />
* get the plugin from [http://download.osgeo.org/gdal/ OSGeo's Download Server]: "gdal-grass-X.Y.Z.tar.gz" using <source lang="bash" enclose="none">wget</source><br />
<ul><source lang="bash"><br />
# update version number accordingly!<br />
wget http://download.osgeo.org/gdal/3.2.3/gdal-grass-3.2.3.tar.gz<br />
tar xvzf gdal-grass-3.2.3.tar.gz<br />
cd gdal-grass-3.2.3<br />
</source></ul><br />
<br />
* create <source lang="bash" enclose="none">/etc/ld.so.conf.d/grass.conf</source> or add in <source lang="bash" enclose="none">/etc/ld.so.conf</source> the GRASS library path: <br />
<ul><source lang="bash"><br />
# GRASS 7.8 library path (adapt as needed)<br />
/usr/local/src/releasebranch_7_8/lib<br />
<br />
# GRASS 7 (development version) library path (adapt as needed)<br />
/usr/local/src/grass_master/lib<br />
</source></ul><br />
<br />
* optionally, clean previous configurations/compilations<source lang="bash"><br />
make distclean</source><br />
<br />
* configure -- point to GRASS installation/binaries<br />
<ul><source lang="bash"> ./configure \<br />
--prefix=/usr/local \<br />
--with-gdal=/usr/local/bin/gdal-config \<br />
--with-grass=/usr/local/grass-7.8.git/ \<br />
--with-autoload="/usr/local/lib64/gdalplugins/" \<br />
--with-ld-shared="g++ -shared"</source></ul><br />
<ul><br />
* for GRASS 7.6, replace with <source lang="bash" enclose="none"> --with-grass=/usr/local/grass-7.6.3/</source><br />
* for GRASS 7.x...<br />
</ul><br />
<br />
* compile & install using checkinstall<source lang="bash"><br />
make -j2 && sudo checkinstall</source><br />
<br />
= Post compilation/installation control =<br />
<br />
* For a recommended quick-check read the [http://grass.osgeo.org/wiki/Compile_and_install_GRASS_and_QGIS_with_GDAL/OGR_Plugin#Troubleshooting Troubleshooting] section at [http://grass.osgeo.org/wiki/Compile_and_install_GDAL-GRASS_plugin Compile_and_install_GDAL-GRASS_plugin]<br />
<br />
* in case of errors in future compilation attempts, remember to remove program binaries and files created with the "configuration" from previous compilations with<br />
make distclean<br />
<br />
* another common mistake is compiling a module against some GRASS version and then try to run it through another GRASS version. The solution is to recompile the affected module or, in case there are multiple GRASS installations, set up properly LD_LIBRARY_PATH paths.<br />
<br />
<br />
= Removal of GRASS =<br />
<br />
<br />
To get rid of a GRASS binaries installation, delete (update version numbers accordingly)<br />
* <source lang="bash" enclose="none">/usr/local/grass-7.8.1.dev</source> (directory, binaries location)<br />
* <source lang="bash" enclose="none">/usr/local/bin/grass78</source> (file)<br />
* <source lang="bash" enclose="none">/home/username/.grassrc7</source> (file)<br />
<br />
<br />
If wanted, delete also the complete source code:<br />
* <source lang="bash" enclose="none">/usr/local/src/grass78_release</source> (directory, source code location)<br />
<br />
<br />
To remove <code>grass</code> (or any other package) which was installed by <source lang="bash" enclose="none">checkinstall</source>, use <source lang="bash" enclose="none">dpkg</source>, e.g.<source lang="bash"><br />
sudo dpkg -r grass78 # package name defined at installation is important</source><br />
<br />
= Packaging of GRASS =<br />
<br />
* See https://salsa.debian.org/debian-gis-team/grass/tree/master/debian for directions on rolling your own packages.<br />
<br />
For details about the auto-nightly-builds and after-market supplied packages from UbuntuGIS, please refer to the [[Ubuntu Packaging]] wiki page.<br />
<br />
== See also ==<br />
<br />
* Docker: https://grass.osgeo.org/download/software/docker-images/<br />
* [[Ubuntu Packaging]]<br />
* [[GRASS in Debian]]<br />
<br />
= Archived Notes =<br />
<br />
Notes that concern the configuration and compilation of GRASS GIS and its dependencies for older versions of Ubuntu-Linux.<br />
<br />
== Ubuntu 7.10 64-bit ==<br />
<br />
* Compiling latest GRASS source code on a 64-bit machine (with an ATI graphic card) under Ubuntu 7.10 64-bit with support for: 64-bit, SQLite, OpenGL, PYTHON, FFMPEG<br />
(Based on "Ubuntu 6.06 LTS - GRASS 6.1 Compilation Script" by David Finlayson)<br />
''Assuming it is the first time attempting to compile GRASS' source code & installing SVN, PROJ, GDAL/OGR''<br />
<br />
'''Preparation'''<br />
sudo apt-get update && sudo apt-get upgrade<br />
<br />
* install dependencies for compiling (in general) and dependencies for GRASS: PROJ, GDAL/OGR<br />
sudo apt-get install grass build-essential flex bison libncurses5-dev zlib1g-dev \<br />
libgdal1-dev libtiff4-dev libgcc1 libpng12-dev tcl8.4-dev tk8.4-dev fftw3-dev \<br />
libfreetype6-dev libavcodec-dev libxmu-dev gdal-bin libreadline5 libreadline5-dev \<br />
make python-dev python-wxversion<br />
<br />
* install SQLite<br />
sudo apt-get install sqlite3 libsqlite3-dev<br />
<br />
* install SVN<br />
sudo apt-get install subversion<br />
<br />
* create a directory as a simple user where source code(s) are going to be stored (in our example we use a directory called '''src''' under '''/usr/local''')<br />
<br />
sudo mkdir /usr/local/src<br />
<br />
* grant rwx (read-write-execute) permissions for our userid/ groupid on the directory (replace words userid and groupid with real userid):<br />
sudo chown ''userid'':''groupid'' /usr/local/src<br />
<br />
sudo chmod ug+rwx /usr/local/src<br />
<br />
* download latest source code from GRASS SVN repository in a directory on the system (e.g. /usr/local/src)<br />
svn checkout https://svn.osgeo.org/grass/grass/trunk grass_trunk<br />
<br />
* Above command places GRASS' source code in '''/usr/local/src/grass_trunk'''. In case of a subsequent update use the command: '''svn up''' from within the grass_trunk directory<br />
<br />
----<br />
'''Before''' attempting to compile GRASS, READ section (C) in the '''INSTALL''' file located in the main directory of GRASS source code entitled:<br />
'''(C) COMPILATION NOTES for 64bit platforms'''<br />
----<br />
<br />
* installing FFTW3 if not already on system<br />
sudo apt-get install fftw3 fftw3-dev<br />
<br />
'''FFMPEG'''<br />
<br />
Note: Back in Ubuntu 7.10, installing ffmpeg through the repositories wouldn't work with grass. The following steps were successfully used.<br />
<br />
* install FFMPEG (information taken from: http://stream0.org/2008/01/install-ffmpeg-on-ubuntu-gutsy.html)<br />
* download source code with svn<br />
svn checkout svn://svn.mplayerhq.hu/ffmpeg/trunk ffmpeg<br />
<br />
* install dependencies<br />
sudo apt-get install liblame-dev libfaad2-dev libfaac-dev libxvidcore4-dev \<br />
liba52-0.7.4 liba52-0.7.4-dev libx264-dev libdts-dev checkinstall \<br />
build-essential subversion<br />
<br />
* guide to ffmpeg directory<br />
cd ffmpeg<br />
<br />
if necessary: '''make distclean''' before configuration (look at notes below)<br />
<br />
* configuration ('''note:''' the configuration parameter "'''--enable-pp'''" does not work anymore)<br />
# configure FFMPEG<br />
./configure --enable-gpl --enable-libvorbis --enable-libtheora \<br />
--enable-liba52 --enable-libdc1394 --enable-libgsm \<br />
--enable-libmp3lame --enable-libfaad --enable-libfaac \<br />
--enable-libxvid --enable-libx264 \<br />
--enable-shared<br />
<br />
* compilation<br />
make<br />
<br />
* installation on /usr/local/bin -- important to remember when configuring GRASS' source code for compilation<br />
sudo checkinstall<br />
<br />
'''Go for GRASS!'''<br />
* in our example we used the /usr/local/src directory to store GRASS' source code, so:<br />
cd /usr/local/src/grass_trunk<br />
<br />
* configuration<br />
CFLAGS="-g -Wall" ./configure --enable-64bit \<br />
--with-libs=/usr/lib64 --with-cxx --with-freetype=yes \<br />
--with-postgres=no --with-sqlite=yes --enable-largefile=yes \<br />
--with-tcltk-includes=/usr/include/tcl8.4 \<br />
--with-freetype-includes=/usr/include/freetype2 \<br />
--with-opengl-libs=/usr/include/GL --with-readline \<br />
--with-python=yes --with-ffmpeg=yes \<br />
--with-ffmpeg-includes=/usr/local/include/ffmpeg<br />
<br />
*if OpenGL fails then maybe it is necessary to link '''glxATI.h''' with '''glx.h''' and re-run the configuration<br />
<br />
cd /usr/include/GL<br />
<br />
sudo ln glxATI.h glx.h<br />
<br />
* compilation<br />
make<br />
<br />
* compilation is expected to end with a statement similar to the following:<br />
<br />
Started compilation: Wed Feb 27 00:24:36 CET 2008<br />
--<br />
Errors in:<br />
No errors detected.<br />
<br />
* installation<br />
sudo checkinstall<br />
<br />
* launch 64-bit GRASS.6.4.svn<br />
grass64<br />
<br />
'''Notes'''<br />
* in case of errors in future compilation attempts, remember to remove program binaries with<br />
make clean<br />
* and the files created with the "configuration" from previous compilations with<br />
make distclean<br />
<br />
== Ubuntu 6.06, 7.10 ==<br />
<br />
* [http://david.p.finlayson.googlepages.com/makegrass.sh makegrass.sh] is script designed to automate most of the download, configuration and compilation of GRASS 6.x-CVS<br />
** it is advised use [https://help.ubuntu.com/community/CheckInstall checkinstall] (''sudo apt-get install checkinstall'') instead of ''make install'' to keep track of installed software <br />
** Think twice before using this script. Some users experienced problems such as disabled XGL etc.<br />
* [[User:Steko/Automated_CVS_compiling|Here]] is another of these scripts, it's homemade so probably you'll find the above more useful for production sites.<br />
<br />
<br />
[[Category: Compilation]]<br />
[[Category: Installation]]<br />
[[Category: Ubuntu]]<br />
[[Category: FAQ]]</div>Veroandreohttps://grasswiki.osgeo.org/w/index.php?title=GRASS_GSoC_Ideas_2024&diff=27390GRASS GSoC Ideas 20242024-02-15T12:58:56Z<p>Veroandreo: re-order</p>
<hr />
<div><br />
== About ==<br />
<br />
* [https://wiki.osgeo.org/wiki/Google_Summer_of_Code_2024 The OSGeo GSoC 2024 main page]<br />
* [https://summerofcode.withgoogle.com/ Official GSoC page at Google]<br />
<br />
== Ideas ==<br />
If you are a student you can suggest a new idea or pick up an existing one. In any case write about it to [https://lists.osgeo.org/listinfo/grass-dev grass-dev mailing list],[https://github.com/OSGeo/grass/discussions GitHub Discussions], or [https://gitter.im/grassgis/community Gitter].<br />
<br />
You are invited as well to have a close look at ideas from previous years ([https://trac.osgeo.org/grass/wiki/GSoC/2014 2014], [https://trac.osgeo.org/grass/wiki/GSoC/2015 2015], [https://trac.osgeo.org/grass/wiki/GSoC/2016 2016],<br />
[https://trac.osgeo.org/grass/wiki/GSoC/2017 2017],<br />
[https://trac.osgeo.org/grass/wiki/GSoC/2018 2018],<br />
[https://trac.osgeo.org/grass/wiki/GSoC/2019 2019],<br />
[https://trac.osgeo.org/grass/wiki/GSoC/2020 2020],<br />
[https://trac.osgeo.org/grass/wiki/GSoC/2021 2021],<br />
[https://trac.osgeo.org/grass/wiki/GSoC/2022 2022],<br />
[https://trac.osgeo.org/grass/wiki/GSoC/2023 2023])<br />
which have not yet been implemented.<br />
You can also look at accepted GRASS GSoC [https://trac.osgeo.org/grass/wiki/GSoC projects from previous years] for an idea of scope.''<br />
<br />
Include "GRASS GIS" in the title of our idea to easily distinguish ideas and projects inside OSGeo.<br />
<br />
<br />
=== Parallelization of existing tools ===<br />
<br />
There are several tools that would benefit from parallelization with OpenMP, e.g. r.texture, r.horizon, r.fill.stats, r/v.surf.idw, r.viewshed, v.to.rast, r.grow.distance,...<br />
For overview of current state, see [[Raster_Parallelization_with_OpenMP]].<br />
<br />
* Requirements: familiarity with C, OpenMP<br />
* Mentor: Huidae Cho<br />
* Co-mentor: Vaclav Petras, Anna Petrasova<br />
* Project length: 175 or 350 hours (take your pick)<br />
* Rating: medium<br />
* Expected Outcomes: parallelized module or modules, depending on complexity<br />
* Test of skills: suggest/implement solution for https://github.com/OSGeo/grass/issues/2644<br />
<br />
=== Improve GRASS user experience in Jupyter Notebook ===<br />
[[File:Jupyter_interactive_viewshed.png|500px|thumb|right|InteractiveMap in grass.jupyter library]]<br />
Python package [https://grass.osgeo.org/grass-stable/manuals/libpython/grass.jupyter.html grass.jupyter] was developed during [https://trac.osgeo.org/grass/wiki/GSoC/2021/JupyterAndGRASS GSoC 2021] to simplify running GRASS from Jupyter Notebooks and displaying data. This project could focus on adding features such as adding parallelization for rendering, increasing interactivity of displayed data using ipyleaflet (e.g., capture mouse clicks to show information about vector line, pixel), adding API for managing projects and subprojects (i.e., locations/mapsets), simplifing display of attribute data, ...<br />
<br />
* Requirements: Python<br />
* Mentor: Anna Petrasova<br />
* Co-mentor: Vaclav Petras, Helena Mitasova<br />
* Project length: 175 or 350 hours (take your pick)<br />
* Rating: easy to medium<br />
* Expected Outcomes: improved user experience when using GRASS through notebooks<br />
* Test of skills: https://github.com/OSGeo/grass/issues/3276, or write a test for [https://github.com/OSGeo/grass/tree/main/python/grass/jupyter grass.jupyter library] using python unittest or pytest, more info [https://grass.osgeo.org/grass-devel/manuals/libpython/gunittest_testing.html here].<br />
<br />
=== Add JSON output to different tools in C ===<br />
There are several tools in GRASS that would benefit from a JSON-formatted output, see [https://github.com/OSGeo/grass/issues/3020 this issue for a list of tools]. Besides adding the JSON output, the work would also include adding tests and basic documentation.<br />
* Requirements: C, Python for tests<br />
* Mentor: Vaclav Petras<br />
* Co-mentor: Anna Petrasova, Corey White<br />
* Project length: 175 or 350 hours (take your pick)<br />
* Rating: easy to medium<br />
* Expected Outcomes: one or more (depending on project length and complexity of the tool) tools with well tested JSON output<br />
* Test of skills: Address https://github.com/OSGeo/grass/issues/1044 for r.surf.fractal<br />
<br />
=== Support writing tests with pytest ===<br />
<br />
* The current testing framework, ''[https://grass.osgeo.org/grass-stable/manuals/libpython/gunittest.html grass.gunittest]'', was written before migration to Git/GitHub and when long free runs in 3rd party services were unthinkable. Additionally, some no longer relevant goals were prioritized, such as independence on the current code, detailed custom HTML reports, success tracking over time, and high specialization towards GRASS-specifics.<br />
* ''grass.gunittest'' is based on Python ''unittest'' package and many projects since then migrated to //pytest//, e.g., GDAL and Numpy. While ''unittest'' is inspired by Java's JUnit, ''pytest'' is designed to support writing small, readable tests, and uses plain `assert` statements instead of many different assert methods.<br />
* Using ''pytest'' should lead to tests which feel more like Python scripts and to minimum of testing-specific code.<br />
* An example issue of ''grass.gunittest'' is that it doesn't work well with tests of the main GRASS executable (prominence of `grass ... --exec` is yet another new thing which changed since ''grass.gunittest'' was designed).<br />
* Two main things needed:<br />
** Create general comparison functions from the ''grass.gunittest'' assert methods so that they can be used with pytest.<br />
** Current grass.script.setup.init function and grass.script.core.create_location function don't work well in the context of a pytest test function. More <br />
* Additional things needed:<br />
** Fixture for pytest to set up and tear down a GRASS session in a temporary mapset.<br />
<br />
* Requirements: Python<br />
* Project length: 175 or 350 hours (take your pick)<br />
* Mentor: Vaclav Petras<br />
* Co-mentor: Stefan Blumentrath<br />
* Proposed by: Vaclav Petras<br />
* Rating: easy to medium<br />
* Expected Outcomes: Convenient way of writing tests with pytest<br />
* Test of skills: Fix failing tests and/or write new tests (more is better). Alternatively, addressing a smaller problem in the testing framework is a good task, too.<br />
<br />
=== New easy-to-use CLI and API for GRASS GIS ===<br />
<br />
* Make running of GRASS GIS modules as easy as it is to run GDAL commands.<br />
** `grass run r.slope.aspect elevation=elevation.tiff slope=slope.tiff aspect=aspect.tiff`<br />
** CLI like GDAL has.<br />
** No GRASS Database, Location, Mapset to deal with.<br />
** No import, export from user perspective.<br />
** Reasonable defaults for things like region.<br />
** CLI and API still allows user to specify any of the above.<br />
* Idea page with details: wiki:GSoC/2021/EasyToUseCliAndApiIdea<br />
* Project length: 350 hours<br />
* Rating: medium<br />
* Requirements:<br />
** Language: Python<br />
** Proposal: Student needs to show sufficient understanding of the GRASS GIS Database structure and significantly extend on text below in terms of more concrete formulation of ideas and identification of missing and existing parts.<br />
* Mentors: Vaclav Petras<br />
* Co-mentors: Stefan Blumentrath<br />
* Proposed by: Vaclav Petras<br />
* Expected outcomes: New subcommand which easily runs a GRASS module on GeoTiff and GeoPackage.<br />
* Test and training tasks:<br />
** Solve one of the tickets linked at the idea page.<br />
** Add features to `grass` executable interface:<br />
*** Make it possible to associate `*.gxw` files with `grass` executable (#1204) or at least add `--gui-workspace` or preferably just recognize it in the command line (distinguish it from database/location/mapset).<br />
** Extend `--exec` functionality:<br />
*** Add `--region` to set a temporary computational region for the execution, e.g. `--region="raster=raster_name"`<br />
*** Add `--import-raster=some/file.tiff` which imports (r.import) a raster file (same for vector and similarly for export).<br />
*** Add `--link-raster=some/file.tiff` which links (r.external) a raster file (same for vector and similarly for r.external.out).<br />
<br />
=== STAC (SpatioTemporal Asset Catalog) Integration ===<br />
<br />
Create new import and export capabilities for GRASS GIS which allow users to easily ingest data from STAC catalogs and export locations and mapsets as STAC specs for data discovery within STAC browsers. <br />
<br />
* Requirements: familiar with python, STAC specs<br />
* Mentor: Corey White<br />
* Co-mentor: Vaclav Petras, Anna Petrasova<br />
* Project length: 175 or 350 hours (take your pick)<br />
* Rating: medium<br />
* Expected Outcomes: completion of t.in.stac and t.out.stac<br />
* Test of skills:<br />
** suggest or implement solution for implementing t.out.stac using the prototype STAC spec https://github.com/tomorrownow/grass-stac-extension <br />
** suggest/implement solution for completing https://github.com/OSGeo/grass-addons/pull/802<br />
<br />
=== Add EODAG support to GRASS GIS ===<br />
<br />
[https://eodag.readthedocs.io/en/stable/ EODAG] is a Python library useful to download several satellite datasets from different providers (i.e., USGS, Copernicus, AWS, Planetary Computer, etc.). GRASS has various modules to download satellite data like i.sentinel.download, i.landsat.download, i.modis.download. However, they all use different libraries, some of them no longer maintained. Hence, implementing the use of EODAG as back-end for those tools would be very useful not only in terms of maintenance but also in terms of less code repetition. It would also open the possibility for new tools or a master tool to download other datasets directly from GRASS. <br />
<br />
* Requirements: familiar with Python<br />
* Project length: 175 or 350 hours<br />
* Mentor: Luca Delucchi<br />
* Co-mentor: Veronica Andreo<br />
* Proposed by: Luca Delucchi<br />
* Rating: medium<br />
* Expected Outcomes: 175 hours EODAG core library to be able to download products; 350 library + application at least to i.sentinel.download but hopefully also to i.landsat.download<br />
* Test of skills:<br />
<br />
=== Welcome screen ===<br />
<br />
First time GRASS users are intimidated by requirement to think in advance about data analysis they plan to do. Recent versions have attempted to mitigate this issue by skipping startup screen and dropping the user into a generic WGS84 Project (Location) that most likely will not be the right one for performing actual work with data user has. One option how to improve experience of the first time users would be a welcome screen with clear and simple options of various pathways how to start exploring GRASS. All pathways already exist in the current GUI, but they are not well exposed to the first time user and/or lack certain features helping to understand choices to be made.<br />
Although the GUI is the most visible part, most likely changes to existing Project (Location) creation tools / libraries might be required.<br />
<br />
* Things to develop:<br />
** Main window with pathway choices<br />
** Create new Project from user provided data wizard<br />
** Create new Project by sample data download wizard<br />
** Create new Project by defining its parameters wizard<br />
* Requirements: Python / wxPython<br />
* Project length: 175 or 350 hours <br />
* Mentor: Māris Nartišs<br />
* Co-mentor: (? Anna Petrasova, ? Veronica Andreo)<br />
* Proposed by: Māris Nartišs<br />
* Rating: easy to medium<br />
* Expected Outcomes: functional GUI with partial integration (175 hours), fully integration (350 hours)<br />
* Test of skills: fix one of GUI bugs, e.g.:<br />
** https://github.com/OSGeo/grass/issues/3278<br />
** https://github.com/OSGeo/grass/issues/2440<br />
* Other: As this is a widely exposed part, expect communicating with many opinionated developers and users.<br />
<br />
=== Add {your research idea} to GRASS GIS ===<br />
<br />
* In general, you can propose any topic, but you can specifically propose integrating your research or research idea into GRASS GIS.<br />
* Requirements:<br />
** Language:<br />
*** Depends on the project, often Python, sometimes C.<br />
*** Adding your latest ecological analysis <br />
** Proposal:<br />
*** Discuss relevance to GRASS GIS.<br />
*** Describe technical steps needed for integration.<br />
*** Describe whether it is an addition of a tool (module) or a change in one of the libraries. If it is a tool, specify if it should be included in the core grass repository or in grass-addons repository and why.<br />
*** Specify what research was done and what needs to be accomplished in order to have usable product at the end of summer.<br />
*** Specify who will provide the research expertise.<br />
* Project length: 175 or 350 hours (take your pick)<br />
* Rating: from low to hard<br />
* Mentors:<br />
** GRASS GIS project will provide technical mentors, but it is up to the applicant to ensure the research part is mentored well. An exception may be granted to applicants which can demonstrate that the research is finished or that they have enough expertise themselves.<br />
** Possible technical mentors: Vaclav Petras, Anna Petrasova<br />
** Research mentors: Bring in an expert from your field, e.g., your academic advisor or project principal investigator (if needed).<br />
* Proposed by: Vaclav Petras<br />
* Expected outcome: Working feature which is integrated and merged at the end of the project.<br />
* Test and training tasks:<br />
** Create a test in Python for an existing tool in the grass-addons repository or in the core grass repository.<br />
<br />
=== Title of idea ===<br />
<br />
Description here<br />
<br />
* Requirements:<br />
* Project length: (175 or 350 hours) <br />
* Mentor: <br />
* Proposed by: <br />
* Rating: <br />
* Expected Outcomes: <br />
* Test of skills: <br />
* Other:<br />
<br />
== Tips for students ==<br />
<br />
* If you have your own ideas we encourage you to propose them. Explain them on the [https://lists.osgeo.org/listinfo/grass-dev grass-dev mailing list].<br />
* If you like some idea here or from previous yeas, write about it on [https://lists.osgeo.org/listinfo/grass-dev grass-dev mailing list] and any ideas of your own which could improve it.<br />
* Follow some good practices in your ideas and proposals:<br />
** Stress why the project would be useful.<br />
** Show that you know how you will proceed. That is, make sure that you can demonstrate that the proposal is feasible in the given time frame.<br />
** Be specific in the implementation (or at least as specific as you can).<br />
** Explain what the final product will look like and how it will work. You can add drawings or mock-ups.<br />
** Explain how the idea relates to existing GRASS GIS functions, features, and needs.<br />
** Do not include steps such as "install GRASS", "compile GRASS libraries (on my machine)", "read about the API". You should do this before applying to GSoC.<br />
* Compile GRASS GIS from source and prepare environment for development:<br />
** Read [https://github.com/OSGeo/grass/blob/main/CONTRIBUTING.md CONTRIBUTING file] and [https://grasswiki.osgeo.org/wiki/Compile_and_Install compilation instructions].<br />
** If you get stuck with the setup, feel free to consult the [https://lists.osgeo.org/listinfo/grass-user grass-user mailing list].<br />
** Familiarize yourself with wiki:Submitting rules.<br />
* Prove your worth by being active on the GRASS mailing lists ([https://lists.osgeo.org/listinfo/grass-user grass-user], [https://lists.osgeo.org/listinfo/grass-dev grass-dev]) or other channels ([https://github.com/OSGeo/grass/discussions GitHub Discussions], [https://gitter.im/grassgis/community Gitter]), fix some [https://github.com/OSGeo/grass/issues bugs], and/or implement some (smaller) features, or write some (simpler) GRASS module, and post it to mailing list. There's no better way to demonstrate your willingness and abilities. Do this before start you apply to GSoC. <br />
* Also note that fixing existing bugs and/or implementing enhancements will be a part of student evaluation.<br />
<br />
* Every year GRASS GIS hopes to participate and participates in GSoC as part of the [https://www.osgeo.org/ OSGeo Foundation]'s GSoC program umbrella. See the official OSGeo template for application details and other important information at the [https://wiki.osgeo.org/wiki/Google_Summer_of_Code_Recommendations_for_Students OSGeo Recommendations for Students].</div>Veroandreohttps://grasswiki.osgeo.org/w/index.php?title=GRASS_GSoC_Ideas_2024&diff=27389GRASS GSoC Ideas 20242024-02-15T12:33:49Z<p>Veroandreo: edit intro and motivation</p>
<hr />
<div><br />
== About ==<br />
<br />
* [https://wiki.osgeo.org/wiki/Google_Summer_of_Code_2024 The OSGeo GSoC 2024 main page]<br />
* [https://summerofcode.withgoogle.com/ Official GSoC page at Google]<br />
<br />
== Ideas ==<br />
If you are a student you can suggest a new idea or pick up an existing one. In any case write about it to [https://lists.osgeo.org/listinfo/grass-dev grass-dev mailing list],[https://github.com/OSGeo/grass/discussions GitHub Discussions], or [https://gitter.im/grassgis/community Gitter].<br />
<br />
You are invited as well to have a close look at ideas from previous years ([https://trac.osgeo.org/grass/wiki/GSoC/2014 2014], [https://trac.osgeo.org/grass/wiki/GSoC/2015 2015], [https://trac.osgeo.org/grass/wiki/GSoC/2016 2016],<br />
[https://trac.osgeo.org/grass/wiki/GSoC/2017 2017],<br />
[https://trac.osgeo.org/grass/wiki/GSoC/2018 2018],<br />
[https://trac.osgeo.org/grass/wiki/GSoC/2019 2019],<br />
[https://trac.osgeo.org/grass/wiki/GSoC/2020 2020],<br />
[https://trac.osgeo.org/grass/wiki/GSoC/2021 2021],<br />
[https://trac.osgeo.org/grass/wiki/GSoC/2022 2022],<br />
[https://trac.osgeo.org/grass/wiki/GSoC/2023 2023])<br />
which have not yet been implemented.<br />
You can also look at accepted GRASS GSoC [https://trac.osgeo.org/grass/wiki/GSoC projects from previous years] for an idea of scope.''<br />
<br />
Include "GRASS GIS" in the title of our idea to easily distinguish ideas and projects inside OSGeo.<br />
<br />
<br />
=== Parallelization of existing tools ===<br />
<br />
There are several tools that would benefit from parallelization with OpenMP, e.g. r.texture, r.horizon, r.fill.stats, r/v.surf.idw, r.viewshed, v.to.rast, r.grow.distance,...<br />
For overview of current state, see [[Raster_Parallelization_with_OpenMP]].<br />
<br />
* Requirements: familiarity with C, OpenMP<br />
* Mentor: Huidae Cho<br />
* Co-mentor: Vaclav Petras, Anna Petrasova<br />
* Project length: 175 or 350 hours (take your pick)<br />
* Rating: medium<br />
* Expected Outcomes: parallelized module or modules, depending on complexity<br />
* Test of skills: suggest/implement solution for https://github.com/OSGeo/grass/issues/2644<br />
<br />
=== Improve GRASS user experience in Jupyter Notebook ===<br />
[[File:Jupyter_interactive_viewshed.png|500px|thumb|right|InteractiveMap in grass.jupyter library]]<br />
Python package [https://grass.osgeo.org/grass-stable/manuals/libpython/grass.jupyter.html grass.jupyter] was developed during [https://trac.osgeo.org/grass/wiki/GSoC/2021/JupyterAndGRASS GSoC 2021] to simplify running GRASS from Jupyter Notebooks and displaying data. This project could focus on adding features such as adding parallelization for rendering, increasing interactivity of displayed data using ipyleaflet (e.g., capture mouse clicks to show information about vector line, pixel), adding API for managing projects and subprojects (i.e., locations/mapsets), simplifing display of attribute data, ...<br />
<br />
* Requirements: Python<br />
* Mentor: Anna Petrasova<br />
* Co-mentor: Vaclav Petras, Helena Mitasova<br />
* Project length: 175 or 350 hours (take your pick)<br />
* Rating: easy to medium<br />
* Expected Outcomes: improved user experience when using GRASS through notebooks<br />
* Test of skills: https://github.com/OSGeo/grass/issues/3276, or write a test for [https://github.com/OSGeo/grass/tree/main/python/grass/jupyter grass.jupyter library] using python unittest or pytest, more info [https://grass.osgeo.org/grass-devel/manuals/libpython/gunittest_testing.html here].<br />
<br />
=== Add JSON output to different tools in C ===<br />
There are several tools in GRASS that would benefit from a JSON-formatted output, see [https://github.com/OSGeo/grass/issues/3020 this issue for a list of tools]. Besides adding the JSON output, the work would also include adding tests and basic documentation.<br />
* Requirements: C, Python for tests<br />
* Mentor: Vaclav Petras<br />
* Co-mentor: Anna Petrasova, Corey White<br />
* Project length: 175 or 350 hours (take your pick)<br />
* Rating: easy to medium<br />
* Expected Outcomes: one or more (depending on project length and complexity of the tool) tools with well tested JSON output<br />
* Test of skills: Address https://github.com/OSGeo/grass/issues/1044 for r.surf.fractal<br />
<br />
=== Support writing tests with pytest ===<br />
<br />
* The current testing framework, ''[https://grass.osgeo.org/grass-stable/manuals/libpython/gunittest.html grass.gunittest]'', was written before migration to Git/GitHub and when long free runs in 3rd party services were unthinkable. Additionally, some no longer relevant goals were prioritized, such as independence on the current code, detailed custom HTML reports, success tracking over time, and high specialization towards GRASS-specifics.<br />
* ''grass.gunittest'' is based on Python ''unittest'' package and many projects since then migrated to //pytest//, e.g., GDAL and Numpy. While ''unittest'' is inspired by Java's JUnit, ''pytest'' is designed to support writing small, readable tests, and uses plain `assert` statements instead of many different assert methods.<br />
* Using ''pytest'' should lead to tests which feel more like Python scripts and to minimum of testing-specific code.<br />
* An example issue of ''grass.gunittest'' is that it doesn't work well with tests of the main GRASS executable (prominence of `grass ... --exec` is yet another new thing which changed since ''grass.gunittest'' was designed).<br />
* Two main things needed:<br />
** Create general comparison functions from the ''grass.gunittest'' assert methods so that they can be used with pytest.<br />
** Current grass.script.setup.init function and grass.script.core.create_location function don't work well in the context of a pytest test function. More <br />
* Additional things needed:<br />
** Fixture for pytest to set up and tear down a GRASS session in a temporary mapset.<br />
<br />
* Requirements: Python<br />
* Project length: 175 or 350 hours (take your pick)<br />
* Mentor: Vaclav Petras<br />
* Co-mentor: Stefan Blumentrath<br />
* Proposed by: Vaclav Petras<br />
* Rating: easy to medium<br />
* Expected Outcomes: Convenient way of writing tests with pytest<br />
* Test of skills: Fix failing tests and/or write new tests (more is better). Alternatively, addressing a smaller problem in the testing framework is a good task, too.<br />
<br />
=== New easy-to-use CLI and API for GRASS GIS ===<br />
<br />
* Make running of GRASS GIS modules as easy as it is to run GDAL commands.<br />
** `grass run r.slope.aspect elevation=elevation.tiff slope=slope.tiff aspect=aspect.tiff`<br />
** CLI like GDAL has.<br />
** No GRASS Database, Location, Mapset to deal with.<br />
** No import, export from user perspective.<br />
** Reasonable defaults for things like region.<br />
** CLI and API still allows user to specify any of the above.<br />
* Idea page with details: wiki:GSoC/2021/EasyToUseCliAndApiIdea<br />
* Project length: 350 hours<br />
* Rating: medium<br />
* Requirements:<br />
** Language: Python<br />
** Proposal: Student needs to show sufficient understanding of the GRASS GIS Database structure and significantly extend on text below in terms of more concrete formulation of ideas and identification of missing and existing parts.<br />
* Mentors: Vaclav Petras<br />
* Co-mentors: Stefan Blumentrath<br />
* Proposed by: Vaclav Petras<br />
* Expected outcomes: New subcommand which easily runs a GRASS module on GeoTiff and GeoPackage.<br />
* Test and training tasks:<br />
** Solve one of the tickets linked at the idea page.<br />
** Add features to `grass` executable interface:<br />
*** Make it possible to associate `*.gxw` files with `grass` executable (#1204) or at least add `--gui-workspace` or preferably just recognize it in the command line (distinguish it from database/location/mapset).<br />
** Extend `--exec` functionality:<br />
*** Add `--region` to set a temporary computational region for the execution, e.g. `--region="raster=raster_name"`<br />
*** Add `--import-raster=some/file.tiff` which imports (r.import) a raster file (same for vector and similarly for export).<br />
*** Add `--link-raster=some/file.tiff` which links (r.external) a raster file (same for vector and similarly for r.external.out).<br />
<br />
=== STAC (SpatioTemporal Asset Catalog) Integration ===<br />
<br />
Create new import and export capabilities for GRASS GIS which allow users to easily ingest data from STAC catalogs and export locations and mapsets as STAC specs for data discovery within STAC browsers. <br />
<br />
* Requirements: familiar with python, STAC specs<br />
* Mentor: Corey White<br />
* Co-mentor: Vaclav Petras, Anna Petrasova<br />
* Project length: 175 or 350 hours (take your pick)<br />
* Rating: medium<br />
* Expected Outcomes: completion of t.in.stac and t.out.stac<br />
* Test of skills:<br />
** suggest or implement solution for implementing t.out.stac using the prototype STAC spec https://github.com/tomorrownow/grass-stac-extension <br />
** suggest/implement solution for completing https://github.com/OSGeo/grass-addons/pull/802<br />
<br />
=== Add EODAG support to GRASS GIS ===<br />
<br />
[https://eodag.readthedocs.io/en/stable/ EODAG] is a Python library useful to download several satellite datasets from different providers (i.e., USGS, Copernicus, AWS, Planetary Computer, etc.). GRASS has various modules to download satellite data like i.sentinel.download, i.landsat.download, i.modis.download. However, they all use different libraries, some of them no longer maintained. Hence, implementing the use of EODAG as back-end for those tools would be very useful not only in terms of maintenance but also in terms of less code repetition. It would also open the possibility for new tools or a master tool to download other datasets directly from GRASS. <br />
<br />
* Requirements: familiar with Python<br />
* Project length: 175 or 350 hours<br />
* Mentor: Luca Delucchi<br />
* Co-mentor: Veronica Andreo<br />
* Proposed by: Luca Delucchi<br />
* Rating: medium<br />
* Expected Outcomes: 175 hours EODAG core library to be able to download products; 350 library + application at least to i.sentinel.download but hopefully also to i.landsat.download<br />
* Test of skills:<br />
<br />
=== Add {your research idea} to GRASS GIS ===<br />
<br />
* In general, you can propose any topic, but you can specifically propose integrating your research or research idea into GRASS GIS.<br />
* Requirements:<br />
** Language:<br />
*** Depends on the project, often Python, sometimes C.<br />
*** Adding your latest ecological analysis <br />
** Proposal:<br />
*** Discuss relevance to GRASS GIS.<br />
*** Describe technical steps needed for integration.<br />
*** Describe whether it is an addition of a tool (module) or a change in one of the libraries. If it is a tool, specify if it should be included in the core grass repository or in grass-addons repository and why.<br />
*** Specify what research was done and what needs to be accomplished in order to have usable product at the end of summer.<br />
*** Specify who will provide the research expertise.<br />
* Project length: 175 or 350 hours (take your pick)<br />
* Rating: from low to hard<br />
* Mentors:<br />
** GRASS GIS project will provide technical mentors, but it is up to the applicant to ensure the research part is mentored well. An exception may be granted to applicants which can demonstrate that the research is finished or that they have enough expertise themselves.<br />
** Possible technical mentors: Vaclav Petras, Anna Petrasova<br />
** Research mentors: Bring in an expert from your field, e.g., your academic advisor or project principal investigator (if needed).<br />
* Proposed by: Vaclav Petras<br />
* Expected outcome: Working feature which is integrated and merged at the end of the project.<br />
* Test and training tasks:<br />
** Create a test in Python for an existing tool in the grass-addons repository or in the core grass repository.<br />
<br />
=== Welcome screen ===<br />
<br />
First time GRASS users are intimidated by requirement to think in advance about data analysis they plan to do. Recent versions have attempted to mitigate this issue by skipping startup screen and dropping the user into a generic WGS84 Project (Location) that most likely will not be the right one for performing actual work with data user has. One option how to improve experience of the first time users would be a welcome screen with clear and simple options of various pathways how to start exploring GRASS. All pathways already exist in the current GUI, but they are not well exposed to the first time user and/or lack certain features helping to understand choices to be made.<br />
Although the GUI is the most visible part, most likely changes to existing Project (Location) creation tools / libraries might be required.<br />
<br />
Things to develop:<br />
* Main window with pathway choices<br />
* Create new Project from user provided data wizard<br />
* Create new Project by sample data download wizard<br />
* Create new Project by defining its parameters wizard<br />
<br />
<br />
* Requirements: Python / wxPython<br />
* Project length: 175 or 350 hours <br />
* Mentor: Māris Nartišs<br />
* Co-mentor: (? Anna Petrasova, ? Veronica Andreo)<br />
* Proposed by: Māris Nartišs<br />
* Rating: easy to medium<br />
* Expected Outcomes: functional GUI with partial integration (175 hours), fully integration (350 hours)<br />
* Test of skills: fix one of GUI bugs, e.g.:<br />
** https://github.com/OSGeo/grass/issues/3278<br />
** https://github.com/OSGeo/grass/issues/2440<br />
* Other: As this is a widely exposed part, expect communicating with many opinionated developers and users.<br />
<br />
=== Title of idea ===<br />
<br />
Description here<br />
<br />
* Requirements:<br />
* Project length: (175 or 350 hours) <br />
* Mentor: <br />
* Proposed by: <br />
* Rating: <br />
* Expected Outcomes: <br />
* Test of skills: <br />
* Other:<br />
<br />
== Tips for students ==<br />
<br />
* If you have your own ideas we encourage you to propose them. Explain them on the [https://lists.osgeo.org/listinfo/grass-dev grass-dev mailing list].<br />
* If you like some idea here or from previous yeas, write about it on [https://lists.osgeo.org/listinfo/grass-dev grass-dev mailing list] and any ideas of your own which could improve it.<br />
* Follow some good practices in your ideas and proposals:<br />
** Stress why the project would be useful.<br />
** Show that you know how you will proceed. That is, make sure that you can demonstrate that the proposal is feasible in the given time frame.<br />
** Be specific in the implementation (or at least as specific as you can).<br />
** Explain what the final product will look like and how it will work. You can add drawings or mock-ups.<br />
** Explain how the idea relates to existing GRASS GIS functions, features, and needs.<br />
** Do not include steps such as "install GRASS", "compile GRASS libraries (on my machine)", "read about the API". You should do this before applying to GSoC.<br />
* Compile GRASS GIS from source and prepare environment for development:<br />
** Read [https://github.com/OSGeo/grass/blob/main/CONTRIBUTING.md CONTRIBUTING file] and [https://grasswiki.osgeo.org/wiki/Compile_and_Install compilation instructions].<br />
** If you get stuck with the setup, feel free to consult the [https://lists.osgeo.org/listinfo/grass-user grass-user mailing list].<br />
** Familiarize yourself with wiki:Submitting rules.<br />
* Prove your worth by being active on the GRASS mailing lists ([https://lists.osgeo.org/listinfo/grass-user grass-user], [https://lists.osgeo.org/listinfo/grass-dev grass-dev]) or other channels ([https://github.com/OSGeo/grass/discussions GitHub Discussions], [https://gitter.im/grassgis/community Gitter]), fix some [https://github.com/OSGeo/grass/issues bugs], and/or implement some (smaller) features, or write some (simpler) GRASS module, and post it to mailing list. There's no better way to demonstrate your willingness and abilities. Do this before start you apply to GSoC. <br />
* Also note that fixing existing bugs and/or implementing enhancements will be a part of student evaluation.<br />
<br />
* Every year GRASS GIS hopes to participate and participates in GSoC as part of the [https://www.osgeo.org/ OSGeo Foundation]'s GSoC program umbrella. See the official OSGeo template for application details and other important information at the [https://wiki.osgeo.org/wiki/Google_Summer_of_Code_Recommendations_for_Students OSGeo Recommendations for Students].</div>Veroandreohttps://grasswiki.osgeo.org/w/index.php?title=User:Veroandreo&diff=27386User:Veroandreo2024-02-14T12:49:34Z<p>Veroandreo: update pic</p>
<hr />
<div>[[File:Vero.jpg|200x200px|thumb|right]]<br />
I’m an argentinean biologist, with a PhD in Biology and a MS degree in GIS and Remote Sensing (RS). I’m mostly interested in GIS and RS applications for public health and environmental emergencies. In 2013, I did an internship in the former [http://gis.cri.fmach.it/ PGIS] group at [http://www.fmach.it/ Fondazione Edmund Mach] (Trento, Italy) and ever since then I’ve become a GRASS GIS and FOSS fan. <br />
<br />
I mostly work with temporal modules of GRASS GIS (see for example the [https://grasswiki.osgeo.org/wiki/Temporal_data_processing Temporal Data Processing Wiki] and derived wikis therein). Since 2015, I do RS-GIS consultancy and teach basic and advanced GRASS GIS workshops/courses with focus on time series processing. In July 2016, I started working as a postdoc researcher in the [https://www.itc.nl/EOS Earth Observation Sciences Department] at ITC - University of Twente (Enschede, The Netherlands).</div>Veroandreohttps://grasswiki.osgeo.org/w/index.php?title=File:Vero.jpg&diff=27385File:Vero.jpg2024-02-14T12:47:59Z<p>Veroandreo: </p>
<hr />
<div>profile pic</div>Veroandreohttps://grasswiki.osgeo.org/w/index.php?title=GRASS_GIS_Budget_2024&diff=27351GRASS GIS Budget 20242023-12-17T14:57:58Z<p>Veroandreo: </p>
<hr />
<div>== Income ==<br />
<br />
{| class="wikitable"<br />
! Item !! USD !! EUR !! Notes<br />
|-<br />
| Request to OSGeo (general budget) || 5,000.00 || 4,585.76 || OSGeo Projects budget<br />
|-<br />
| Expected Donations || 550.00 || 504.43 || Based on average from 2020-2022<br />
|-<br />
| Total income || 5,550.00 || 5,090.20 || <br />
|}<br />
<br />
== Expenses ==<br />
<br />
{| class="wikitable"<br />
! Item !! USD !! EUR !! Notes<br />
|-<br />
| '''Events, Sprints, Travel''' || || || <br />
|-<br />
| Sprint || 4,100.00 || 3,760.32 || Community contributions to the sprint through the budget<br />
|-<br />
| PSC rep at AGM + Travel to OSGeo Sprint || 2,200.00 || 2,017.74 || Multiple travels on a continent or one travel to a different continent<br />
|-<br />
| Subtotal || 6,300.00 || 5,778.06 || <br />
|-<br />
| || || || <br />
|-<br />
| '''Student Grants''' || || || <br />
|-<br />
| Student grants || 4,000.00 || 3,668.61 || See Student Grants [https://grasswiki.osgeo.org/wiki/Student_Grants wiki] page, 4 grants offered<br />
|-<br />
| Subtotal || 4,000.00 || 3,668.61 || <br />
|-<br />
| || || || <br />
|-<br />
| '''Marketing''' || || || <br />
|-<br />
| T-shirts, swag for users, conferences, ... || 400.00 || 366.86 || Community members can request for local or global events<br />
|-<br />
| Stickers and magnets (as above) || 400.00 || 366.86 || Community members can request for local or global events<br />
|-<br />
| Subtotal || 800.00 || 733.72 || <br />
|-<br />
| || || || <br />
|-<br />
| Total expenses || 11,100.00 || 10,180.39 || <br />
|}<br />
<br />
== Balance ==<br />
<br />
{| class="wikitable"<br />
! Item !! USD !! EUR !! Notes<br />
|-<br />
| Year balance (income - expenses) || -5,550.00 || -5,090.20 || If negative, it needs to be covered by additional fundraising and surplus.<br />
|-<br />
| Balance in Open Collective || 6,149.03 || 5,639.60 || State from December 15, 2023<br />
|-<br />
| EOY balance (year balance + surplus) || 599.03 || 549.40 || <br />
|}<br />
<br />
Edits: Ask the treasurer about editing this page.</div>Veroandreohttps://grasswiki.osgeo.org/w/index.php?title=GRASS_Community_Meeting_Prague_2023&diff=27118GRASS Community Meeting Prague 20232023-06-06T11:46:56Z<p>Veroandreo: /* Thanks to our sponsors */</p>
<hr />
<div>{{toc|right}}<br />
The GRASS GIS team is organizing the ''GRASS GIS Community Meeting with contributors, power users and developers'' from '''June 2 to June 6, 2023''' to celebrate GRASS GIS '''40th birthday''' (by contributing to GRASS GIS of course).<br />
<br />
<gallery mode="slideshow"><br />
Image:Prague-Community-Meeting-2023-crop.jpg|Prague 2023 Group Photo<br />
Image:Day3-table.jpg|A full work table during the 3rd day<br />
Image:Day3-collaboration.jpg|Lots of discussion and collaboration<br />
Image:GRASS-smiles.jpg|GRASS GIS development brings smiles<br />
Image:Day2-collaboration.jpg|Afternoon working and collaborating<br />
Image:Beer-and-work-day4.jpg|The work and discussion continues over dinner<br />
Image:Group-photo-hike.jpg|View at Alšova vyhlídka while taking a walk together<br />
</gallery><br />
<br />
== Purpose ==<br />
<br />
GRASS GIS Community Meeting is a great occasion for folks to support the development by actively contributing to the source code, documentation (manuals, wiki, tutorials), translations, website or likewise. The '''community''' meeting is also a get-together where supporters, contributors, power users and developers make decisions and tackle larger problems related to the project, discuss and collaboratively resolve bugs, plan the direction for the project and work on new features. We welcome people committed to improving the GRASS GIS project and the interfaces to QGIS, GDAL, PostGIS, R, OGC Services and desiring to '''celebrate with us the 40th GRASS GIS birthday!!'''<br />
<br />
In this meeting, we will work on GRASS GIS and integrations with related OSGeo projects. We will revise connection to QGIS to make it easier to maintain, and we will work on migration of the build to CMake to improve Windows builds including PDAL support. Furthermore, we will start moving documentation to Markdown to make it easier to contribute to and we will add images and examples for tools and workflows which still miss them. Finally, we will automate and document maintenance processes to reduce the burden on maintainers and thus improve the project sustainability. <br />
<br />
Note that while we have our general plan, we can't accept any earmarked donations, i.e., we can't make any promises for a specific work to be done. We do require participants to work on GRASS GIS or connections to other projects. However, we leave them the freedom to work on what they think is the best contribution to the project at that time given their skills and time available.<br />
<br />
For the detailed agenda and individual's plans, see below.<br />
<br />
== Sponsors ==<br />
<br />
We welcome '''financial contributions''' to support the meeting and we are looking for sponsors to cover costs such as meals or to help reducing travel and accommodation expenses for GRASS developers who volunteer their time. If you are interested in sponsoring the GRASS Community Meeting, please see our<br />
<br />
::: '''[https://opencollective.com/osgeo/projects/grass/contribute/grass-community-meeting-prague-2023-55074 OpenCollective GRASS Community Meeting Prague 2023 Tier]'''<br />
<br />
Any surplus at the end of the event will used for future activities of the GRASS GIS project such as the successful [[Student Grants|student mini grant program]].<br />
<br />
This GRASS Community Meeting is a great occasion for you to support the development of GRASS. With your contribution you'll enable more developers to meet. Community meetings are important opportunities for developers to discuss, fix bugs, plan the direction for the project and work on new features. Please see below for the detailed agenda. The developers and contributors are donating their valuable time, so it would be great if in-kind funding can be made available from within the community to cover out-of-pocket expenses. All of the work that takes place at the community meeting will be directly contributed back into the GRASS project to the benefit of everyone who uses it.<br />
<br />
=== Thanks to our sponsors ===<br />
<br />
We are grateful for the support which we have received to organize this GRASS Community Meeting:<br />
<br />
[[File:Osgeo logo.png|none|left|alt=Light and dark green logo of OSGeo saying Your Open Source Compass|Open Source Geospatial Foundation]]<br />
* [https://www.osgeo.org/ OSGeo]: 7303 USD (approved budget contribution, [https://www.loomio.com/p/2m75BZkL/motion-to-approve-7303-to-support-grass-gis-community-meeting motion])<br />
* Twitter: [https://twitter.com/OSGeo/ @OSGeo] | [https://fosstodon.org/@osgeo @osgeo@fosstodon.org]<br />
<br />
[[File:FOSSGIS_eV_logo.png|none|left|400px|alt=Logo of FOSSGIS e.V.|FOSSGIS e.V.]]<br />
* [https://www.fossgis.de/ FOSSGIS e.V.]: 5000 EUR (approved budget contribution, [https://www.fossgis.de/wiki/F%C3%B6rderantr%C3%A4ge/GRASS_GIS_Community_Meeting_2023 request])<br />
* Twitter: [https://twitter.com/FOSSGIS_Verein @FOSSGIS_Verein] | [https://mastodon.online/@FOSSGISeV/ @FOSSGISeV@mastodon.online]<br />
<br />
[[File:OSGeo JP logo for web.png|none|left|400px|alt=OSGeo.JP]]<br />
* [https://www.osgeo.jp/ OSGeo Japan]: 550 USD (through Open Collective)<br />
<br />
Individuals:<br />
* Hernán De Angelis 20 USD<br />
* MarWe 50 USD<br />
* Nick Brady 50 USD<br />
* José Ramón 50 USD<br />
* Johannes Brauner 30 USD<br />
* Peter Löwe 30 USD<br />
* Evan Kay 10 USD<br />
* Joaquin Perez Valera 5 USD<br />
* Anonymous sponsors 2750 USD<br />
<br />
In-kind contributions:<br />
<br />
* Department of Geomatics Faculty of Civil Engineering Czech Technical University in Prague (FCE CTU) - space and personnel time (planning, preparation, participation)<br />
* North Carolina State University, Center for Geospatial Analytics - personnel time (planning, preparation, participation)<br />
* mundialis GmbH & Co. KG - personnel time (planning, preparation, participation)<br />
* CONICET - personnel time (planning, preparation, participation)<br />
* Research Institute for Nature and Forest (INBO | Brussels, Belgium) – personnel time + travel and hotel costs of INBO staff<br />
* SunGIS – personnel time, travel, and hotel costs of Maris Nartiss<br />
* OpenPlains Inc. – personnel time<br />
<br />
Personal time and/or financial contributions:<br />
* Martin Landa, Micha Silver, Helmut Kudrnovsky, Markus Neleter, Ondřej Pešek, Helena Mitasova, Vaclav Petras, Anna Petrasova, Corey White, Maris Nartiss, Aaron Saw Min Sern, Luís de Sousa, Caitlin Haedrich, Linda Kladivová, Carmen Tawalika, Floris Vanderhaeghe, Brendan Harmon, Veronica Andreo, Daniel Torres, Loïc Bartoletti<br />
<br />
== Timing ==<br />
<br />
'''When''': June 2-6, 2023<br />
<br />
Of course you are invited to join or leave the meeting whenever you want.<br />
<br />
== Venue ==<br />
<br />
[[Image:logo_cvut.jpg|130px|left]]<br />
Department of Geomatics<br><br />
[https://www.fsv.cvut.cz/?lang=en Faculty of Civil Engineering]<br><br />
[https://www.cvut.cz/en Czech Technical University in Prague], {{wikipedia|Czech Republic}}<br><br />
Thákurova 7/2077, Prague<br><br />
Room B868<br><br />
[https://en.mapy.cz/s/debazefuse Map]<br><br />
<br />
Prague has an international [http://www.prg.aero/en/ airport] and is also reachable by train, bus or car.<br />
<br />
== Accommodation and Costs ==<br />
<br />
Participants should plan for the following costs:<br />
<br />
* The participation is free of charge<br />
* Travel to Prague, variable depending on where you come from, reimbursements depending on the financial contributions provided by the community<br />
* Accommodation and meals (with the donated sponsorship money we will try to cover some expenses of the participants)<br />
'''Please note''': The currency in Czech Republic is {{wikipedia|Czech crown}} (CZK, koruna, Kč). 100 Czech crowns are about 4 Euros (see [https://www.cnb.cz/cs/financni-trhy/devizovy-trh/kurzy-devizoveho-trhu/kurzy-devizoveho-trhu/ current rates]).<br />
<br />
Please let us know your time of arrival and departure, so we can book accommodations and organize the logistics.<br />
<br />
Financial support: (partial) travel grants can be payed upon request thanks to our sponsors!<br />
<br />
== Agenda - What we plan to do ==<br />
<br />
'''Note:''' The program is generally open for your ideas. Please write an email to the [http://lists.osgeo.org/mailman/listinfo/grass-dev GRASS developer list] to discuss your contribution.<br />
<br />
During the meeting we will work on GRASS GIS on these tasks (please add more!):<br />
<br />
* We will update and revise the [https://github.com/qgis/QGIS/tree/master/python/plugins/grassprovider GRASS GIS Integration with QGIS] to simplify maintenance.<br />
* Furthermore, we will migrate the compilation technology to CMake to significantly improve the Windows builds including PDAL support and become binary compatible with OSGeo4W.<br />
* The extensive GRASS documentation will be converted from HTML to Markdown to facilitate future collaboration.<br />
* Pictures, examples and workflows will be added to the documentation where they are still missing.<br />
* Software maintenance processes are automated and documented to reduce the burden on maintainers and thus improve the sustainability of the project.<br />
<br />
This means that there are tasks from both the programming and documentation areas to appeal to a wide range of interested parties.<br />
<br />
Further details about the action items you '''find [[Talk:GRASS Community Meeting Prague 2023|here]]''' and below. Topics cover non-technical, semi-technical, and technical issues.<br />
<br />
=== Timeline ===<br />
<br />
(agenda is under development, but also flexible)<br />
<br />
==== Thursday, 1 June ====<br />
<br />
* Arrival<br />
<br />
==== Friday, 2 June ====<br />
<br />
* 9:00 meeting starts in the room B-868<br />
* Lunch: 12:45 NTK<br />
* Review the plan for the next days<br />
* API for use in Python and in other projects (e.g., QGIS)<br />
* Parallelizations<br />
<br />
==== Saturday, 3 June ====<br />
<br />
* Reducing cost of distribution on Windows<br />
* Convert GRASS GIS documentation from HTML to Markdown and implement new documentation system (mkdocs?)<br />
* Group photo 1<br />
* Outdoor social evening<br />
<br />
==== Sunday, 4 June ====<br />
<br />
* Compilation CMake (Windows, Linux)<br />
* Connections in general, rgrass, qgisprocess<br />
* GRASS GIS addons overview generator for entire GitHub (and more?) based on tag "[https://github.com/topics/grass-gis-addons grass-gis-addons]"<br />
* Group photo 2<br />
<br />
==== Monday, 5 June ====<br />
<br />
* Connections in general, QGIS, rgrass, qgisprocess<br />
* Parallelizations<br />
* grass.jupyter<br />
<br />
==== Tuesday, 6 June ====<br />
<br />
* Connections in general, QGIS<br />
* Parallelizations<br />
* grass.jupyter<br />
<br />
==== Wednesday, 7 June ====<br />
<br />
* Departure<br />
<br />
=== Social events ===<br />
<br />
==== Friday, 2 June ====<br />
<br />
Dinner at 7pm: [https://www.uveverky.com/kontakt/ U veverku pub] ([https://en.mapy.cz/s/jumomotupu map])<br />
<br />
==== Saturday, 3 June ====<br />
<br />
Dinner at 6pm: [https://unetickypivovar.cz/en Únětický pivovar] ([https://en.mapy.cz/s/mubutetoba map])<br />
<!--<br />
Option 1:<br />
<br />
* 4:21pm bus from Dejvicka (underground station) to Vyhledy<br />
* [https://en.mapy.cz/s/rocabosumu walk 45min] <br />
--><br />
* 3:50pm train from Podbaba (15min walk) to Roztoky<br />
* [https://en.mapy.cz/s/dabavojufa walk 1:30min]<br />
* Bus (355) back from Unetice to Dejvicka: 21:57 or 23:18<br />
<br />
==== Sunday, 4 June ====<br />
<br />
Dinner at 7pm: [https://www.restauracevltava.cz/ Restaurace Vltava] ([https://en.mapy.cz/s/gonezofozo map])<br />
<br />
==== Monday, 5 June ====<br />
<br />
Dinner at 7pm: [https://www.my-paprika.com/ My Paprika] ([https://en.mapy.cz/s/modekehepu map])<br />
<br />
* Tram 26 from Dejvicka to Strossmayerovo namesti at 6:26pm<br />
<br />
== Participation ==<br />
<br />
We are planning for an attendance of 20 people (i.e., coding places) but of course you are welcome to join us and bring new ideas with you: we'll make more places available. Please add your name here or contact [[User:Landa|Martin Landa]] <tt><landa.martin at gmail.com></tt>:<br />
<br />
=== In person ===<br />
<br />
{|class="wikitable sortable" border="2" cellspacing="0" cellpadding="4" rules="all" style="margin:1em 1em 1em 0; border:solid 1px #AAAAAA; border-collapse:collapse; background-color:#edf9c7; font-size:95%; empty-cells:show;" <br />
!width=50px|'''Number'''<br />
!width=130px|'''Participant '''<br />
!width=100px|'''Country'''<br />
!width=100px|'''Arrival'''<br />
!width=100px|'''Departure'''<br />
!'''Topics'''<br />
!'''Notes'''<br />
|-<br />
|1<br />
|[[User:Landa|Martin Landa]]<br />
| Czech Republic<br />
| June 1<br />
| June 7<br />
| Python: create_location ([https://github.com/OSGeo/grass/issues/1987 #1987]), Graphical Modeler improvements and single window layout integration<br />
|<br />
|-<br />
|2<br />
| Micha Silver<br />
| Israel<br />
| June 2<br />
| June 6<br />
| Addon to derive soil moisture from Sentinel 2<br />
|<br />
|-<br />
|3<br />
|[https://www.osgeo.org/member/kudrnovsky/ Helmut Kudrnovsky]<br />
| Austria<br />
| June 2 (18:37) by train<br />
| June 4 (18:24) by train <br />
| support CMake transition<br />
|<br />
|-<br />
|4<br />
|[[User:Neteler|Markus Neteler]]<br />
| Germany<br />
| June 2 (17:17)<br />
| June 6 (12:43)<br />
| translations, manual pages, ..., see [[Talk:GRASS_Community_Meeting_Prague_2023#Markus_Neteler|my list in "Discussion" page]]<br />
|<br />
|-<br />
|5<br />
|[[User:pesekon2|Ondřej Pešek]]<br />
| Czech Republic<br />
| June 2 (17:17)<br />
| June 6 (12:43)<br />
| Python 3.12-connected issues, gmodeler<br />
|<br />
|-<br />
|6<br />
| [[User:helena|Helena Mitasova]]<br />
| United States <br />
| June 2<br />
| June 6<br />
|<br />
|<br />
|-<br />
|7<br />
| [[User:wenzeslaus|Vaclav Petras]]<br />
| United States <br />
| June 1<br />
| June 7<br />
| init and other Python API topics, support CMake transition, revise connection with QGIS and other tools, funding<br />
|<br />
|-<br />
|8<br />
| [[User:Annakrat|Anna Petrasova]]<br />
| United States <br />
| June 1<br />
| June 7<br />
| parallelization documentation, grass.jupyter, R and QGIS integration<br />
|<br />
|-<br />
|9<br />
| [[User:Ctwhite|Corey White]]<br />
| United States <br />
| June 2 (10:55)<br />
| June 7<br />
| Connections with other tools, OpenPlains, JSON outputs<br />
|<br />
|-<br />
|10<br />
| [[User:MarisN|Maris Nartiss]]<br />
| Latvia<br />
| June 2 (14:30)<br />
| June 6 (12:00)<br />
| Improvements of imagery modules (push i.svm.*; i.signatures; ?)<br />
|-<br />
|11<br />
| [[User:Aaronsms|Aaron Saw Min Sern]]<br />
| Singapore<br />
| June 1<br />
| June 7<br />
| Support CMake transition, r.mapcalc parallelization<br />
|<br />
|-<br />
|12<br />
| [[User:Ldesousa|Luís de Sousa]]<br />
| The Netherlands<br />
| June 1 (20:00)<br />
| June 5 (20:45)<br />
| Update r.mblend add-on; test CMake transition.<br />
| <br />
|-<br />
|13<br />
| Caitlin Haedrich<br />
| United States<br />
| June 1<br />
| June 7<br />
| grass.jupyter<br />
|<br />
|-<br />
|14<br />
| Linda Kladivová<br />
| Czech Republic<br />
| June 2<br />
| June 6<br />
| Single-Window layout issues and improvements<br />
|<br />
|-<br />
|15<br />
| Carmen Tawalika<br />
| Germany<br />
| June 2 (17:17)<br />
| June 6 (12:43)<br />
| Happy to assist with general topics like documentation + automation, in doubt something related to actinia<br />
| <br />
|-<br />
|16<br />
| Floris Vanderhaeghe<br />
| Belgium<br />
| June 3 (train 19:17)<br />
| June 6 (train 8:25)<br />
| Helping in interfacing GRASS from R (rgrass & qgisprocess packages)<br />
| <br />
|-<br />
|}<br />
<br />
If you are arriving or departing on the days of the event, please specify the time, too.<br />
<br />
=== Via chat or hangout ===<br />
<br />
Join our [https://app.gitter.im/#/room/#grassgis_community:gitter.im Gitter chatroom]<br />
<br />
Gitter has a video (and backup will be Zoom).<br />
<br />
Participating virtually:<br />
<br />
{|class="wikitable sortable" border="2" cellspacing="0" cellpadding="4" rules="all" style="margin:1em 1em 1em 0; border:solid 1px #AAAAAA; border-collapse:collapse; background-color:#edf9c7; font-size:95%; empty-cells:show;" <br />
!width=50px|'''Number'''<br />
!width=130px|'''Participant '''<br />
!width=100px|'''Country'''<br />
!'''Topics'''<br />
!'''Times, synchronous or fully asynchronous'''<br />
!'''Notes'''<br />
|-<br />
|1<br />
|[[User:Baharmon|Brendan Harmon]]<br />
| United States<br />
| Update integration with QGIS<br />
| Available 8:00 AM CST (UTC-6) onwards<br />
|<br />
|-<br />
|2<br />
|[[User:veroandreo|Veronica Andreo]]<br />
| Argentina<br />
| Mission and vision, interfaces with QGIS and R, sponsoring, ... [https://grasswiki.osgeo.org/wiki/Talk:GRASS_Community_Meeting_Prague_2023#Vero see discussion tab]<br />
| available from 8:00 AM ART (UTC-3) onward<br />
|<br />
|-<br />
|3<br />
|[[User:Nobeeakon|Daniel T]]<br />
| Mexico<br />
| <br />
| some availability through the days :/<br />
|<br />
|-<br />
|4<br />
|[[User:LBartoletti|Loïc Bartoletti]]<br />
| France<br />
| QGIS Integration, support CMake transition<br />
|<br />
|-<br />
|}<br />
<br />
<br />
==== Timing of hangout meetings ====<br />
<br />
Follow Gitter.<br />
<br />
=== Collaborative document scratching ===<br />
<br />
Follow Gitter.<br />
<br />
== Individual Preparation ==<br />
<br />
<br />
* Bring your own computer<br />
* Bring {{wikipedia|AC adapter|power connector adapter}} if needed (Czech Republic: 230V, 50Hz, {{wikipedia|File:Euro-Flachstecker_2.jpg|Type C Europlugs}} are common and also {{wikipedia|File:French_plug_and_socket.jpg|Type E}})<br />
* Install git and the compiler tools, and come with a working GRASS development environment if possible.<br />
<br />
== Broadcast & Video ==<br />
<br />
During the event :) Find the latest information on the [https://matrix.to/#/#grassgis_sprint:gitter.im Gitter Channel].<br />
<br />
== Photos ==<br />
Day 1<br />
<gallery mode="slideshow"><br />
Image:Devs at work.jpg|Hard at work on the first day<br />
Image:Lively discussion.jpg|Lively discussion<br />
Image:Dinner day 1.jpg|Dinner at a nearby pub<br />
</gallery><br />
<br />
Day 2<br />
<gallery mode="slideshow"><br />
Image:Prague-Community-Meeting-2023.jpg|Group photo<br />
Image:PXL 20230603 085440353.jpg|A full table on day 2<br />
Image:GRASS-smiles.jpg|GRASS GIS development brings smiles<br />
Image:Day2-pizza.jpg|Pizza fuels work!<br />
Image:Day2-collaboration.jpg|Afternoon working and collaborating<br />
Image:Group-photo-hike.jpg|View at Alšova vyhlídka on the way to Únětický pivovar (brewery)<br />
Image:Únětický pivovar.jpg|Beer at Únětický pivovar, a 300-year-old brewery, after a day of hard work<br />
</gallery><br />
<br />
Day 3<br />
<gallery mode="slideshow"><br />
Image:Day3-working.jpg|Working on new features, bug fixes, documentation and more..<br />
Image:Day3-table.jpg|An even fuller table on day 3<br />
Image:Day3-collaboration.jpg|Collaboration and discussion<br />
Image:Beer-pano-day3.jpg|Panoramic photo of a cheers to GRASS's 40th Birthday at Vitala restaurant<br />
</gallery><br />
<br />
Day 4<br />
<gallery mode="slideshow"><br />
Image:Group-photo2-day4.jpg|Group photo on Day 4 on the steps of CVUT Praha<br />
Image:Qgis-call-day4.jpg|Discussing QGIS integration<br />
Image:Toast-grass-40th-birthday.jpg|A toast to GRASS GIS's 40th Birthday and a successful meeting<br />
Image:Beer-and-work-day4.jpg|The work and discussion continues over dinner<br />
</gallery><br />
<br />
== FAQ ==<br />
<br />
* '''How was it last time?'''<br />
** Very nice, see [[GRASS_GIS at OSGeo Virtual Community Sprint 2020]]!<br />
* ''Is the GRASS Community Meeting just a coding event?''<br />
** It is mainly a coding and documentation event. It is a working session for people who are already participants in the GRASS project and/or are committed to improving the GRASS project.<br />
** On demand we can do some presentations of current working GRASS implementation and new upcoming features to spread the idea of Open Source GIS software.<br />
* ''Is the GRASS Community Meeting for developers only?''<br />
** No: anybody can help, with testing, checking out bugs and fixes, documentation and more.<br />
* ''Where can I get help and more information about the community meeting?''<br />
** Contact [[User:Landa|Martin Landa]] <tt><landa.martin at gmail.com></tt><br />
<br />
== Report and press release ==<br />
<br />
TBD: After the event :-)<br />
<br />
We'll esp. craft a report for our sponsors.<br />
<br />
[[Category: Workshops]]<br />
[[Category: Code Sprint]]<br />
[[Category: 2023]]</div>Veroandreohttps://grasswiki.osgeo.org/w/index.php?title=Talk:GRASS_Community_Meeting_Prague_2023&diff=27093Talk:GRASS Community Meeting Prague 20232023-06-05T13:26:30Z<p>Veroandreo: /* Vero Andreo */ rgrass7 news</p>
<hr />
<div>__TOC__<br />
<br />
== Tasks for participants ==<br />
<br />
* Create section for you in the Reports section.<br />
* List all the things you are working on in the section. Update the list each day. Include things you work on with other people.<br />
* Link the [https://github.com/orgs/OSGeo/projects/1/ GRASS Community Meeting Prague 2023] project on GitHub to each PR or issue you are working on or plan to be working on.<br />
* If you are or will be working on an issue or on a PR which is not originally submitted by you, assign yourself to the issue or PR. (You can unassign yourself later if you change your mind.)<br />
<br />
== Planning and organizing ==<br />
<br />
* Initial planning: Veronica Andreo, Martin Landa, Vaclav Petras, Helmut Kudrnovsky, Anna Petrasova, Huidae Cho, Markus Neteler, Helena Mitasova, Micha Silver, Linda Kladivova<br />
* Funding acquisition: Veronica Andreo, Markus Neteler, Vaclav Petras, Anna Petrasova, Huidae Cho, Luca Delucchi, Venkatesh Raghavan<br />
* Budget: Vaclav Petras, Markus Neteler, Veronica Andreo<br />
* Venue and local organizing: Martin Landa<br />
* T-shirts, hoodies, stickers: Vaclav Petras, Anna Petrasova<br />
* Promotion, invitations, and social media: Caitlin Haedrich, Veronica Andreo, Vaclav Petras<br />
* Wiki page: Martin Landa, Markus Neteler, Vaclav Petras, Veronica Andreo<br />
* Virtual meeting organizing: Veronica Andreo<br />
* Photography: Caitlin Haedrich<br />
<br />
== Ideas for the meeting agenda ==<br />
<br />
Collect ideas here :-)<br />
<br />
=== Markus Neteler ===<br />
<br />
* Improve QGIS-GRASS GIS integration; update of provider to GRASS GIS 8<br />
* GRASS GIS addons overview generator for entire GitHub (and more?) based on tag "[https://github.com/topics/grass-gis-addons grass-gis-addons]"<br />
* Discuss about a 4th edition of "Open Source GIS: A GRASS GIS Approach"<br />
* message translation: Easy [https://docs.weblate.org/en/latest/user/translating.html#machine-translation machine translation] of messages in [https://weblate.osgeo.org/translate/grass-gis OSGeo-Weblate] with DeepL API<br />
** my tests with DeepL show that the quality is very good; average translation time of a user message shrinks to 15 seconds {{done}}<br />
** note: one needs to login to Weblate to see the "Automatic suggestion" button (using the OSGeo-ID)<br />
* Fix docs:<br />
** Provide better explanation for radius parameter for r.resamp.filter: https://github.com/OSGeo/grass/issues/2569<br />
** improve v.clean docs<br />
<br />
=== Vero ===<br />
<br />
* '''All - think about GRASS GIS mission and vision''': Where do we want to be as a project in 5 years time? What do we want to have? What do we want to be?<br />
* Participate in discussions about GRASS interfaces with QGIS and R (rgrass)<br />
* Discuss sponsoring<br />
* Student grant for (python) documentation?<br />
* Discuss about wiki clean-up/update (Anna was working on a list of pages) <br />
* Website enhancements: complete open PR's, meet Daniel Torres, new support item in main menu<br />
* Discuss State of GRASS presentation for FOSS4G 2023<br />
* i.landsat if time permits<br />
* ...<br />
<br />
=== You ===<br />
<br />
== Reports ==<br />
<br />
=== Caitlin Haedrich ===<br />
* Photos, social media and wiki page<br />
* grass.jupyter:<br />
** [https://github.com/OSGeo/grass/pull/2996 add feature for animating series of rasters]<br />
<br />
=== Vaclav Petras ===<br />
<br />
* Rename location to project<br />
** [https://github.com/OSGeo/grass/pull/2993 wxGUI: Rename location to project #2993]<br />
** Discussion<br />
* Python API<br />
** [https://github.com/OSGeo/grass/pull/2923 grass.experimental: Add object to access modules as functions #2923]<br />
* CI<br />
** [https://github.com/OSGeo/grass/pull/3002 CI: Switch Travis to Ubuntu 22.04 (jammmy) #3002]<br />
* Reviews and merges:<br />
** [https://github.com/OSGeo/grass/pull/2974 t.rast.algebra/testsuite: split file test_raster_algebra.py #2974]<br />
** [https://github.com/OSGeo/grass/pull/2189 Imagery: add libsvm based imagery classification #2189]<br />
** [https://github.com/OSGeo/grass-addons/pull/606 r.random.walk: Add module to create random walks #606]<br />
<br />
=== Anna Petrasova ===<br />
* [https://github.com/OSGeo/grass/pull/2992 Fix bug in querying]<br />
* review, merge and backport of [https://github.com/OSGeo/grass/pull/2994 fix in datacatalog]<br />
* review of [https://github.com/OSGeo/grass/pull/2520 wxGUI: fix show MASK statusbar button widget if mask is created]<br />
* merge of [https://github.com/OSGeo/grass/pull/2667 wxGUI: adding a button for undocking an AuiNotebook tab to wx.Frame (Single-Window GUI)]<br />
* edit [https://github.com/OSGeo/grass/pull/2990 check min required wx version when starting wxgui]<br />
<br />
=== Maris Nartiss ===<br />
<br />
* i.svm.* cleanup and preparation for a review<br />
* A conceptual proposal for a new start up screen<br />
* Initial version of imagery signature management module i.signatures<br />
* Remove obsolete parts of locale README file<br />
<br />
=== Micha Silver ===<br />
Working on a new GRASS addon: r.optram<br />
[https://github.com/micha-silver/grass-addons/tree/grass8/src/raster/r.optram the repo on github]<br />
<br />
02/06: Initialize main file ''r.optram.py''<br />
<br />
includes these functions: <br />
# ''getImgList()'' - get list of IMG_FILEs in a Sentinel 2 SAFE Directory<br />
# ''cropToAOI()'' - Crop the images to the Area of Interest<br />
# ''prepareSTR()'' - Convert SWIR to the SWIR Transformed Reflectance<br />
# ''prepareVI()'' - Prepare the (user chosen) vegetation index<br />
<br />
03/06: <br />
# Split to three modules: '''r.optram.preprocess, r.optram, r.optram.soilmoisture'''<br />
# new function: ''prepareTrapezoid()'' - to get wet-dry regression lines and slope, intercept values<br />
<br />
<br />
04/06<br />
# ''prepareTrapezoid()'' function completed.<br />
# (Joined video conf with Roger Bivand on R-GRASS integration.)<br />
<br />
05/06<br />
Initialize third file/function: ''r.optram.soilmoisture.py''<br />
# ''createSoilMoisture()'' - creates new GRASS raster for a single date<br />
# Add documentation to modules<br />
<br />
TODO list:<br />
* Read Sentinel cloud mask and mask out cloud pixels in '''r.optram.preprocess'''<br />
* large study areas or very long time series will create a big numpy table of variables (vegetation index and STR). A possible solution:<br />
# Determine some "reasonable" maximum size for the numpy table, depending on computer resources.<br />
# Extract a subset of pixels from each raster in the time series, such that the total table pixel values will not exceed that maximum<br />
# The size of the subset will be set by ("reasonable" max / number of rasters in time series)<br />
# Allow user to determine "reasonable" max.<br />
* Currently this addon consists of three sub-modules. Consider to consolidate to one.<br />
<br />
=== Luís de Sousa ===<br />
<br />
==== Work on GRASS add-on [https://grass.osgeo.org/grass82/manuals/addons/r.mblend.html r.mblend] ====<br />
<br />
* Module is still maintained and fully functional in GRASS 8.2 (now included in the [https://github.com/OSGeo/grass-addons GRASS global add-ons repository])<br />
* However was not longer producing correct results due to new behaviour in '''v.what.rast'''<br />
* Solution identified, using inner buffer to interpolation area ([https://github.com/OSGeo/grass-addons/pull/910 PR #910])<br />
* A small unit test suite was developed ([https://github.com/OSGeo/grass-addons/pull/911 PR #911])<br />
<br />
==== Documentation ====<br />
<br />
* Expanded instructions on Pre-commit ([https://github.com/OSGeo/grass/pull/3006 PR #3006])<br />
* Mini guidelines on unit tests for add-ons ([https://github.com/OSGeo/grass-addons/pull/916 PR #916])<br />
<br />
=== Aaron Saw Min Sern ===<br />
<br />
* Fix bug to complete r.univar parallelization. [https://github.com/OSGeo/grass/pull/2683 PR]<br />
<br />
=== Martin Landa ===<br />
<br />
* Check min required wx version when starting wxgui [https://github.com/OSGeo/grass/pull/2990 PR #2990]<br />
* Graphical modeler: avoid overlapping module parameters [https://github.com/OSGeo/grass/issues/2991 PR #2991]<br />
* Show ModelRelation in white on dark mode [https://github.com/OSGeo/grass/pull/2997 PR #2997]<br />
* Add OSGeo4W workflow to compile Addons [https://github.com/OSGeo/grass-addons/pull/912 PR #912]<br />
* Integrate Grapical Modeler into single window layout [https://github.com/OSGeo/grass/pull/3003 PR #3003]<br />
* Graphical Modeler: fix command parsing in "add tool" dialog [https://github.com/OSGeo/grass/pull/3022 PR #3022]<br />
<br />
=== Markus Neteler ===<br />
<br />
* backport of "HTML header charset changed from ISO-8859-1 to UTF-8" [https://github.com/OSGeo/grass/pull/2547 PR #2547] to GRASS GIS 8.2.1 (fixing r.forcircular manual encoding bug)<br />
* improve "Update alpine Docker tag to v3.18 [https://github.com/OSGeo/grass/pull/2953 PR #2953]<br />
* backport of Alpine Dockerfile improvements<br />
* discussion about "location/mapset" vs "project/..." terminology<br />
* initial QGIS-GRASS update discussion<br />
* Google Photo album feeds<br />
* Use of [https://github.com/OSGeo/grass/blob/main/doc/development/submitting/submitting.md#use-pre-commit pre-commit] (recommended to all devs!)<br />
* Participate in a two-hour meeting with Nyall Dawson (QGIS) and the GRASS Community about interfacing GRASS from QGIS<br />
* GRASS GIS manual pages: re-styling and conversion of all pages to markdown:<br />
** convert to markdown with pandoc (draft script see https://app.gitter.im/#/room/#grassgis_sprint:gitter.im discussion)<br />
** using mkdocs (https://www.mkdocs.org/): it provides menus and a search window<br />
** check: automatic formatting for mkdocs: https://github.com/KyleKing/mdformat-mkdocs<br />
<br />
=== Helmut Kudrnovsky ===<br />
<br />
* discuss (win)GRASS-R issues [https://github.com/rsbivand/rgrass/issues/57 initGrass Error] and [https://github.com/OSGeo/grass/issues/2998 feature requests]<br />
<br />
* Review and initial tests of PR [https://github.com/OSGeo/grass/pull/2684 compilation with cmake] on Windows<br />
<br />
* Participated in a two-hour meeting with Roger, Floris, Vaclav, Anna, Micha, ..... about rgrass development<br />
<br />
=== Ondřej Pešek ===<br />
<br />
* gmodeler: add export to an actinia script: [https://github.com/OSGeo/grass/pull/3005 PR #3005]<br />
* fix GRASS GIS broken for Python 3.12: [https://github.com/OSGeo/grass/pull/3009 PR #3009], [https://github.com/OSGeo/grass/pull/3010 PR #3010], [https://github.com/OSGeo/grass/pull/3011 PR #3011], [https://github.com/OSGeo/grass/pull/3018 PR #3018]<br />
* fix GRASS GIS addons broken for Python 3.12: [https://github.com/OSGeo/grass-addons/pull/917 PR #917], [https://github.com/OSGeo/grass-addons/pull/918 PR #918], [https://github.com/OSGeo/grass-addons/pull/919 PR #919]<br />
<br />
=== Floris Vanderhaeghe ===<br />
<br />
* Explore reading straight from the GRASS database into R (https://github.com/rsbivand/rgrass/issues/75)<br />
* Help arranging a meeting with Nyall Dawson for the QGIS GRASS interface <br />
* Participate in a two-hour meeting with Roger Bivand, Vero Andreo, Vaclav, Anna, Helmut, Micha, ..... about rgrass development<br />
* Participate in a two-hour meeting with Nyall Dawson (QGIS) and the GRASS Community about interfacing GRASS from QGIS<br />
<br />
=== Vero Andreo ===<br />
<br />
* Participated in the discussion about renaming locations to projects<br />
* Call with Paulo on diverse topics, r.niche.similarity PR revision and merge<br />
* Participated in a two-hour meeting with Roger, Floris, Vaclav, Anna, Helmut, Micha, ..... about rgrass development<br />
* Worked on GRASS Website:<br />
** Apply fixes and merge the [https://github.com/OSGeo/grass-website/pull/362 DOI] and [https://github.com/OSGeo/grass-website/pull/364 first draft of sponsoring tiers] PRs<br />
** Beautify tables and content of sponsoring page [https://github.com/OSGeo/grass-website/pull/368 #368]<br />
** New menu and submenus (some reordered), please comment [https://github.com/OSGeo/grass-website/pull/369 #369] <br />
** Created a news item about rgrass7 retirement with text snippet contributed by Roger Bivand [https://github.com/OSGeo/grass-website/pull/370 #370]<br />
* Other minor revisions<br />
<br />
=== Discussion with Nyall (QGIS) ===<br />
<br />
* How to improve the integration<br />
** save some of the existing code<br />
** update "Processing" integration<br />
** ...<br />
* GRASS GIS Addon support in QGIS, see<br />
** https://github.com/qgis/QGIS/pull/53048<br />
** https://github.com/qgis/QGIS/pull/53049</div>Veroandreohttps://grasswiki.osgeo.org/w/index.php?title=Talk:GRASS_Community_Meeting_Prague_2023&diff=27075Talk:GRASS Community Meeting Prague 20232023-06-04T20:09:40Z<p>Veroandreo: add Vero :)</p>
<hr />
<div>__TOC__<br />
<br />
== Tasks for participants ==<br />
<br />
* Create section for you in the Reports section.<br />
* List all the things you are working on in the section. Update the list each day. Include things you work on with other people.<br />
* Link the [https://github.com/orgs/OSGeo/projects/1/ GRASS Community Meeting Prague 2023] project on GitHub to each PR or issue you are working on or plan to be working on.<br />
* If you are or will be working on an issue or on a PR which is not originally submitted by you, assign yourself to the issue or PR. (You can unassign yourself later if you change your mind.)<br />
<br />
== Planning and organizing ==<br />
<br />
* Initial planning: Veronica Andreo, Martin Landa, Vaclav Petras, Helmut Kudrnovsky, Anna Petrasova, Huidae Cho, Markus Neteler, Helena Mitasova, Micha Silver, Linda Kladivova<br />
* Funding acquisition: Veronica Andreo, Markus Neteler, Vaclav Petras, Anna Petrasova, Huidae Cho, Luca Delucchi, Venkatesh Raghavan<br />
* Budget: Vaclav Petras, Markus Neteler, Veronica Andreo<br />
* Venue and local organizing: Martin Landa<br />
* T-shirts, hoodies, stickers: Vaclav Petras, Anna Petrasova<br />
* Promotion, invitations, and social media: Caitlin Haedrich, Veronica Andreo, Vaclav Petras<br />
* Wiki page: Martin Landa, Markus Neteler, Vaclav Petras, Veronica Andreo<br />
* Virtual meeting organizing: Veronica Andreo<br />
* Photography: Caitlin Haedrich<br />
<br />
== Ideas for the meeting agenda ==<br />
<br />
Collect ideas here :-)<br />
<br />
=== Markus Neteler ===<br />
<br />
* Improve QGIS-GRASS GIS integration; update of provider to GRASS GIS 8<br />
* GRASS GIS addons overview generator for entire GitHub (and more?) based on tag "[https://github.com/topics/grass-gis-addons grass-gis-addons]"<br />
* Discuss about a 4th edition of "Open Source GIS: A GRASS GIS Approach"<br />
* message translation: Easy [https://docs.weblate.org/en/latest/user/translating.html#machine-translation machine translation] of messages in [https://weblate.osgeo.org/translate/grass-gis OSGeo-Weblate] with DeepL API<br />
** my tests with DeepL show that the quality is very good; average translation time of a user message shrinks to 15 seconds {{done}}<br />
** note: one needs to login to Weblate to see the "Automatic suggestion" button (using the OSGeo-ID)<br />
* Fix docs:<br />
** Provide better explanation for radius parameter for r.resamp.filter: https://github.com/OSGeo/grass/issues/2569<br />
** improve v.clean docs<br />
<br />
=== Vero ===<br />
<br />
* '''All - think about GRASS GIS mission and vision''': Where do we want to be as a project in 5 years time? What do we want to have? What do we want to be?<br />
* Participate in discussions about GRASS interfaces with QGIS and R (rgrass)<br />
* Discuss sponsoring<br />
* Student grant for (python) documentation?<br />
* Discuss about wiki clean-up/update (Anna was working on a list of pages) <br />
* Website enhancements: complete open PR's, meet Daniel Torres, new support item in main menu<br />
* Discuss State of GRASS presentation for FOSS4G 2023<br />
* i.landsat if time permits<br />
* ...<br />
<br />
=== You ===<br />
<br />
== Reports ==<br />
<br />
=== Caitlin Haedrich ===<br />
* Photos, social media and wiki page<br />
* grass.jupyter:<br />
** [https://github.com/OSGeo/grass/pull/2996 add feature for animating series of rasters]<br />
<br />
=== Vaclav Petras ===<br />
<br />
* Rename location to project<br />
** [https://github.com/OSGeo/grass/pull/2993 wxGUI: Rename location to project #2993]<br />
** Discussion<br />
* Python API<br />
** [https://github.com/OSGeo/grass/pull/2923 grass.experimental: Add object to access modules as functions #2923]<br />
* CI<br />
** [https://github.com/OSGeo/grass/pull/3002 CI: Switch Travis to Ubuntu 22.04 (jammmy) #3002]<br />
* Reviews and merges:<br />
** [https://github.com/OSGeo/grass/pull/2974 t.rast.algebra/testsuite: split file test_raster_algebra.py #2974]<br />
** [https://github.com/OSGeo/grass/pull/2189 Imagery: add libsvm based imagery classification #2189]<br />
** [https://github.com/OSGeo/grass-addons/pull/606 r.random.walk: Add module to create random walks #606]<br />
<br />
=== Anna Petrasova ===<br />
* [https://github.com/OSGeo/grass/pull/2992 Fix bug in querying]<br />
* review, merge and backport of [https://github.com/OSGeo/grass/pull/2994 fix in datacatalog]<br />
* review of [https://github.com/OSGeo/grass/pull/2520 wxGUI: fix show MASK statusbar button widget if mask is created]<br />
* merge of [https://github.com/OSGeo/grass/pull/2667 wxGUI: adding a button for undocking an AuiNotebook tab to wx.Frame (Single-Window GUI)]<br />
* edit [https://github.com/OSGeo/grass/pull/2990 check min required wx version when starting wxgui]<br />
<br />
=== Maris Nartiss ===<br />
<br />
* i.svm.* cleanup and preparation for a review<br />
* A conceptual proposal for a new start up screen<br />
* Initial version of imagery signature management module i.signatures<br />
* Remove obsolete parts of locale README file<br />
<br />
=== Micha Silver ===<br />
Working on a new GRASS addon: r.optram<br />
[https://github.com/micha-silver/grass-addons/tree/grass8/src/raster/r.optram the repo on github]<br />
<br />
02/06: Initialize main file ''r.optram.py''<br />
<br />
includes these functions: <br />
# getImgList() - get list of IMG_FILEs in a Sentinel 2 SAFE Directory<br />
# cropToAOI() - Crop the images to the Area of Interest<br />
# prepareSTR() - Convert SWIR to the SWIR Transformed Reflectance<br />
# prepareVI() - Prepare the (user chosen) vegetation index<br />
<br />
03/06: <br />
# Split to three modules: r.optram.preprocess, r.optram, r.optram.soilmoisture<br />
# new function: ''prepareTrapezoid()'' - to get wet-dry regression lines and slope, intercept values<br />
<br />
04/06<br />
Initialize second file/function: ''r.optram.soilmoisture.py''<br />
# createSoilMoisture() - creates new GRASS raster<br />
<br />
=== Luís de Sousa ===<br />
<br />
==== Work on GRASS add-on [https://grass.osgeo.org/grass82/manuals/addons/r.mblend.html r.mblend] ====<br />
<br />
* Module is still maintained and fully functional in GRASS 8.2 (now included in the [https://github.com/OSGeo/grass-addons GRASS global add-ons repository])<br />
* However was not longer producing correct results due to new behaviour in '''v.what.rast'''<br />
* Solution identified, using inner buffer to interpolation area ([https://github.com/OSGeo/grass-addons/pull/910 PR #910])<br />
* A small unit test suite was developed ([https://github.com/OSGeo/grass-addons/pull/911 PR #911])<br />
<br />
==== Documentation ====<br />
<br />
* Expanded instructions on Pre-commit ([https://github.com/OSGeo/grass/pull/3006 PR #3006])<br />
* Mini guidelines on unit tests for add-ons ([https://github.com/OSGeo/grass-addons/pull/916 PR #916])<br />
<br />
=== Aaron Saw Min Sern ===<br />
<br />
* Fix bug to complete r.univar parallelization. [https://github.com/OSGeo/grass/pull/2683 PR]<br />
<br />
=== Martin Landa ===<br />
<br />
* Check min required wx version when starting wxgui [https://github.com/OSGeo/grass/pull/2990 PR #2990]<br />
* Graphical modeler: avoid overlapping module parameters [https://github.com/OSGeo/grass/issues/2991 PR #2991]<br />
* Show ModelRelation in white on dark mode [https://github.com/OSGeo/grass/pull/2997 PR #2997]<br />
* Add OSGeo4W workflow to compile Addons [https://github.com/OSGeo/grass-addons/pull/912 PR #912]<br />
* Integrate Grapical Modeler into single window layout [https://github.com/OSGeo/grass/pull/3003 PR #3003]<br />
<br />
=== Markus Neteler ===<br />
<br />
* backport of "HTML header charset changed from ISO-8859-1 to UTF-8" [https://github.com/OSGeo/grass/pull/2547 PR #2547] to GRASS GIS 8.2.1 (fixing r.forcircular manual encoding bug)<br />
* improve "Update alpine Docker tag to v3.18 [https://github.com/OSGeo/grass/pull/2953 PR #2953]<br />
* backport of Alpine Dockerfile improvements<br />
* discussion about "location/mapset" vs "project/..." terminology<br />
* initial QGIS-GRASS update discussion<br />
* Google Photo album feeds<br />
* Use of [https://github.com/OSGeo/grass/blob/main/doc/development/submitting/submitting.md#use-pre-commit pre-commit] (recommended to all devs!)<br />
* GRASS GIS manual pages: re-styling and conversion of all pages to markdown:<br />
** convert to markdown with pandoc (draft script see https://app.gitter.im/#/room/#grassgis_sprint:gitter.im discussion)<br />
** using mkdocs (https://www.mkdocs.org/): it provides menus and a search window<br />
** check: automatic formatting for mkdocs: https://github.com/KyleKing/mdformat-mkdocs<br />
<br />
=== Helmut Kudrnovsky ===<br />
<br />
* discuss (win)GRASS-R issues [https://github.com/rsbivand/rgrass/issues/57 initGrass Error] and [https://github.com/OSGeo/grass/issues/2998 feature requests]<br />
<br />
* Review and initial tests of PR [https://github.com/OSGeo/grass/pull/2684 compilation with cmake] on Windows<br />
<br />
=== Ondřej Pešek ===<br />
<br />
* gmodeler: add export to an actinia script: [https://github.com/OSGeo/grass/pull/3005 PR #3005]<br />
* fix GRASS GIS broken for Python 3.12: [https://github.com/OSGeo/grass/pull/3009 PR #3009], [https://github.com/OSGeo/grass/pull/3010 PR #3010], [https://github.com/OSGeo/grass/pull/3011 PR #3011]<br />
<br />
=== Floris Vanderhaeghe ===<br />
<br />
* Explore reading straight from the GRASS database into R (https://github.com/rsbivand/rgrass/issues/75)<br />
* Help arranging a meeting with Nyall Dawson for the QGIS GRASS interfase <br />
* Participate in a two-hour meeting with Roger Bivand, Vero Andreo, Vaclav, Anna, Helmut, Micha, ..... about rgrass development<br />
<br />
=== Vero Andreo ===<br />
<br />
* Participated in the discussion about renaming locations to projects<br />
* Call with Paulo on diverse topics, r.niche.similarity PR revision and merge<br />
* Participated in a two-hour meeting with Roger, Floris, Vaclav, Anna, Helmut, Micha, ..... about rgrass development<br />
* Worked on GRASS Website:<br />
** Apply fixes and merge the [https://github.com/OSGeo/grass-website/pull/362 DOI] and [https://github.com/OSGeo/grass-website/pull/364 first draft of sponsoring tiers] PRs<br />
** Beautify tables and content of sponsoring page [https://github.com/OSGeo/grass-website/pull/368 #368]<br />
** New menu and submenus (some reordered), please comment [https://github.com/OSGeo/grass-website/pull/369 #369] <br />
* Other minor revisions</div>Veroandreohttps://grasswiki.osgeo.org/w/index.php?title=GRASS_Community_Meeting_Prague_2023&diff=26966GRASS Community Meeting Prague 20232023-05-09T17:29:59Z<p>Veroandreo: /* Purpose */</p>
<hr />
<div>{{toc|right}}<br />
The GRASS GIS team is organizing the ''GRASS GIS Community Meeting with contributors, power users and developers'' from '''June 2 to June 6, 2023''' to celebrate GRASS GIS '''40th birthday'''. <br />
<br />
<gallery mode="slideshow"><br />
Image:grass-sprint-prague.jpg|Prague 2013<br />
Image:Grass_sprint2018_bonn_fotowall.jpg|Bonn 2018<br />
</gallery><br />
<br />
== Purpose ==<br />
<br />
GRASS GIS Community Meeting is a great occasion for folks to support the development by actively contributing to the source code, documentation (manuals, wiki, tutorials), translations, website or likewise. The '''community''' meeting is also a get-together where supporters, contributors, power users and developers make decisions and tackle larger problems related to the project, discuss and collaboratively resolve bugs, plan the direction for the project and work on new features. We welcome people committed to improving the GRASS GIS project and the interfaces to QGIS, GDAL, PostGIS, R, OGC Services and desiring to '''celebrate with us the 40th GRASS GIS birthday!!'''<br />
<br />
In this meeting, we will work on GRASS GIS and integrations with related OSGeo projects. We will revise connection to QGIS to make it easier to maintain, and we will migrate the build to CMake to improve Windows builds including PDAL support. Furthermore, we will move documentation to Markdown to make it easier to contribute to and we will add images and examples for tools and workflows which still miss them. Finally, we will automate and document maintenance processes to reduce the burden on maintainers and thus improve the project sustainability. <br />
<br />
Note that while we have our general plan, we can't accept any earmarked donations, i.e., we can't make any promises for a specific work to be done. We do require participants to work on GRASS GIS or connections to other projects. However, we leave them the freedom to work on what they think is the best contribution to the project at that time given their skills and time available.<br />
<br />
For the detailed agenda and individual's plans, see below.<br />
<br />
== Sponsors ==<br />
<br />
We welcome '''financial contributions''' to support the meeting and we are looking for sponsors to cover costs such as meals or to help reducing travel and accommodation expenses for GRASS developers who volunteer their time. If you are interested in sponsoring the GRASS Community Meeting, please see our<br />
<br />
::: '''[https://opencollective.com/osgeo/projects/grass/contribute/grass-community-meeting-prague-2023-55074 OpenCollective GRASS Community Meeting Prague 2023 Tier]'''<br />
<br />
Any surplus at the end of the event will used for future activities of the GRASS GIS project such as the successful [[Student Grants|student mini grant program]].<br />
<br />
This GRASS Community Meeting is a great occasion for you to support the development of GRASS. With your contribution you'll enable more developers to meet. Community meetings are important opportunities for developers to discuss, fix bugs, plan the direction for the project and work on new features. Please see below for the detailed agenda. The developers and contributors are donating their valuable time, so it would be great if in-kind funding can be made available from within the community to cover out-of-pocket expenses. All of the work that takes place at the community meeting will be directly contributed back into the GRASS project to the benefit of everyone who uses it.<br />
<br />
=== Thanks to our sponsors ===<br />
<br />
We are grateful for the support which we have received to organize this GRASS Community Meeting:<br />
<br />
[[File:Osgeo logo.png|none|left|alt=Light and dark green logo of OSGeo saying Your Open Source Compass|Open Source Geospatial Foundation]]<br />
* OSGeo: 7303 USD (approved budget contribution, [https://www.loomio.com/p/2m75BZkL/motion-to-approve-7303-to-support-grass-gis-community-meeting motion])<br />
<br />
[[File:FOSSGIS_eV_logo.png|none|left|400px|alt=Logo of FOSSGIS e.V.|FOSSGIS e.V.]]<br />
* FOSSGIS e.V.: 5000 EUR<br />
<br />
Individuals:<br />
* MarWe 50 USD<br />
* Nick Brady 50 USD<br />
* Johannes Brauner 30 USD<br />
* Joaquin Perez Valera 5 USD<br />
* Anonymous sponsors 2750 USD<br />
<br />
In-kind contributions:<br />
<br />
* Faculty of Civil Engineering Czech Technical University in Prague (FCE CTU) - space and personnel time (planning, preparation)<br />
* North Carolina State University - personnel time (planning, preparation)<br />
* mundialis GmbH & Co. KG - personnel time (planning, preparation)<br />
* CONICET - personnel time (planning, preparation)<br />
<br />
== Timing ==<br />
<br />
'''When''': June 2-6, 2023<br />
<br />
Of course you are invited to join or leave the meeting whenever you want.<br />
<br />
== Venue ==<br />
<br />
[[Image:logo_cvut.jpg|130px|left]]<br />
Department of Geomatics<br><br />
[https://www.fsv.cvut.cz/?lang=en Faculty of Civil Engineering]<br><br />
[https://www.cvut.cz/en Czech Technical University in Prague], {{wikipedia|Czech Republic}}<br><br />
Thákurova 7/2077, Prague<br><br />
Room B868<br><br />
[https://en.mapy.cz/s/debazefuse Map]<br><br />
<br />
Prague has an international [http://www.prg.aero/en/ airport] and is also reachable by train, bus or car.<br />
<br />
== Accommodation and Costs ==<br />
<br />
Participants should plan for the following costs:<br />
<br />
* The participation is free of charge<br />
* Travel to Prague, variable depending on where you come from, reimbursements depending on the financial contributions provided by the community<br />
* Accommodation and meals (with the donated sponsorship money we will try to cover some expenses of the participants)<br />
'''Please note''': The currency in Czech Republic is {{wikipedia|Czech crown}} (CZK, koruna, Kč). 100 Czech crowns are about 4 Euros (see [https://www.cnb.cz/cs/financni-trhy/devizovy-trh/kurzy-devizoveho-trhu/kurzy-devizoveho-trhu/ current rates]).<br />
<br />
Please let us know your time of arrival and departure, so we can book accommodations and organize the logistics.<br />
<br />
Financial support: (partial) travel grants can be payed upon request thanks to our sponsors!<br />
<br />
== Agenda - What we plan to do ==<br />
<br />
'''Note:''' The program is generally open for your ideas. Please write an email to the [http://lists.osgeo.org/mailman/listinfo/grass-dev GRASS developer list] to discuss your contribution.<br />
<br />
During the meeting we will work on GRASS GIS on these tasks (please add more!):<br />
<br />
* We will update and revise the [https://github.com/qgis/QGIS/tree/master/python/plugins/grassprovider GRASS GIS Integration with QGIS] to simplify maintenance.<br />
* Furthermore, we will migrate the compilation technology to CMake to significantly improve the Windows builds including PDAL support and become binary compatible with OSGeo4W.<br />
* The extensive GRASS documentation will be converted from HTML to Markdown to facilitate future collaboration.<br />
* Pictures, examples and workflows will be added to the documentation where they are still missing.<br />
* Software maintenance processes are automated and documented to reduce the burden on maintainers and thus improve the sustainability of the project.<br />
<br />
This means that there are tasks from both the programming and documentation areas to appeal to a wide range of interested parties.<br />
<br />
Further details about the action items you '''find [[Talk:GRASS Community Meeting Prague 2023|here]]''' and below. Topics cover non-technical, semi-technical, and technical issues.<br />
<br />
=== Timeline ===<br />
<br />
(agenda is under development, but also flexible)<br />
<br />
==== Thursday, 1 June ====<br />
<br />
* Arrival<br />
<br />
==== Friday, 2 June ====<br />
<br />
* 10:00 meeting starts in the room B-868<br />
* API for use in Python and in other projects (e.g., QGIS)<br />
<br />
==== Saturday, 3 June ====<br />
<br />
* Reducing cost of distribution on Windows<br />
* Group photo 1<br />
<br />
==== Sunday, 4 June ====<br />
<br />
* Compilation CMake (Windows, Linux)<br />
* Connections in general, rgrass, qgisprocess<br />
* Group photo 2<br />
<br />
==== Monday, 5 June ====<br />
<br />
* Connections in general, QGIS, rgrass, qgisprocess<br />
<br />
==== Tuesday, 6 June ====<br />
<br />
* Connections in general, QGIS<br />
<br />
==== Wednesday, 7 June ====<br />
<br />
* Departure<br />
<br />
== Participation ==<br />
<br />
We are planning for an attendance of 20 people (i.e., coding places) but of course you are welcome to join us and bring new ideas with you: we'll make more places available. Please add your name here or contact [[User:Landa|Martin Landa]] <tt><landa.martin at gmail.com></tt>:<br />
<br />
=== In person ===<br />
<br />
{|class="wikitable sortable" border="2" cellspacing="0" cellpadding="4" rules="all" style="margin:1em 1em 1em 0; border:solid 1px #AAAAAA; border-collapse:collapse; background-color:#edf9c7; font-size:95%; empty-cells:show;" <br />
!width=50px|'''Number'''<br />
!width=130px|'''Participant '''<br />
!width=100px|'''Country'''<br />
!width=100px|'''Arrival'''<br />
!width=100px|'''Departure'''<br />
!'''Topics'''<br />
!width=75px|'''T-Shirt'''<br />
!'''Notes'''<br />
|-<br />
|1<br />
|[[User:Landa|Martin Landa]]<br />
| Czech Republic<br />
| June 1<br />
| June 7<br />
| Python: create_location ([https://github.com/OSGeo/grass/issues/1987 #1987]), Graphical Modeler improvements and single window layout integration<br />
| XL<br />
|<br />
|-<br />
|2<br />
| Micha Silver<br />
| Israel<br />
| June 2<br />
| June 6<br />
| Addon to derive soil moisture from Sentinel 2<br />
| XXL<br />
|<br />
|-<br />
|3<br />
|[https://www.osgeo.org/member/kudrnovsky/ Helmut Kudrnovsky]<br />
| Austria<br />
| June 2 (18:37) by train<br />
| June 4 (18:24) by train <br />
| <br />
| L<br />
|<br />
|-<br />
|4<br />
|[[User:Neteler|Markus Neteler]]<br />
| Germany<br />
| June 2 (17:17)<br />
| June 6 (12:43)<br />
| translations, manual pages, ..., see [[Talk:GRASS_Community_Meeting_Prague_2023#Markus_Neteler|my list in "Discussion" page]]<br />
| L<br />
|<br />
|-<br />
|5<br />
|[[User:pesekon2|Ondřej Pešek]]<br />
| Czech Republic<br />
| June 2 (17:17)<br />
| June 6 (12:43)<br />
| Python 3.12-connected issues, gmodeler<br />
| M<br />
|<br />
|-<br />
|6<br />
| [[User:helena|Helena Mitasova]]<br />
| United States <br />
| June 2<br />
| June 6<br />
|<br />
| S<br />
|<br />
|-<br />
|7<br />
| [[User:wenzeslaus|Vaclav Petras]]<br />
| United States <br />
| June 1<br />
| June 7<br />
| init and other Python API topics, support CMake transition, revise connection with QGIS and other tools, funding<br />
| M<br />
|<br />
|-<br />
|8<br />
| [[User:Annakrat|Anna Petrasova]]<br />
| United States <br />
| June 1<br />
| June 7<br />
| parallelization documentation, grass.jupyter, R and QGIS integration<br />
| S<br />
|<br />
|-<br />
|9<br />
| [[User:Ctwhite|Corey White]]<br />
| United States <br />
| June 2 (10:55)<br />
| June 7<br />
| Connections with other tools, OpenPlains, JSON outputs<br />
| XL<br />
|<br />
|-<br />
|10<br />
| [[User:MarisN|Maris Nartiss]]<br />
| Latvia<br />
| June 2<br />
| June 6<br />
| <br />
| XL<br />
|-<br />
|11<br />
| [[User:Aaronsms|Aaron Saw Min Sern]]<br />
| Singapore<br />
| June 1<br />
| June 7<br />
| Support CMake transition, r.mapcalc parallelization<br />
| XS (or S)<br />
| Possibly attending virtually (TBC)<br />
|-<br />
|12<br />
| [[User:Ldesousa|Luís de Sousa]]<br />
| The Netherlands<br />
| June 1 (20:00)<br />
| June 5 (20:45)<br />
| Update r.mblend add-on; test CMake transition.<br />
| M<br />
| <br />
|-<br />
|13<br />
| [[User:Chaedrich|Caitlin Haedrich]]<br />
| United States<br />
| June 1<br />
| June 7<br />
| grass.jupyter<br />
| S<br />
|<br />
|-<br />
|14<br />
| [[User:Lindakladivova|Linda Kladivová]]<br />
| Czech Republic<br />
| June 2<br />
| June 6<br />
| <br />
| M<br />
|<br />
|-<br />
|15<br />
| Carmen Tawalika<br />
| Germany<br />
| June 2 (17:17)<br />
| June 6 (12:43)<br />
| Happy to assist with general topics like documentation + automation, in doubt something related to actinia<br />
| M<br />
| <br />
|-<br />
|16<br />
| Floris Vanderhaeghe<br />
| Belgium<br />
| June 3 (train 19:17)<br />
| June 6 (train 8:25)<br />
| Helping in interfacing GRASS from R (rgrass & qgisprocess packages)<br />
| L<br />
| <br />
|-<br />
|}<br />
<br />
If you are arriving or departing on the days of the event, please specify the time, too.<br />
<br />
=== Via chat or hangout ===<br />
<br />
Join our [https://app.gitter.im/#/room/#grassgis_community:gitter.im Gitter chatroom]<br />
<br />
TBD: Google Meet / Zoom / ???<br />
<br />
Participating virtually:<br />
<br />
{|class="wikitable sortable" border="2" cellspacing="0" cellpadding="4" rules="all" style="margin:1em 1em 1em 0; border:solid 1px #AAAAAA; border-collapse:collapse; background-color:#edf9c7; font-size:95%; empty-cells:show;" <br />
!width=50px|'''Number'''<br />
!width=130px|'''Participant '''<br />
!width=100px|'''Country'''<br />
!'''Topics'''<br />
!'''Notes'''<br />
|-<br />
|1<br />
|[[User:Baharmon|Brendan Harmon]]<br />
| United States<br />
| Update integration with QGIS<br />
|<br />
|-<br />
|2<br />
|[[User:veroandreo|Veronica Andreo]]<br />
| Argentina<br />
| Mission and vision, interfaces with QGIS and R, sponsoring, ... [https://grasswiki.osgeo.org/wiki/Talk:GRASS_Community_Meeting_Prague_2023#Vero see discussion tab]<br />
|<br />
|-<br />
|}<br />
<br />
<br />
==== Timing of hangout meetings ====<br />
<br />
Vero: available from 8:00 AM ART (UTC-3) onward<br />
<br />
=== Collaborative document scratching ===<br />
<br />
TBD<br />
<br />
== Individual Preparation ==<br />
<br />
<br />
* Bring your own computer<br />
* Bring {{wikipedia|AC adapter|power connector adapter}} if needed (Czech Republic: 230V, 50Hz, {{wikipedia|File:Euro-Flachstecker_2.jpg|Type C Europlugs}} are common and also {{wikipedia|File:French_plug_and_socket.jpg|Type E}})<br />
* Install subversion and the compiler tools, and come with a working GRASS development environment if possible.<br />
<br />
== Broadcast & Video ==<br />
<br />
During the event :)<br />
<br />
== Photos ==<br />
<br />
Also during the event :)<br />
<br />
== FAQ ==<br />
<br />
* '''How was it last time?'''<br />
** Very nice, see [[GRASS_GIS at OSGeo Virtual Community Sprint 2020]]!<br />
* ''Is the GRASS Community Meeting just a coding event?''<br />
** It is mainly a coding and documentation event. It is a working session for people who are already participants in the GRASS project and/or are committed to improving the GRASS project.<br />
** On demand we can do some presentations of current working GRASS implementation and new upcoming features to spread the idea of Open Source GIS software.<br />
* ''Is the GRASS Community Meeting for developers only?''<br />
** No: anybody can help, with testing, checking out bugs and fixes, documentation and more.<br />
* ''Where can I get help and more information about the community meeting?''<br />
** Contact [[User:Landa|Martin Landa]] <tt><landa.martin at gmail.com></tt><br />
<br />
== Report and press release ==<br />
<br />
TBD: After the event :-)<br />
<br />
We'll esp. craft a report for our sponsors.<br />
<br />
[[Category: Workshops]]<br />
[[Category: Code Sprint]]<br />
[[Category: 2023]]</div>Veroandreohttps://grasswiki.osgeo.org/w/index.php?title=Talk:GRASS_Community_Meeting_Prague_2023&diff=26962Talk:GRASS Community Meeting Prague 20232023-05-09T16:32:37Z<p>Veroandreo: </p>
<hr />
<div>__TOC__<br />
<br />
== Planning and organizing ==<br />
<br />
* Initial planning: Veronica Andreo, Martin Landa, Vaclav Petras, Helmut Kudrnovsky, Anna Petrasova, Huidae Cho, Markus Neteler, Helena Mitasova, Micha Silver, Linda Kladivova<br />
* Funding acquisition: Veronica Andreo, Markus Neteler, Vaclav Petras, Anna Petrasova, Huidae Cho, Luca Delucchi, Venkatesh Raghavan<br />
* Budget: Vaclav Petras, Markus Neteler, Veronica Andreo<br />
* Venue and local organizing: Martin Landa<br />
* T-shirts, hoodies, stickers: Vaclav Petras, Anna Petrasova<br />
* Promotion, invitations, and social media: Veronica Andreo, Vaclav Petras<br />
* Wiki page: Martin Landa, Markus Neteler, Vaclav Petras, Veronica Andreo<br />
<br />
== Ideas for the meeting agenda ==<br />
<br />
Collect ideas here :-)<br />
<br />
=== Markus Neteler ===<br />
<br />
* Discuss about a 4th edition of "Open Source GIS: A GRASS GIS Approach"<br />
* Easy [https://docs.weblate.org/en/latest/user/translating.html#machine-translation machine translation] of messages in [https://weblate.osgeo.org/translate/grass-gis OSGeo-Weblate] with DeepL API<br />
** my tests with DeepL show that the quality is very good; average translation time of a user message shrinks to 15 seconds<br />
** note: one needs to login to Weblate to see the "Automatic suggestion" button (using the OSGeo-ID)<br />
* Re-styling of all GRASS GIS manual pages:<br />
** convert to markdown<br />
** using mkdocs (https://www.mkdocs.org/): it provides menus and a search window<br />
<br />
=== Vero ===<br />
<br />
* '''All - think about GRASS GIS mission and vision''': Where do we want to be as a project in 5 years time? What do we want to have? What do we want to be?<br />
* Participate in discussions about GRASS interfaces with QGIS and R (rgrass)<br />
* Discuss sponsoring<br />
* Student grant for (python) documentation?<br />
* Discuss about wiki clean-up/update (Anna was working on a list of pages) <br />
* Website enhancements: complete open PR's, meet Daniel Torres, new support item in main menu<br />
* Discuss State of GRASS presentation for FOSS4G 2023<br />
* i.landsat if time permits<br />
* ...<br />
<br />
=== You ===</div>Veroandreohttps://grasswiki.osgeo.org/w/index.php?title=Talk:GRASS_Community_Meeting_Prague_2023&diff=26931Talk:GRASS Community Meeting Prague 20232023-05-04T12:40:43Z<p>Veroandreo: /* Vero */</p>
<hr />
<div>__TOC__<br />
<br />
== Ideas for the meeting agenda ==<br />
<br />
Collect ideas here :-)<br />
<br />
=== Markus Neteler ===<br />
<br />
* Discuss about a 4th edition of "Open Source GIS: A GRASS GIS Approach"<br />
* Easy [https://docs.weblate.org/en/latest/user/translating.html#machine-translation machine translation] of messages in [https://weblate.osgeo.org/translate/grass-gis OSGeo-Weblate] with DeepL API<br />
** my tests with DeepL show that the quality is very good; average translation time of a user message shrinks to 15 seconds<br />
** note: one needs to login to Weblate to see the "Automatic suggestion" button (using the OSGeo-ID)<br />
* Re-styling of all GRASS GIS manual pages:<br />
** convert to markdown<br />
** using mkdocs (https://www.mkdocs.org/): it provides menus and a search window<br />
<br />
=== Vero ===<br />
<br />
* '''All - think about GRASS GIS mission and vision''': Where do we want to be as a project in 5 years time? What do we want to have? What do we want to be?<br />
* Participate in discussions about GRASS interfaces with QGIS and R (rgrass)<br />
* Discuss sponsoring<br />
* Student grant for (python) documentation?<br />
* Discuss about wiki clean-up/update (Anna was working on a list of pages) <br />
* Website enhancements: complete open PR's, meet Daniel Torres, new support item in main menu<br />
* Discuss State of GRASS presentation for FOSS4G 2023<br />
* i.landsat if time permits<br />
* ...<br />
<br />
=== You ===</div>Veroandreohttps://grasswiki.osgeo.org/w/index.php?title=GRASS_Community_Meeting_Prague_2023&diff=26928GRASS Community Meeting Prague 20232023-05-03T22:46:01Z<p>Veroandreo: /* Via chat or hangout */</p>
<hr />
<div>{{toc|right}}<br />
The GRASS GIS team is organizing the ''GRASS GIS Community Meeting with contributors, power users and developers'' from '''June 2 to June 6, 2023''' to celebrate GRASS GIS '''40th birthday'''. <br />
<br />
<gallery mode="slideshow"><br />
Image:grass-sprint-prague.jpg|Prague 2013<br />
Image:Grass_sprint2018_bonn_fotowall.jpg|Bonn 2018<br />
</gallery><br />
<br />
== Purpose ==<br />
<br />
GRASS GIS Community Meeting is a great occasion for folks to support the development by actively contributing to the source code, documentation (manuals, wiki, tutorials), translations, website or likewise. The '''community''' meeting is also a get-together where supporters, contributors, power users and developers make decisions and tackle larger problems related to the project, discuss and collaboratively resolve bugs, plan the direction for the project and work on new features. We welcome people committed to improving the GRASS GIS project and the interfaces to QGIS, GDAL, PostGIS, R statistics, OGC Services and willing to '''celebrate with us the 40th GRASS GIS birthday!!'''<br />
<br />
For the detailed agenda, see below.<br />
<br />
== Sponsors ==<br />
<br />
We welcome '''financial contributions''' to support the meeting and we are looking for sponsors to cover costs such as meals or to help reducing travel and accommodation expenses for GRASS developers who volunteer their time. If you are interested in sponsoring the GRASS Community Meeting, please see our<br />
<br />
::: '''[https://opencollective.com/osgeo/projects/grass/contribute/grass-community-meeting-prague-2023-55074 OpenCollective GRASS Community Meeting Prague 2023 Tier]'''<br />
<br />
Any surplus at the end of the event will used for future activities of the GRASS GIS project such as the successful [[Student Grants|student mini grant program]].<br />
<br />
This GRASS Community Meeting is a great occasion for you to support the development of GRASS. With your contribution you'll enable more developers to meet. Community meetings are important opportunities for developers to discuss, fix bugs, plan the direction for the project and work on new features. Please see below for the detailed agenda. The developers and contributors are donating their valuable time, so it would be great if in-kind funding can be made available from within the community to cover out-of-pocket expenses. All of the work that takes place at the community meeting will be directly contributed back into the GRASS project to the benefit of everyone who uses it.<br />
<br />
=== Thanks to our sponsors ===<br />
<br />
We are grateful for the support which we have received to organize this GRASS Community Meeting:<br />
<br />
[[File:Osgeo logo.png|none|left|alt=Light and dark green logo of OSGeo saying Your Open Source Compass|Open Source Geospatial Foundation]]<br />
* OSGeo: 7303 USD (approved budget contribution, [https://www.loomio.com/p/2m75BZkL/motion-to-approve-7303-to-support-grass-gis-community-meeting motion])<br />
<br />
[[File:FOSSGIS_eV_logo.png|none|left|400px|alt=Logo of FOSSGIS e.V.|FOSSGIS e.V.]]<br />
* FOSSGIS e.V.: 5000 EUR<br />
<br />
Individuals:<br />
* MarWe 50 USD<br />
* Nick Brady 50 USD<br />
* Johannes Brauner 30 USD<br />
* Joaquin Perez Valera 5 USD<br />
* Anonymous sponsors 2750 USD<br />
<br />
In-kind contributions:<br />
<br />
* Faculty of Civil Engineering Czech Technical University in Prague (FCE CTU) - space and personnel time (planning, preparation)<br />
* North Carolina State University - personnel time (planning, preparation)<br />
* mundialis GmbH & Co. KG - personnel time (planning, preparation)<br />
* CONICET - personnel time (planning, preparation)<br />
<br />
== Timing ==<br />
<br />
'''When''': June 2-6, 2023<br />
<br />
Of course you are invited to join or leave the meeting whenever you want.<br />
<br />
== Venue ==<br />
<br />
[[Image:logo_cvut.jpg|130px|left]]<br />
Department of Geomatics<br><br />
[https://www.fsv.cvut.cz/?lang=en Faculty of Civil Engineering]<br><br />
[https://www.cvut.cz/en Czech Technical University in Prague], {{wikipedia|Czech Republic}}<br><br />
Thákurova 7/2077, Prague<br><br />
Room B868<br><br />
[https://en.mapy.cz/s/debazefuse Map]<br><br />
<br />
Prague has an international [http://www.prg.aero/en/ airport] and is also reachable by train, bus or car.<br />
<br />
== Accommodation and Costs ==<br />
<br />
Participants should plan for the following costs:<br />
<br />
* The participation is free of charge<br />
* Travel to Prague, variable depending on where you come from, reimbursements depending on the financial contributions provided by the community<br />
* Accommodation and meals (with the donated sponsorship money we will try to cover some expenses of the participants)<br />
'''Please note''': The currency in Czech Republic is {{wikipedia|Czech crown}} (CZK, koruna, Kč). 100 Czech crowns are about 4 Euros (see [https://www.cnb.cz/cs/financni-trhy/devizovy-trh/kurzy-devizoveho-trhu/kurzy-devizoveho-trhu/ current rates]).<br />
<br />
Please let us know your time of arrival and departure, so we can book accommodations and organize the logistics.<br />
<br />
Financial support: (partial) travel grants can be payed upon request thanks to our sponsors!<br />
<br />
== Agenda - What we plan to do ==<br />
<br />
'''Note:''' The program is generally open for your ideas. Please write an email to the [http://lists.osgeo.org/mailman/listinfo/grass-dev GRASS developer list] to discuss your contribution.<br />
<br />
During the meeting we will work on GRASS GIS on these tasks (please add more!):<br />
<br />
* We will update and revise the [https://github.com/qgis/QGIS/tree/master/python/plugins/grassprovider GRASS GIS Integration with QGIS] to simplify maintenance.<br />
* Furthermore, we will migrate the compilation technology to CMake to significantly improve the Windows builds including PDAL support and become binary compatible with OSGeo4W.<br />
* The extensive GRASS documentation will be converted from HTML to Markdown to facilitate future collaboration.<br />
* Pictures, examples and workflows will be added to the documentation where they are still missing.<br />
* Software maintenance processes are automated and documented to reduce the burden on maintainers and thus improve the sustainability of the project.<br />
<br />
This means that there are tasks from both the programming and documentation areas to appeal to a wide range of interested parties.<br />
<br />
Further details about the action items you '''find [[Talk:GRASS Community Meeting Prague 2023|here]]''' and below. Topics cover non-technical, semi-technical, and technical issues.<br />
<br />
=== Timeline ===<br />
<br />
Will be specified later.<br />
<br />
==== Thursday, 1 June ====<br />
<br />
* Arrival<br />
<br />
==== Friday, 2 June ====<br />
<br />
* 10:00 meeting starts in the room B-868<br />
<br />
==== Saturday, 3 June ====<br />
<br />
==== Sunday, 4 June ====<br />
<br />
==== Monday, 5 June ====<br />
<br />
==== Tuesday, 6 June ====<br />
<br />
==== Wednesday, 7 June ====<br />
<br />
* Departure<br />
<br />
== Participation ==<br />
<br />
We are planning for an attendance of 20 people (i.e., coding places) but of course you are welcome to join us and bring new ideas with you: we'll make more places available. Please add your name here or contact [[User:Landa|Martin Landa]] <tt><landa.martin at gmail.com></tt>:<br />
<br />
=== In person ===<br />
<br />
{|class="wikitable sortable" border="2" cellspacing="0" cellpadding="4" rules="all" style="margin:1em 1em 1em 0; border:solid 1px #AAAAAA; border-collapse:collapse; background-color:#edf9c7; font-size:95%; empty-cells:show;" <br />
!width=50px|'''Number'''<br />
!width=130px|'''Participant '''<br />
!width=100px|'''Country'''<br />
!width=100px|'''Arrival'''<br />
!width=100px|'''Departure'''<br />
!'''Topics'''<br />
!width=75px|'''T-Shirt'''<br />
!'''Notes'''<br />
|-<br />
|1<br />
|[[User:Landa|Martin Landa]]<br />
| Czech Republic<br />
| June 1<br />
| June 7<br />
| Python: create_location ([https://github.com/OSGeo/grass/issues/1987 #1987])<br />
| XL<br />
|<br />
|-<br />
|2<br />
| Micha Silver<br />
| Israel<br />
| June 2<br />
| June 6<br />
| Addon to derive soil moisture from Sentinel 2<br />
| XXL<br />
|<br />
|-<br />
|3<br />
|[https://www.osgeo.org/member/kudrnovsky/ Helmut Kudrnovsky]<br />
| Austria<br />
| June 2<br />
| June 4<br />
| <br />
| L<br />
|<br />
|-<br />
|4<br />
|[[User:Neteler|Markus Neteler]]<br />
| Germany<br />
| June 2<br />
| June 6 (12:43)<br />
| see [[Talk:GRASS_Community_Meeting_Prague_2023#Markus_Neteler|my list in "Discussion" page]]<br />
| L<br />
|<br />
|-<br />
|5<br />
|[[User:pesekon2|Ondřej Pešek]]<br />
| Czech Republic<br />
| June 2 (17:17)<br />
| June 6 (12:43)<br />
| <br />
| M<br />
|<br />
|-<br />
|6<br />
| [[User:helena|Helena Mitasova]]<br />
| United States <br />
| June 2<br />
| June 6<br />
|<br />
| S<br />
|<br />
|-<br />
|7<br />
| [[User:wenzeslaus|Vaclav Petras]]<br />
| United States <br />
| June 1<br />
| June 7<br />
| init and other Python API topics, support CMake transition, revise connection with QGIS and other tools<br />
| M<br />
|<br />
|-<br />
|8<br />
| [[User:Annakrat|Anna Petrasova]]<br />
| United States <br />
| June 1<br />
| June 7<br />
| parallelization, grass.jupyter<br />
| S<br />
|<br />
|-<br />
|9<br />
| [[User:Ctwhite|Corey White]]<br />
| United States <br />
| June 2 (10:55)<br />
| June 7<br />
| Connections with other tools, OpenPlains, JSON outputs<br />
| XL<br />
|<br />
|-<br />
|10<br />
| [[User:MarisN|Maris Nartiss]]<br />
| Latvia<br />
| June 2<br />
| June 6<br />
| <br />
| XL<br />
|-<br />
|11<br />
| [[User:Aaronsms|Aaron Saw Min Sern]]<br />
| Singapore<br />
| June 1<br />
| June 7<br />
| Support CMake transition, r.mapcalc parallelization<br />
| XS (or S)<br />
| Possibly attending virtually (TBC)<br />
|-<br />
|12<br />
| [[User:Ldesousa|Luís de Sousa]]<br />
| The Netherlands<br />
| June 1<br />
| June 5<br />
| Update r.mblend add-on; test CMake transition.<br />
| M<br />
| <br />
|-<br />
|13<br />
| [[User:Chaedrich|Caitlin Haedrich]]<br />
| United States<br />
| June 1<br />
| June 7<br />
| grass.jupyter<br />
| S<br />
|<br />
|-<br />
|14<br />
| [[User:Lindakladivova|Linda Kladivová]]<br />
| Czech Republic<br />
| June 2<br />
| June 6<br />
| <br />
| M<br />
|<br />
|-<br />
|15<br />
| Carmen Tawalika<br />
| Germany<br />
| June 2<br />
| June 6<br />
| Happy to assist with general topics like documentation + automation, in doubt something related to actinia<br />
| M<br />
| <br />
|-<br />
|}<br />
<br />
If you are arriving or departing on the days of the event, please specify the time, too.<br />
<br />
=== Via chat or hangout ===<br />
<br />
Join our [https://app.gitter.im/#/room/#grassgis_community:gitter.im Gitter chatroom]<br />
<br />
TBD: Google Meet / Zoom / ???<br />
<br />
Participating virtually:<br />
<br />
{|class="wikitable sortable" border="2" cellspacing="0" cellpadding="4" rules="all" style="margin:1em 1em 1em 0; border:solid 1px #AAAAAA; border-collapse:collapse; background-color:#edf9c7; font-size:95%; empty-cells:show;" <br />
!width=50px|'''Number'''<br />
!width=130px|'''Participant '''<br />
!width=100px|'''Country'''<br />
!'''Topics'''<br />
!'''Notes'''<br />
|-<br />
|1<br />
|[[User:Baharmon|Brendan Harmon]]<br />
| United States<br />
| Update integration with QGIS<br />
|<br />
|-<br />
|2<br />
|[[User:veroandreo|Veronica Andreo]]<br />
| Argentina<br />
| See [https://grasswiki.osgeo.org/wiki/Talk:GRASS_Community_Meeting_Prague_2023#Vero discussion tab]<br />
|<br />
|-<br />
|}<br />
<br />
<br />
==== Timing of hangout meetings ====<br />
<br />
Vero: available from 8:00 AM ART (UTC-3) onward<br />
<br />
=== Collaborative document scratching ===<br />
<br />
TBD<br />
<br />
== Individual Preparation ==<br />
<br />
<br />
* Bring your own computer<br />
* Bring {{wikipedia|AC adapter|power connector adapter}} if needed (Czech Republic: 230V, 50Hz, {{wikipedia|File:Euro-Flachstecker_2.jpg|Type C Europlugs}} are common and also {{wikipedia|File:French_plug_and_socket.jpg|Type E}})<br />
* Install subversion and the compiler tools, and come with a working GRASS development environment if possible.<br />
<br />
== Broadcast & Video ==<br />
<br />
During the event :)<br />
<br />
== Photos ==<br />
<br />
Also during the event :)<br />
<br />
== FAQ ==<br />
<br />
* '''How was it last time?'''<br />
** Very nice, see [[GRASS_GIS at OSGeo Virtual Community Sprint 2020]]!<br />
* ''Is the GRASS Community Meeting just a coding event?''<br />
** It is mainly a coding and documentation event. It is a working session for people who are already participants in the GRASS project and/or are committed to improving the GRASS project.<br />
** On demand we can do some presentations of current working GRASS implementation and new upcoming features to spread the idea of Open Source GIS software.<br />
* ''Is the GRASS Community Meeting for developers only?''<br />
** No: anybody can help, with testing, checking out bugs and fixes, documentation and more.<br />
* ''Where can I get help and more information about the community meeting?''<br />
** Contact [[User:Landa|Martin Landa]] <tt><landa.martin at gmail.com></tt><br />
<br />
== Report and press release ==<br />
<br />
TBD: After the event :-)<br />
<br />
We'll esp. craft a report for our sponsors.<br />
<br />
[[Category: Workshops]]<br />
[[Category: Code Sprint]]<br />
[[Category: 2023]]</div>Veroandreohttps://grasswiki.osgeo.org/w/index.php?title=Talk:GRASS_Community_Meeting_Prague_2023&diff=26927Talk:GRASS Community Meeting Prague 20232023-05-03T22:44:00Z<p>Veroandreo: /* Ideas for the meeting agenda */ add vero's list</p>
<hr />
<div>__TOC__<br />
<br />
== Ideas for the meeting agenda ==<br />
<br />
Collect ideas here :-)<br />
<br />
=== Markus Neteler ===<br />
<br />
* Discuss about a 4th edition of "Open Source GIS: A GRASS GIS Approach"<br />
* Easy [https://docs.weblate.org/en/latest/user/translating.html#machine-translation machine translation] of messages in [https://weblate.osgeo.org/translate/grass-gis OSGeo-Weblate] with DeepL API<br />
** my tests with DeepL show that the quality is very good; average translation time of a user message shrinks to 15 seconds<br />
* ...<br />
<br />
=== Vero ===<br />
<br />
* '''All - think about GRASS GIS mission and vision''': Where do we want to be as a project in 5 years time? What do we want to have? What do we want to be?<br />
* Participate in discussions about GRASS interfaces with QGIS and R (rgrass)<br />
* Discuss sponsoring<br />
* Student grant for (python) documentation?<br />
* Discuss about wiki clean-up/update (Anna was working on a list of pages) <br />
* Website enhancements: complete open PR's, meet Daniel Torres, new support item in main menu<br />
* i.landsat if time permits<br />
* ...<br />
<br />
=== You ===</div>Veroandreohttps://grasswiki.osgeo.org/w/index.php?title=GRASS_Community_Meeting_Prague_2023&diff=26924GRASS Community Meeting Prague 20232023-05-02T22:17:04Z<p>Veroandreo: /* Timing of hangout meetings */ add preferred timing</p>
<hr />
<div>{{toc|right}}<br />
The GRASS GIS team is organizing the ''GRASS GIS Community Meeting with contributors, power users and developers'' from '''June 2 to June 6, 2023''' to celebrate GRASS GIS '''40th birthday'''. <br />
<br />
<gallery mode="slideshow"><br />
Image:grass-sprint-prague.jpg|Prague 2013<br />
Image:Grass_sprint2018_bonn_fotowall.jpg|Bonn 2018<br />
</gallery><br />
<br />
== Purpose ==<br />
<br />
GRASS GIS Community Meeting is a great occasion for folks to support the development by actively contributing to the source code, documentation (manuals, wiki, tutorials), translations, website or likewise. The '''community''' meeting is also a get-together where supporters, contributors, power users and developers make decisions and tackle larger problems related to the project, discuss and collaboratively resolve bugs, plan the direction for the project and work on new features. We welcome people committed to improving the GRASS GIS project and the interfaces to QGIS, GDAL, PostGIS, R statistics, OGC Services and willing to '''celebrate with us the 40th GRASS GIS birthday!!'''<br />
<br />
For the detailed agenda, see below.<br />
<br />
== Sponsors ==<br />
<br />
We welcome '''financial contributions''' to support the meeting and we are looking for sponsors to cover costs such as meals or to help reducing travel and accommodation expenses for GRASS developers who volunteer their time. If you are interested in sponsoring the GRASS Community Meeting, please see our<br />
<br />
::: '''[https://opencollective.com/osgeo/projects/grass/contribute/grass-community-meeting-prague-2023-55074 OpenCollective GRASS Community Meeting Prague 2023 Tier]'''<br />
<br />
Any surplus at the end of the event will used for future activities of the GRASS GIS project such as the successful [[Student Grants|student mini grant program]].<br />
<br />
This GRASS Community Meeting is a great occasion for you to support the development of GRASS. With your contribution you'll enable more developers to meet. Community meetings are important opportunities for developers to discuss, fix bugs, plan the direction for the project and work on new features. Please see below for the detailed agenda. The developers and contributors are donating their valuable time, so it would be great if in-kind funding can be made available from within the community to cover out-of-pocket expenses. All of the work that takes place at the community meeting will be directly contributed back into the GRASS project to the benefit of everyone who uses it.<br />
<br />
=== Thanks to our sponsors ===<br />
<br />
We are grateful for the support which we have received to organize this GRASS Community Meeting:<br />
<br />
[[File:Osgeo logo.png|none|left|alt=Light and dark green logo of OSGeo saying Your Open Source Compass|Open Source Geospatial Foundation]]<br />
* OSGeo: 7303 USD (approved budget contribution, [https://www.loomio.com/p/2m75BZkL/motion-to-approve-7303-to-support-grass-gis-community-meeting motion])<br />
<br />
[[File:FOSSGIS_eV_logo.png|none|left|400px|alt=Logo of FOSSGIS e.V.|FOSSGIS e.V.]]<br />
* FOSSGIS e.V.: 5000 EUR<br />
<br />
Individuals:<br />
* MarWe 50 USD<br />
* Nick Brady 50 USD<br />
* Johannes Brauner 30 USD<br />
* Joaquin Perez Valera 5 USD<br />
* Anonymous sponsors 2750 USD<br />
<br />
In-kind contributions:<br />
<br />
* Faculty of Civil Engineering Czech Technical University in Prague (FCE CTU) - space and personnel time (planning, preparation)<br />
* North Carolina State University - personnel time (planning, preparation)<br />
* mundialis GmbH & Co. KG - personnel time (planning, preparation)<br />
* CONICET - personnel time (planning, preparation)<br />
<br />
== Timing ==<br />
<br />
'''When''': June 2-6, 2023<br />
<br />
Of course you are invited to join or leave the meeting whenever you want.<br />
<br />
== Venue ==<br />
<br />
[[Image:logo_cvut.jpg|130px|left]]<br />
Department of Geomatics<br><br />
[https://www.fsv.cvut.cz/?lang=en Faculty of Civil Engineering]<br><br />
[https://www.cvut.cz/en Czech Technical University in Prague], {{wikipedia|Czech Republic}}<br><br />
Thákurova 7/2077, Prague<br><br />
Room B868<br><br />
[https://en.mapy.cz/s/debazefuse Map]<br><br />
<br />
Prague has an international [http://www.prg.aero/en/ airport] and is also reachable by train, bus or car.<br />
<br />
== Accommodation and Costs ==<br />
<br />
Participants should plan for the following costs:<br />
<br />
* The participation is free of charge<br />
* Travel to Prague, variable depending on where you come from, reimbursements depending on the financial contributions provided by the community<br />
* Accommodation and meals (with the donated sponsorship money we will try to cover some expenses of the participants)<br />
'''Please note''': The currency in Czech Republic is {{wikipedia|Czech crown}} (CZK, koruna, Kč). 100 Czech crowns are about 4 Euros (see [https://www.cnb.cz/cs/financni-trhy/devizovy-trh/kurzy-devizoveho-trhu/kurzy-devizoveho-trhu/ current rates]).<br />
<br />
Please let us know your time of arrival and departure, so we can book accommodations and organize the logistics.<br />
<br />
Financial support: (partial) travel grants can be payed upon request thanks to our sponsors!<br />
<br />
== Agenda - What we plan to do ==<br />
<br />
'''Note:''' The program is generally open for your ideas. Please write an email to the [http://lists.osgeo.org/mailman/listinfo/grass-dev GRASS developer list] to discuss your contribution.<br />
<br />
During the meeting we will work on GRASS GIS on these tasks (please add more!):<br />
<br />
* We will update and revise the [https://github.com/qgis/QGIS/tree/master/python/plugins/grassprovider GRASS GIS Integration with QGIS] to simplify maintenance.<br />
* Furthermore, we will migrate the compilation technology to CMake to significantly improve the Windows builds including PDAL support and become binary compatible with OSGeo4W.<br />
* The extensive GRASS documentation will be converted from HTML to Markdown to facilitate future collaboration.<br />
* Pictures, examples and workflows will be added to the documentation where they are still missing.<br />
* Software maintenance processes are automated and documented to reduce the burden on maintainers and thus improve the sustainability of the project.<br />
<br />
This means that there are tasks from both the programming and documentation areas to appeal to a wide range of interested parties.<br />
<br />
Further details about the action items you '''find [[Talk:GRASS Community Meeting Prague 2023|here]]''' and below. Topics cover non-technical, semi-technical, and technical issues.<br />
<br />
=== Timeline ===<br />
<br />
Will be specified later.<br />
<br />
==== Thursday, 1 June ====<br />
<br />
* Arrival<br />
<br />
==== Friday, 2 June ====<br />
<br />
* 10:00 meeting starts in the room B-868<br />
<br />
==== Saturday, 3 June ====<br />
<br />
==== Sunday, 4 June ====<br />
<br />
==== Monday, 5 June ====<br />
<br />
==== Tuesday, 6 June ====<br />
<br />
==== Wednesday, 7 June ====<br />
<br />
* Departure<br />
<br />
== Participation ==<br />
<br />
We are planning for an attendance of 20 people (i.e., coding places) but of course you are welcome to join us and bring new ideas with you: we'll make more places available. Please add your name here or contact [[User:Landa|Martin Landa]] <tt><landa.martin at gmail.com></tt>:<br />
<br />
=== In person ===<br />
<br />
{|class="wikitable sortable" border="2" cellspacing="0" cellpadding="4" rules="all" style="margin:1em 1em 1em 0; border:solid 1px #AAAAAA; border-collapse:collapse; background-color:#edf9c7; font-size:95%; empty-cells:show;" <br />
!width=50px|'''Number'''<br />
!width=130px|'''Participant '''<br />
!width=100px|'''Country'''<br />
!width=100px|'''Arrival'''<br />
!width=100px|'''Departure'''<br />
!'''Topics'''<br />
!width=75px|'''T-Shirt'''<br />
!'''Notes'''<br />
|-<br />
|1<br />
|[[User:Landa|Martin Landa]]<br />
| Czech Republic<br />
| June 1<br />
| June 7<br />
| Python: create_location ([https://github.com/OSGeo/grass/issues/1987 #1987])<br />
| XL<br />
|<br />
|-<br />
|2<br />
| Micha Silver<br />
| Israel<br />
| June 2<br />
| June 6<br />
| Addon to derive soil moisture from Sentinel 2<br />
| XXL<br />
|<br />
|-<br />
|3<br />
|[https://www.osgeo.org/member/kudrnovsky/ Helmut Kudrnovsky]<br />
| Austria<br />
| June 2<br />
| June 4<br />
| <br />
| L<br />
|<br />
|-<br />
|4<br />
|[[User:Neteler|Markus Neteler]]<br />
| Germany<br />
| June 2<br />
| June 6 (12:43)<br />
| see [[Talk:GRASS_Community_Meeting_Prague_2023#Markus_Neteler|my list in "Discussion" page]]<br />
| L<br />
|<br />
|-<br />
|5<br />
|[[User:pesekon2|Ondřej Pešek]]<br />
| Czech Republic<br />
| June 2 (17:17)<br />
| June 6 (12:43)<br />
| <br />
| M<br />
|<br />
|-<br />
|6<br />
| [[User:helena|Helena Mitasova]]<br />
| United States <br />
| June 2<br />
| June 6<br />
|<br />
| S<br />
|<br />
|-<br />
|7<br />
| [[User:wenzeslaus|Vaclav Petras]]<br />
| United States <br />
| June 1<br />
| June 7<br />
| Support CMake transition, revise connection with QGIS and other tools<br />
| M<br />
|<br />
|-<br />
|8<br />
| [[User:Annakrat|Anna Petrasova]]<br />
| United States <br />
| June 1<br />
| June 7<br />
| parallelization, grass.jupyter<br />
| S<br />
|<br />
|-<br />
|9<br />
| [[User:Ctwhite|Corey White]]<br />
| United States <br />
| June 1<br />
| June 7<br />
| Connections with other tools, OpenPlains, JSON outputs<br />
| XL<br />
|<br />
|-<br />
|10<br />
| [[User:MarisN|Maris Nartiss]]<br />
| Latvia<br />
| June 2<br />
| June 6<br />
| <br />
| XL<br />
|-<br />
|11<br />
| [[User:Aaronsms|Aaron Saw Min Sern]]<br />
| Singapore<br />
| June 1<br />
| June 7<br />
| Support CMake transition, r.mapcalc parallelization<br />
| XS (or S)<br />
| Possibly attending virtually (TBC)<br />
|-<br />
|12<br />
| [[User:Ldesousa|Luís de Sousa]]<br />
| The Netherlands<br />
| June 1<br />
| June 5<br />
| Update r.mblend add-on; test CMake transition.<br />
| M<br />
| <br />
|-<br />
|13<br />
| [[User:Chaedrich|Caitlin Haedrich]]<br />
| United States<br />
| June 1<br />
| June 7<br />
| grass.jupyter<br />
| S<br />
|<br />
|-<br />
|14<br />
| [[User:Lindakladivova|Linda Kladivová]]<br />
| Czech Republic<br />
| June 2<br />
| June 6<br />
| <br />
| M<br />
|<br />
|-<br />
|15<br />
| Carmen Tawalika<br />
| Germany<br />
| June 2<br />
| June 6<br />
| Happy to assist with general topics like documentation + automation, in doubt something related to actinia<br />
| M<br />
| <br />
|-<br />
|}<br />
<br />
=== Via chat or hangout ===<br />
<br />
Join our [https://app.gitter.im/#/room/#grassgis_community:gitter.im Gitter chatroom]<br />
<br />
TBD: Google Meet / Zoom / ???<br />
<br />
Participating virtually:<br />
<br />
{|class="wikitable sortable" border="2" cellspacing="0" cellpadding="4" rules="all" style="margin:1em 1em 1em 0; border:solid 1px #AAAAAA; border-collapse:collapse; background-color:#edf9c7; font-size:95%; empty-cells:show;" <br />
!width=50px|'''Number'''<br />
!width=130px|'''Participant '''<br />
!width=100px|'''Country'''<br />
!'''Topics'''<br />
!'''Notes'''<br />
|-<br />
|1<br />
|[[User:Baharmon|Brendan Harmon]]<br />
| United States<br />
| Update integration with QGIS<br />
|<br />
|-<br />
|2<br />
|[[User:veroandreo|Veronica Andreo]]<br />
| Argentina<br />
| i.landsat, website<br />
|<br />
|-<br />
|}<br />
<br />
<br />
==== Timing of hangout meetings ====<br />
<br />
Vero: available from 8:00 AM ART (UTC-3) onward<br />
<br />
=== Collaborative document scratching ===<br />
<br />
TBD<br />
<br />
== Individual Preparation ==<br />
<br />
<br />
* Bring your own computer<br />
* Bring {{wikipedia|AC adapter|power connector adapter}} if needed (Czech Republic: 230V, 50Hz, {{wikipedia|File:Euro-Flachstecker_2.jpg|Type C Europlugs}} are common and also {{wikipedia|File:French_plug_and_socket.jpg|Type E}})<br />
* Install subversion and the compiler tools, and come with a working GRASS development environment if possible.<br />
<br />
== Broadcast & Video ==<br />
<br />
During the event :)<br />
<br />
== Photos ==<br />
<br />
Also during the event :)<br />
<br />
== FAQ ==<br />
<br />
* '''How was it last time?'''<br />
** Very nice, see [[GRASS_GIS at OSGeo Virtual Community Sprint 2020]]!<br />
* ''Is the GRASS Community Meeting just a coding event?''<br />
** It is mainly a coding and documentation event. It is a working session for people who are already participants in the GRASS project and/or are committed to improving the GRASS project.<br />
** On demand we can do some presentations of current working GRASS implementation and new upcoming features to spread the idea of Open Source GIS software.<br />
* ''Is the GRASS Community Meeting for developers only?''<br />
** No: anybody can help, with testing, checking out bugs and fixes, documentation and more.<br />
* ''Where can I get help and more information about the community meeting?''<br />
** Contact [[User:Landa|Martin Landa]] <tt><landa.martin at gmail.com></tt><br />
<br />
== Report and press release ==<br />
<br />
TBD: After the event :-)<br />
<br />
We'll esp. craft a report for our sponsors.<br />
<br />
[[Category: Workshops]]<br />
[[Category: Code Sprint]]<br />
[[Category: 2023]]</div>Veroandreohttps://grasswiki.osgeo.org/w/index.php?title=GRASS_Community_Meeting_Prague_2023&diff=26901GRASS Community Meeting Prague 20232023-04-22T15:40:50Z<p>Veroandreo: /* Via chat or hangout */ r-grass wiki update done (yay!)</p>
<hr />
<div>{{toc|right}}<br />
The GRASS GIS team is organizing the ''GRASS GIS Community Meeting with contributors, power users and developers'' from '''June 2 to June 6, 2023''' to celebrate GRASS GIS '''40th birthday'''. <br />
<br />
<gallery mode="slideshow"><br />
Image:grass-sprint-prague.jpg|Prague 2013<br />
Image:Grass_sprint2018_bonn_fotowall.jpg|Bonn 2018<br />
</gallery><br />
<br />
== Purpose ==<br />
<br />
GRASS GIS Community Meeting is a great occasion for folks to support the development by actively contributing to the source code, documentation (manuals, wiki, tutorials), translations, website or likewise. The '''community''' meeting is also a get-together where supporters, contributors, power users and developers make decisions and tackle larger problems related to the project, discuss and collaboratively resolve bugs, plan the direction for the project and work on new features. We welcome people committed to improving the GRASS GIS project and the interfaces to QGIS, GDAL, PostGIS, R statistics, OGC Services and willing to '''celebrate with us the 40th GRASS GIS birthday!!'''<br />
<br />
For the detailed agenda, see below.<br />
<br />
== Sponsors ==<br />
<br />
We welcome '''financial contributions''' to support the meeting and we are looking for sponsors to cover costs such as meals or to help reducing travel and accommodation expenses for GRASS developers who volunteer their time. If you are interested in sponsoring the GRASS Community Meeting, please see our<br />
<br />
::: '''[https://opencollective.com/osgeo/projects/grass/contribute/grass-community-meeting-prague-2023-55074 OpenCollective GRASS Community Meeting Prague 2023 Tier]'''<br />
<br />
Any surplus at the end of the event will used for future activities of the GRASS GIS project such as the successful [[Student Grants|student mini grant program]].<br />
<br />
This GRASS Community Meeting is a great occasion for you to support the development of GRASS. With your contribution you'll enable more developers to meet. Community meetings are important opportunities for developers to discuss, fix bugs, plan the direction for the project and work on new features. Please see below for the detailed agenda. The developers and contributors are donating their valuable time, so it would be great if in-kind funding can be made available from within the community to cover out-of-pocket expenses. All of the work that takes place at the community meeting will be directly contributed back into the GRASS project to the benefit of everyone who uses it.<br />
<br />
=== Thanks to our sponsors ===<br />
<br />
We are grateful for the support which we have received to organize this GRASS Community Meeting:<br />
<br />
[[File:Osgeo logo.png|none|left|alt=Light and dark green logo of OSGeo saying Your Open Source Compass|Open Source Geospatial Foundation]]<br />
<br />
* OSGeo 7300 USD (approved budget contribution, [https://www.loomio.com/p/2m75BZkL/motion-to-approve-7303-to-support-grass-gis-community-meeting motion])<br />
* MarWe 50 USD<br />
* Johannes Brauner 30 USD<br />
* Joaquin Perez Valera 5 USD<br />
* Anonymous sponsors 2750 USD<br />
<br />
In-kind contributions:<br />
<br />
* Faculty of Civil Engineering Czech Technical University in Prague (FCE CTU) - space and personnel time<br />
* North Carolina State University - personnel time<br />
* mundialis - personnel time<br />
* CONICET - personnel time<br />
<br />
== Timing ==<br />
<br />
'''When''': June 2-6, 2023<br />
<br />
Of course you are invited to join or leave the meeting whenever you want.<br />
<br />
== Venue ==<br />
<br />
[[Image:logo_cvut.jpg|130px|left]]<br />
Department of Geomatics<br><br />
[https://www.fsv.cvut.cz/?lang=en Faculty of Civil Engineering]<br><br />
[https://www.cvut.cz/en Czech Technical University in Prague], {{wikipedia|Czech Republic}}<br><br />
Thákurova 7/2077, Prague<br><br />
Room B868<br><br />
[https://en.mapy.cz/s/debazefuse Map]<br><br />
<br />
Prague has an international [http://www.prg.aero/en/ airport] and is also reachable by train, bus or car.<br />
<br />
== Accommodation and Costs ==<br />
<br />
Participants should plan for the following costs:<br />
<br />
* The participation is free of charge<br />
* Travel to Prague, variable depending on where you come from, reimbursements depending on the financial contributions provided by the community<br />
* Accommodation and meals (with the donated sponsorship money we will try to cover some expenses of the participants)<br />
'''Please note''': The currency in Czech Republic is {{wikipedia|Czech crown}} (CZK, koruna, Kč). 100 Czech crowns are about 4 Euros (see [https://www.cnb.cz/cs/financni-trhy/devizovy-trh/kurzy-devizoveho-trhu/kurzy-devizoveho-trhu/ current rates]).<br />
<br />
Please let us know your time of arrival and departure, so we can book accommodations and organize the logistics.<br />
<br />
Financial support: (partial) travel grants can be payed upon request thanks to our sponsors!<br />
<br />
== Agenda - What we plan to do ==<br />
<br />
'''Note:''' The program is generally open for your ideas. Please write an email to the [http://lists.osgeo.org/mailman/listinfo/grass-dev GRASS developer list] to discuss your contribution.<br />
<br />
During the meeting we will work on GRASS GIS on these tasks (please add more!):<br />
<br />
* We will update and revise the [https://github.com/qgis/QGIS/tree/master/python/plugins/grassprovider GRASS GIS Integration with QGIS] to simplify maintenance.<br />
* Furthermore, we will migrate the compilation technology to CMake to significantly improve the Windows builds including PDAL support and become binary compatible with OSGeo4W.<br />
* The extensive GRASS documentation will be converted from HTML to Markdown to facilitate future collaboration.<br />
* Pictures, examples and workflows will be added to the documentation where they are still missing.<br />
* Software maintenance processes are automated and documented to reduce the burden on maintainers and thus improve the sustainability of the project.<br />
<br />
This means that there are tasks from both the programming and documentation areas to appeal to a wide range of interested parties.<br />
<br />
Further details about the action items you '''find [[Talk:GRASS Community Meeting Prague 2023|here]]''' and below. Topics cover non-technical, semi-technical, and technical issues.<br />
<br />
=== Timeline ===<br />
<br />
Will be specified later.<br />
<br />
==== Thursday, 1 June ====<br />
<br />
* Arrival<br />
<br />
==== Friday, 2 June ====<br />
<br />
==== Saturday, 3 June ====<br />
<br />
==== Sunday, 4 June ====<br />
<br />
==== Monday, 5 June ====<br />
<br />
==== Tuesday, 6 June ====<br />
<br />
==== Friday, 7 June ====<br />
<br />
* Departure<br />
<br />
== Participation ==<br />
<br />
We are planning for an attendance of 20 people (i.e., coding places) but of course you are welcome to join us and bring new ideas with you: we'll make more places available. Please add your name here or contact [[User:Landa|Martin Landa]] <tt><landa.martin at gmail.com></tt>:<br />
<br />
=== In person ===<br />
<br />
{|class="wikitable sortable" border="2" cellspacing="0" cellpadding="4" rules="all" style="margin:1em 1em 1em 0; border:solid 1px #AAAAAA; border-collapse:collapse; background-color:#edf9c7; font-size:95%; empty-cells:show;" <br />
!width=50px|'''Number'''<br />
!width=130px|'''Participant '''<br />
!width=100px|'''Country'''<br />
!width=100px|'''Arrival'''<br />
!width=100px|'''Departure'''<br />
!'''Topics'''<br />
!width=75px|'''T-Shirt'''<br />
!'''Notes'''<br />
|-<br />
|1<br />
|[[User:Landa|Martin Landa]]<br />
| Czech Republic<br />
| June 1<br />
| June 7<br />
| <br />
| XL<br />
|<br />
|-<br />
|2<br />
| Micha Silver<br />
| Israel<br />
| June 2<br />
| June 6<br />
| Addon to derive soil moisture from Sentinel 2<br />
| XXL<br />
|<br />
|-<br />
|3<br />
|[https://www.osgeo.org/member/kudrnovsky/ Helmut Kudrnovsky]<br />
| Austria<br />
| June 2<br />
| June 4<br />
| <br />
| L<br />
|<br />
|-<br />
|4<br />
|[[User:Neteler|Markus Neteler]]<br />
| Germany<br />
| June 2<br />
| June 6 (12:43)<br />
| see [[Talk:GRASS_Community_Meeting_Prague_2023#Markus_Neteler|my list in "Discussion" page]]<br />
| L<br />
|<br />
|-<br />
|5<br />
|[[User:pesekon2|Ondřej Pešek]]<br />
| Czech Republic<br />
| June 2<br />
| June 6<br />
| <br />
| M<br />
|<br />
|-<br />
|6<br />
| [[User:helena|Helena Mitasova]]<br />
| United States <br />
| June 2<br />
| June 6<br />
|<br />
| S<br />
|<br />
|-<br />
|7<br />
| [[User:wenzeslaus|Vaclav Petras]]<br />
| United States <br />
| June 1<br />
| June 7<br />
| Support CMake transition, revise connection with QGIS and other tools<br />
| M<br />
|<br />
|-<br />
|8<br />
| [[User:Annakrat|Anna Petrasova]]<br />
| United States <br />
| June 1<br />
| June 7<br />
| parallelization, grass.jupyter<br />
| S<br />
|<br />
|-<br />
|9<br />
| [[User:Ctwhite|Corey White]]<br />
| United States <br />
| June 1<br />
| June 7<br />
| Connections with other tools, OpenPlains, JSON outputs<br />
| XL<br />
|<br />
|-<br />
|10<br />
| [[User:MarisN|Maris Nartiss]]<br />
| Latvia<br />
| June 2<br />
| June 6<br />
| <br />
| XL<br />
|-<br />
|11<br />
| [[User:Aaronsms|Aaron Saw Min Sern]]<br />
| Singapore<br />
| June 1<br />
| June 7<br />
| Support CMake transition, r.mapcalc parallelization<br />
| XS (or S)<br />
| Possibly attending virtually (TBC)<br />
|-<br />
|12<br />
| [[User:Ldesousa|Luís de Sousa]]<br />
| The Netherlands<br />
| June 1<br />
| June 5<br />
| Update r.mblend add-on; test CMake transition.<br />
| M<br />
| <br />
|-<br />
|}<br />
<br />
=== Via chat or hangout ===<br />
<br />
Join our [https://app.gitter.im/#/room/#grassgis_community:gitter.im Gitter chatroom]<br />
<br />
TBD: Google Meet / Zoom / ???<br />
<br />
Participating virtually:<br />
<br />
{|class="wikitable sortable" border="2" cellspacing="0" cellpadding="4" rules="all" style="margin:1em 1em 1em 0; border:solid 1px #AAAAAA; border-collapse:collapse; background-color:#edf9c7; font-size:95%; empty-cells:show;" <br />
!width=50px|'''Number'''<br />
!width=130px|'''Participant '''<br />
!width=100px|'''Country'''<br />
!'''Topics'''<br />
!'''Notes'''<br />
|-<br />
|1<br />
|[[User:Baharmon|Brendan Harmon]]<br />
| United States<br />
| Update integration with QGIS<br />
|<br />
|-<br />
|2<br />
|[[User:veroandreo|Veronica Andreo]]<br />
| Argentina<br />
| i.landsat, website<br />
|<br />
|-<br />
|}<br />
<br />
<br />
==== Timing of hangout meetings ====<br />
<br />
TBD<br />
<br />
=== Collaborative document scratching ===<br />
<br />
TBD<br />
<br />
== Individual Preparation ==<br />
<br />
<br />
* Bring your own computer<br />
* Bring {{wikipedia|AC adapter|power connector adapter}} if needed (Czech Republic: 230V, 50Hz, {{wikipedia|File:Euro-Flachstecker_2.jpg|Type C Europlugs}} are common and also {{wikipedia|File:French_plug_and_socket.jpg|Type E}})<br />
* Install subversion and the compiler tools, and come with a working GRASS development environment if possible.<br />
<br />
== Broadcast & Video ==<br />
<br />
During the event :)<br />
<br />
== Photos ==<br />
<br />
Also during the event :)<br />
<br />
== FAQ ==<br />
<br />
* '''How was it last time?'''<br />
** Very nice, see [[GRASS_GIS at OSGeo Virtual Community Sprint 2020]]!<br />
* ''Is the GRASS Community Meeting just a coding event?''<br />
** It is mainly a coding and documentation event. It is a working session for people who are already participants in the GRASS project and/or are committed to improving the GRASS project.<br />
** On demand we can do some presentations of current working GRASS implementation and new upcoming features to spread the idea of Open Source GIS software.<br />
* ''Is the GRASS Community Meeting for developers only?''<br />
** No: anybody can help, with testing, checking out bugs and fixes, documentation and more.<br />
* ''Where can I get help and more information about the community meeting?''<br />
** Contact [[User:Landa|Martin Landa]] <tt><landa.martin at gmail.com></tt><br />
<br />
== Press Release ==<br />
<br />
TBD: After the event :-)<br />
<br />
[[Category: Workshops]]<br />
[[Category: Code Sprint]]<br />
[[Category: 2023]]</div>Veroandreohttps://grasswiki.osgeo.org/w/index.php?title=R_statistics/rgrass&diff=26899R statistics/rgrass2023-04-21T19:48:29Z<p>Veroandreo: /* GRASS within R */</p>
<hr />
<div>== Installation ==<br />
<br />
See [[R_statistics/Installation]]<br />
<br />
== Terminology ==<br />
<br />
See "Overview" in [[R_statistics]]<br />
<br />
== R within GRASS ==<br />
<br />
In this example, we will use '''R within a GRASS GIS session''', i.e. start R (or RStudio) from the GRASS GIS terminal or command line interface.<br />
<br />
=== Startup ===<br />
<br />
* First start a GRASS GIS session. Then, at the GRASS command line start ''R'' (for an 'rstudio' session, see below)<br />
: ''In this example we will use the [https://grass.osgeo.org/download/data/#NorthCarolinaDataset North Carolina sample dataset].''<br />
<br />
Reset the region settings to the defaults<br />
<source lang="bash"><br />
GRASS (nc_spm_08_grass7):~ > g.region -d<br />
</source><br />
<br />
Launch R from the GRASS prompt<br />
<source lang="bash"><br />
GRASS (nc_spm_08_grass7):~ > R<br />
</source><br />
<br />
Load the ''rgrass'' library:<br />
<source lang="rsplus"><br />
library(rgrass)<br />
</source><br />
<br />
Get the GRASS environment (mapset, region, map projection, etc.); you can display the metadata for your location by printing G:<br />
<source lang="rsplus"><br />
gmeta()<br />
gisdbase /home/mneteler/grassdata <br />
location nc_spm_08_grass7 <br />
mapset user1 <br />
rows 620 <br />
columns 1630 <br />
north 320000 <br />
south 10000 <br />
west 120000 <br />
east 935000 <br />
nsres 500 <br />
ewres 500 <br />
projection:<br />
PROJCRS["NAD83(HARN) / North Carolina",<br />
BASEGEOGCRS["NAD83(HARN)",<br />
DATUM["NAD83 (High Accuracy Reference Network)",<br />
ELLIPSOID["GRS 1980",6378137,298.257222101,<br />
LENGTHUNIT["metre",1]]],<br />
PRIMEM["Greenwich",0,<br />
ANGLEUNIT["degree",0.0174532925199433]],<br />
ID["EPSG",4152]],<br />
CONVERSION["SPCS83 North Carolina zone (meters)",<br />
METHOD["Lambert Conic Conformal (2SP)",<br />
ID["EPSG",9802]],<br />
PARAMETER["Latitude of false origin",33.75,<br />
ANGLEUNIT["degree",0.0174532925199433],<br />
ID["EPSG",8821]],<br />
PARAMETER["Longitude of false origin",-79,<br />
ANGLEUNIT["degree",0.0174532925199433],<br />
ID["EPSG",8822]],<br />
PARAMETER["Latitude of 1st standard parallel",36.1666666666667,<br />
ANGLEUNIT["degree",0.0174532925199433],<br />
ID["EPSG",8823]],<br />
PARAMETER["Latitude of 2nd standard parallel",34.3333333333333,<br />
ANGLEUNIT["degree",0.0174532925199433],<br />
ID["EPSG",8824]],<br />
PARAMETER["Easting at false origin",609601.22,<br />
LENGTHUNIT["metre",1],<br />
ID["EPSG",8826]],<br />
PARAMETER["Northing at false origin",0,<br />
LENGTHUNIT["metre",1],<br />
ID["EPSG",8827]]],<br />
CS[Cartesian,2],<br />
AXIS["easting (X)",east,<br />
ORDER[1],<br />
LENGTHUNIT["metre",1]],<br />
AXIS["northing (Y)",north,<br />
ORDER[2],<br />
LENGTHUNIT["metre",1]],<br />
USAGE[<br />
SCOPE["Engineering survey, topographic mapping."],<br />
AREA["United States (USA) - North Carolina - counties of Alamance; Alexander; Alleghany; Anson; Ashe; Avery; Beaufort; Bertie; Bladen; Brunswick; Buncombe; Burke; Cabarrus; Caldwell; Camden; Carteret; Caswell; Catawba; Chatham; Cherokee; Chowan; Clay; Cleveland; Columbus; Craven; Cumberland; Currituck; Dare; Davidson; Davie; Duplin; Durham; Edgecombe; Forsyth; Franklin; Gaston; Gates; Graham; Granville; Greene; Guilford; Halifax; Harnett; Haywood; Henderson; Hertford; Hoke; Hyde; Iredell; Jackson; Johnston; Jones; Lee; Lenoir; Lincoln; Macon; Madison; Martin; McDowell; Mecklenburg; Mitchell; Montgomery; Moore; Nash; New Hanover; Northampton; Onslow; Orange; Pamlico; Pasquotank; Pender; Perquimans; Person; Pitt; Polk; Randolph; Richmond; Robeson; Rockingham; Rowan; Rutherford; Sampson; Scotland; Stanly; Stokes; Surry; Swain; Transylvania; Tyrrell; Union; Vance; Wake; Warren; Washington; Watauga; Wayne; Wilkes; Wilson; Yadkin; Yancey."],<br />
BBOX[33.83,-84.33,36.59,-75.38]],<br />
ID["EPSG",3358]]<br />
</source><br />
<br />
=== Listing of existing maps ===<br />
<br />
List available vector maps:<br />
<source lang="rsplus"><br />
execGRASS("g.list", parameters = list(type = "vector"))<br />
</source><br />
<br />
List selected vector maps (wildcard):<br />
<source lang="rsplus"><br />
execGRASS("g.list", parameters = list(type = "vector", pattern = "precip*"))<br />
precip<br />
precip_30ynormals<br />
precip_30ynormals_3d<br />
</source><br />
<br />
Save selected vector maps into R vector:<br />
<source lang="rsplus"><br />
my_vmaps <- execGRASS("g.list", parameters = list(type = "vector", pattern = "precip*"))<br />
attributes(my_vmaps)<br />
attributes(my_vmaps)$resOut<br />
[1] "precip" "precip_30ynormals" "precip_30ynormals_3d"<br />
</source><br />
<br />
List available raster maps:<br />
<source lang="rsplus"><br />
execGRASS("g.list", parameters = list(type = "raster"))<br />
</source><br />
<br />
List selected raster maps (wildcard):<br />
<source lang="rsplus"><br />
execGRASS("g.list", parameters = list(type = "raster", pattern = "lsat7_2002*"))<br />
lsat7_2002_10<br />
lsat7_2002_20<br />
lsat7_2002_30<br />
lsat7_2002_40<br />
lsat7_2002_50<br />
lsat7_2002_61<br />
lsat7_2002_62<br />
lsat7_2002_70<br />
lsat7_2002_80<br />
</source><br />
<br />
=== Reading data from GRASS ===<br />
<br />
==== Example 1: raster maps ====<br />
<br />
Read two GRASS raster maps, "geology_30m" and "elevation", from the North Carolina sample data location into the R current session as a new object "ncdata". This object is a SpatRaster layer from terra package:<br />
<source lang="rsplus"><br />
ncdata <- read_RAST(c("geology_30m", "elevation"))<br />
</source><br />
<br />
We can verify the new R object:<br />
<source lang="rsplus"><br />
ncdata<br />
class : SpatRaster <br />
dimensions : 450, 500, 2 (nrow, ncol, nlyr)<br />
resolution : 30, 30 (x, y)<br />
extent : 630000, 645000, 215000, 228500 (xmin, xmax, ymin, ymax)<br />
coord. ref. : +proj=lcc +lat_0=33.75 +lon_0=-79 +lat_1=36.1666666666667 +lat_2=34.3333333333333 +x_0=609601.22 +y_0=0 +ellps=GRS80 +units=m +no_defs <br />
sources : file1da12a752d65.grd <br />
file1da12112d9ea4.grd <br />
names : geology_30m, elevation <br />
min values : 217, 55.92321 <br />
max values : 948, 156.25197<br />
</source><br />
<br />
Now, let's plot one of the raster layers within the SpatRaster object. We'll load terra library to have all functionality available:<br />
<source lang="rsplus"><br />
library(terra)<br />
plot(ncdata$elevation, main="North Carolina elevation")<br />
</source><br />
<br />
[[Image:ncdata_new.png|center]]<br />
<br />
In addition, we can show what is going on inside the objects read into R:<br />
<source lang="rsplus"><br />
summary(ncdata)<br />
geology_30m elevation <br />
Min. :217.0 Min. : 56.01 <br />
1st Qu.:217.0 1st Qu.: 94.77 <br />
Median :270.0 Median :108.86 <br />
Mean :311.2 Mean :110.36 <br />
3rd Qu.:270.0 3rd Qu.:126.80 <br />
Max. :948.0 Max. :156.07 <br />
</source><br />
<br />
==== Example 2: single raster map ====<br />
<br />
Here an example to transfer a single raster map from GRASS GIS to R:<br />
<br />
<source lang="rsplus"><br />
library(rgrass)<br />
library(terra)<br />
execGRASS("g.region", raster = "elevation", flags = "p")<br />
ncdata <- read_RAST("elevation")<br />
summary(ncdata)<br />
plot(ncdata)<br />
</source><br />
<br />
==== Example 3: vector maps ====<br />
<br />
Here an example to transfer a single vector map from GRASS GIS to R. In this case, vector maps from GRASS will be converted into SpatVector objects from the terra package in R:<br />
<br />
<source lang="rsplus"><br />
# needed prerequisite<br />
library(rgrass)<br />
library(terra)<br />
execGRASS("v.info", map="schools_wake", layer="1")<br />
vInfo("schools_wake")<br />
myschools <- read_VECT("schools_wake")<br />
print(summary(myschools))<br />
plot(myschools)<br />
</source><br />
<br />
==== Example 4: Summarizing data ====<br />
<br />
We can create a table of cell counts:<br />
<source lang="rsplus"><br />
freq(ncdata$geology_30m)<br />
</source><br />
<pre><br />
layer value count<br />
1 1 217 80618<br />
2 1 262 22076<br />
3 1 270 76597<br />
4 1 405 28190<br />
5 1 583 2401<br />
6 1 720 536<br />
7 1 766 786<br />
8 1 862 6858<br />
9 1 910 4996<br />
10 1 921 1392<br />
11 1 945 1<br />
12 1 946 452<br />
13 1 948 97<br />
</pre><br />
<br />
And compare with the equivalent GRASS module:<br />
<source lang="rsplus"><br />
execGRASS("r.stats", flags=c("c", "l"), parameters=list(input="geology_30m"), ignore.stderr=TRUE)<br />
</source><br />
<pre><br />
217 CZfg 80618<br />
262 CZlg 22076<br />
270 CZig 76597<br />
405 CZbg 28190<br />
583 CZve 2401<br />
720 CZam 536<br />
766 CZg 786<br />
862 CZam 6858<br />
910 CZbg 4996<br />
921 Km 1392<br />
945 CZbg 1<br />
946 CZam 452<br />
948 CZam 97<br />
</pre><br />
<br />
<!--- it does no work with terra<br />
Create a box plot of geologic types at different elevations:<br />
<source lang="rsplus"><br />
boxplot(ncdata$elevation ~ ncdata$geology_30m, medlwd = 1)<br />
</source><br />
<br />
[[Image:boxplot_geo.png|center]]<br />
---><br />
<br />
==== Example 5: Querying maps ====<br />
<br />
Sometimes you may want to query GRASS GIS maps from your R session. As an example, here the transfer of raster pixel values at the position of vector points:<br />
<br />
<source lang="rsplus"><br />
# set the computational region to the raster map:<br />
execGRASS("g.region", raster = "elev_state_500m", flags = "p")<br />
<br />
# query raster map at vector points, transfer result into R<br />
goutput <- execGRASS("r.what", map="elev_state_500m", points="geodetic_pts", separator=",", intern=TRUE)<br />
str(goutput)<br />
chr [1:29939] "571530.81289275,265739.968425953,,187.8082200648" ...<br />
<br />
# parse it<br />
con <- textConnection(goutput)<br />
go1 <- read.csv(con, header=FALSE)<br />
str(go1)<br />
'data.frame': 29939 obs. of 4 variables:<br />
$ V1: num 571531 571359 571976 572391 573011 ...<br />
$ V2: num 265740 265987 267049 267513 269615 ...<br />
$ V3: logi NA NA NA NA NA NA ...<br />
$ V4: Factor w/ 22738 levels "-0.0048115728",..: 6859 6642 6749 6411 6356 6904 7506 7224 6908 7167 ...<br />
summary(go1)<br />
V1 V2 V3 V4 <br />
Min. :121862 Min. : 7991 Mode:logical 0 : 723 <br />
1st Qu.:462706 1st Qu.:162508 NA's:29939 * : 293 <br />
Median :610328 Median :204502 0.3048 : 47 <br />
Mean :588514 Mean :200038 0.6096 : 44 <br />
3rd Qu.:717610 3rd Qu.:247633 1.524 : 42 <br />
Max. :946743 Max. :327186 0.9144 : 23 <br />
(Other):28767 <br />
</source><br />
<br />
=== Exporting data back to GRASS ===<br />
<br />
Finally, a SpatialGridDataFrame object is written back to a GRASS raster map:<br />
<br />
First prepare some data: (square root of elevation)<br />
<source lang="rsplus"><br />
ncdata$sqdem <- sqrt(ncdata$elevation)<br />
</source><br />
<br />
Export data from ''R'' back into a GRASS raster map:<br />
<source lang="rsplus"><br />
write_RAST(ncdata$sqdem, "sqdemNC", flags = c("o","overwrite"))<br />
</source><br />
<br />
Check that it imported properly:<br />
<source lang="rsplus"><br />
execGRASS("r.info", parameters=list(map="sqdemNC"))<br />
</source><br />
<br />
<pre><br />
+----------------------------------------------------------------------------+<br />
| Map: sqdemNC Date: Fri Apr 21 17:14:05 2023 |<br />
| Mapset: PERMANENT Login of Creator: veroandreo |<br />
| Location: nc_spm_08_grass7 |<br />
| DataBase: /home/veroandreo/grassdata |<br />
| Title: |<br />
| Timestamp: none |<br />
|----------------------------------------------------------------------------|<br />
| |<br />
| Type of Map: raster Number of Categories: 0 |<br />
| Data Type: FCELL Semantic label: (none) |<br />
| Rows: 450 |<br />
| Columns: 500 |<br />
| Total Cells: 225000 |<br />
| Projection: Lambert Conformal Conic |<br />
| N: 228500 S: 215000 Res: 30 |<br />
| E: 645000 W: 630000 Res: 30 |<br />
| Range of data: min = 7.478182 max = 12.50008 |<br />
| |<br />
| Data Description: |<br />
| generated by r.in.gdal |<br />
| |<br />
| Comments: |<br />
| r.in.gdal --overwrite -o input="/home/veroandreo/tmp/grass8-veroandr\ |<br />
| eo-120898/RtmpPcRHkF/file1da12dbc5b5d.grd" output="sqdemNC" memory=3\ |<br />
| 00 offset=0 num_digits=0 |<br />
| |<br />
+----------------------------------------------------------------------------+<br />
</pre><br />
<br />
=== Using RStudio in a GRASS GIS session ===<br />
<br />
If you are most used to run R through RStudio, but still want to have all GRASS data available for performing<br />
any analyses without loosing the possibility of still using GRASS command line, you can run:<br />
<br />
<source lang="bash"><br />
GRASS> rstudio &<br />
</source><br />
<br />
or, if you already are working on a certain RStudio project:<br />
<br />
<source lang="bash"><br />
GRASS> rstudio /path/to/project/folder/ &<br />
</source><br />
<br />
Then, you load rgrass library in your RStudio project<br />
<source lang="rsplus"><br />
library(rgrass)<br />
</source><br />
<br />
and you are ready to go.<br />
<br />
[[File:Grass7_rstudio.png|thumb|500px|center|RStudio used in GRASS GIS session]]<br />
<br />
== GRASS within R ==<br />
<br />
In this case, we start '''GRASS GIS within an R session''', i.e., we use <tt>initGRASS()</tt> to start GRASS in a temporary location or in an existing GRASS GIS location.<br />
<br />
The first argument in initGRASS() is gisBase=. This argument refers to the path where GRASS is installed. In the latest rgrass <br />
version, if the gisBase argument is missing, initGRASS() will do a minimal effort of guessing it. Firstly, if a GRASS_INSTALLATION environment variable is availabe, then its value will automatically be used for gisBase. If not, then the system command <tt>grass --config path</tt> will be tried to get the value of GISBASE that corresponds to the GRASS installation in the system PATH (if any).<br />
<br />
If users, still want/need to pass the path to GRASS installation themselves, they can run:<br />
<br />
<source lang="bash"><br />
# OSGeo4W shell, Linux, Mac OSX users:<br />
grass --config path<br />
</source><br />
<br />
It may report something like:<br />
<source lang="bash"><br />
# OSGeo4W users:<br />
C:\OSGeo4W64\apps\grass\grass<br />
<br />
# Linux, Mac OSX users:<br />
/usr/local/grass<br />
</source><br />
<br />
If GRASS GIS was installed through OSGeo4W, users should first start the OSGeo4W Shell. Note that it may start in C: or a directory<br />
where the user does not have writing permission. Before calling R or RStudio, first change to a directory where you are <br />
sure you have writing permission.<br />
<br />
<source lang="rsplus"><br />
## MS-Windows users (example for an OSGeo4W 64bit installation)<br />
# change to a directory with writing permission<br />
C:\>d:<br />
D:\>cd temp<br />
D:\temp>cd testR<br />
<br />
# start R within this directory:<br />
D:\temp\testR>R<br />
<br />
# to start RStudio from OSGeo4W Shell, run: "C:/Program Files/RStudio/bin/rstudio.exe"<br />
<br />
# load rgrass package<br />
library(rgrass)<br />
<br />
# initialisation of GRASS in the North Carolina sample dataset<br />
initGRASS(gisBase = "C:/OSGeo4W64/apps/grass/grass",<br />
gisDbase = "C:/Users/marissa/grassdata/",<br />
location = "nc_spm_08_grass7", <br />
mapset = "user1",<br />
home=tempdir(),<br />
override = TRUE)<br />
</source><br />
<br />
Linux and Mac OSX users just need to start R or RStudio the usual way, load the rgrass package and initialize GRASS as shown below:<br />
<br />
<source lang="rsplus"><br />
library(rgrass)<br />
<br />
# initialisation of GRASS in the North Carolina sample dataset<br />
initGRASS(gisBase = "/usr/lib64/grass82",<br />
gisDbase = "/home/veroandreo/grassdata/",<br />
location = "nc_basic_spm_grass7",<br />
mapset = "user1",<br />
home=tempdir(),<br />
override = TRUE)<br />
</source><br />
<br />
=== Temporary location ===<br />
<br />
If we don’t pass an existing location to initGRASS(), a temporary GRASS location will be created and set. By default this will be<br />
an XY location, i.e., no CRS defined. To define a CRS for the temporary location, we create a terra SpatRaster object that by default will be EPSG:4326.<br />
<br />
<source lang="rsplus"><br />
library(terra)<br />
x <- rast()<br />
x<br />
class : SpatRaster <br />
dimensions : 180, 360, 1 (nrow, ncol, nlyr)<br />
resolution : 1, 1 (x, y)<br />
extent : -180, 180, -90, 90 (xmin, xmax, ymin, ymax)<br />
coord. ref. : lon/lat WGS 84<br />
</source><br />
<br />
Then, we use that object to provide an EPSG to our temporary location via the SG= parameter and we start GRASS:<br />
<br />
<source lang="rsplus"><br />
initGRASS(home = tempdir(), <br />
SG = x, <br />
override = TRUE)<br />
</source><br />
<br />
After that, users can write their raster and vector maps into GRASS with write_RAST() and write_VECT(), use GRASS GIS modules over those data with execGRASS() and export the results back to R with read_RAST() and read_VECT() as exemplified above.<br />
<br />
=== Existing location ===<br />
<br />
In the case of existing locations and mapsets, users will provide the path to them via the location= and mapset= parameters, and then read data from GRASS database into R through read_RAST() and read_VECT(), do their analyses or modeling in R and potentially write results back into GRASS with write_RAST() and write_VECT(). See examples above.<br />
<br />
== R in GRASS in batch mode ==<br />
<br />
Run the following script with<br />
<br />
<source lang="bash"><br />
R CMD BATCH batch.R<br />
</source><br />
<br />
<source lang="rsplus"><br />
library(rgrass)<br />
library(terra)<br />
# initialisation of GRASS in the North Carolina sample dataset<br />
initGRASS(gisBase = "/usr/lib64/grass82", <br />
home = tempdir(), <br />
gisDbase = "/home/veroandreo/grassdata/",<br />
location = "nc_spm_08_grass7", <br />
mapset = "user1",<br />
override = TRUE)<br />
# set region to default<br />
system("g.region -dp")<br />
# verify<br />
gmeta()<br />
# read data into R<br />
ncdata <- read_RAST("geology_30m", cat=TRUE)<br />
# summary of geology map<br />
summary(ncdata$geology_30m)<br />
proc.time()<br />
</source><br />
<br />
The result is (shorted here):<br />
<source lang="bash"><br />
cat batch.Rout<br />
</source> <br />
<br />
<source lang="rsplus"><br />
R version 4.1.3 (2022-03-10) -- "One Push-Up"<br />
Copyright (C) 2022 The R Foundation for Statistical Computing<br />
Platform: x86_64-redhat-linux-gnu (64-bit)<br />
<br />
> library(rgrass)<br />
Loading required package: XML<br />
GRASS GIS interface loaded with GRASS version: (GRASS not running)<br />
> library(terra)<br />
terra 1.7.23<br />
<br />
> # initialisation of GRASS in the North Carolina sample dataset<br />
> initGRASS(gisBase = "/usr/lib64/grass82", <br />
+ home = tempdir(), <br />
+ gisDbase = "/home/veroandreo/grassdata/",<br />
+ location = "nc_spm_08_grass7", <br />
+ mapset = "user1",<br />
+ override = TRUE)<br />
gisdbase /home/veroandreo/grassdata/ <br />
location nc_spm_08_grass7 <br />
mapset user1 <br />
rows 620 <br />
columns 1630 <br />
north 320000 <br />
south 10000 <br />
west 120000 <br />
east 935000 <br />
nsres 500 <br />
ewres 500 <br />
projection:<br />
PROJCRS["NAD83(HARN) / North Carolina",<br />
BASEGEOGCRS["NAD83(HARN)",<br />
DATUM["NAD83 (High Accuracy Reference Network)",<br />
ELLIPSOID["GRS 1980",6378137,298.257222101,<br />
<br />
> # set region to default<br />
> system("g.region -dp")<br />
projection: 99 (Lambert Conformal Conic)<br />
zone: 0<br />
datum: nad83<br />
ellipsoid: a=6378137 es=0.006694380022900787<br />
north: 320000<br />
south: 10000<br />
west: 120000<br />
east: 935000<br />
nsres: 500<br />
ewres: 500<br />
rows: 620<br />
cols: 1630<br />
cells: 1010600<br />
<br />
> gmeta()<br />
gisdbase /home/veroandreo/grassdata/ <br />
location nc_spm_08_grass7 <br />
mapset user1 <br />
rows 620 <br />
columns 1630 <br />
north 320000 <br />
south 10000 <br />
west 120000 <br />
east 935000 <br />
nsres 500 <br />
ewres 500 <br />
projection:<br />
PROJCRS["NAD83(HARN) / North Carolina",<br />
BASEGEOGCRS["NAD83(HARN)",<br />
DATUM["NAD83 (High Accuracy Reference Network)",<br />
ELLIPSOID["GRS 1980",6378137,298.257222101,<br />
LENGTHUNIT["metre",1]]],<br />
... <br />
...<br />
BBOX[33.83,-84.33,36.59,-75.38]],<br />
ID["EPSG",3358]] <br />
...<br />
> ncdata <- read_RAST("elev_state_500m")<br />
...<br />
r.out.gdal complete. File </home/veroandreo/tmp/RtmpoA1IKV/file2844e28321574.grd> created.<br />
<br />
> summary(ncdata)<br />
file2844e28321574<br />
Min. : -6.47 <br />
1st Qu.: 14.36 <br />
Median : 86.55 <br />
Mean : 214.55 <br />
3rd Qu.: 252.66 <br />
Max. :1878.39 <br />
NA's :46188 <br />
<br />
> proc.time()<br />
user system elapsed <br />
15.574 1.275 16.998 <br />
</source><br />
<br />
== Troubleshooting ==<br />
<br />
=== Running out of disk space ===<br />
<br />
Linux: A common issue is that /tmp/ is used for temporary files albeit being often a small partition. To change that to a larger directory, you may '''add''' to your <tt>$HOME/.bashrc</tt> the entry:<br />
<br />
<source lang="bash"><br />
# change TMP directory of R (note: of course also another directory than suggested here is fine)<br />
mkdir -p $HOME/tmp<br />
export TMP=$HOME/tmp<br />
</source><br />
<br />
The drawback of this approach is that on modern Linux systems the /tmp/ is a fast RAM disk (based on tempfs) while HOME directories are often on slower spinning disks (unless you have a SSD drive). At least you no longer run out of disk space easily.<br />
<br />
[[Category:FAQ]]<br />
[[Category:Linking to other languages]]<br />
[[Category:R]]<br />
[[Category:Statistics]]</div>Veroandreohttps://grasswiki.osgeo.org/w/index.php?title=R_statistics/rgrass&diff=26898R statistics/rgrass2023-04-21T19:47:54Z<p>Veroandreo: </p>
<hr />
<div>== Installation ==<br />
<br />
See [[R_statistics/Installation]]<br />
<br />
== Terminology ==<br />
<br />
See "Overview" in [[R_statistics]]<br />
<br />
== R within GRASS ==<br />
<br />
In this example, we will use '''R within a GRASS GIS session''', i.e. start R (or RStudio) from the GRASS GIS terminal or command line interface.<br />
<br />
=== Startup ===<br />
<br />
* First start a GRASS GIS session. Then, at the GRASS command line start ''R'' (for an 'rstudio' session, see below)<br />
: ''In this example we will use the [https://grass.osgeo.org/download/data/#NorthCarolinaDataset North Carolina sample dataset].''<br />
<br />
Reset the region settings to the defaults<br />
<source lang="bash"><br />
GRASS (nc_spm_08_grass7):~ > g.region -d<br />
</source><br />
<br />
Launch R from the GRASS prompt<br />
<source lang="bash"><br />
GRASS (nc_spm_08_grass7):~ > R<br />
</source><br />
<br />
Load the ''rgrass'' library:<br />
<source lang="rsplus"><br />
library(rgrass)<br />
</source><br />
<br />
Get the GRASS environment (mapset, region, map projection, etc.); you can display the metadata for your location by printing G:<br />
<source lang="rsplus"><br />
gmeta()<br />
gisdbase /home/mneteler/grassdata <br />
location nc_spm_08_grass7 <br />
mapset user1 <br />
rows 620 <br />
columns 1630 <br />
north 320000 <br />
south 10000 <br />
west 120000 <br />
east 935000 <br />
nsres 500 <br />
ewres 500 <br />
projection:<br />
PROJCRS["NAD83(HARN) / North Carolina",<br />
BASEGEOGCRS["NAD83(HARN)",<br />
DATUM["NAD83 (High Accuracy Reference Network)",<br />
ELLIPSOID["GRS 1980",6378137,298.257222101,<br />
LENGTHUNIT["metre",1]]],<br />
PRIMEM["Greenwich",0,<br />
ANGLEUNIT["degree",0.0174532925199433]],<br />
ID["EPSG",4152]],<br />
CONVERSION["SPCS83 North Carolina zone (meters)",<br />
METHOD["Lambert Conic Conformal (2SP)",<br />
ID["EPSG",9802]],<br />
PARAMETER["Latitude of false origin",33.75,<br />
ANGLEUNIT["degree",0.0174532925199433],<br />
ID["EPSG",8821]],<br />
PARAMETER["Longitude of false origin",-79,<br />
ANGLEUNIT["degree",0.0174532925199433],<br />
ID["EPSG",8822]],<br />
PARAMETER["Latitude of 1st standard parallel",36.1666666666667,<br />
ANGLEUNIT["degree",0.0174532925199433],<br />
ID["EPSG",8823]],<br />
PARAMETER["Latitude of 2nd standard parallel",34.3333333333333,<br />
ANGLEUNIT["degree",0.0174532925199433],<br />
ID["EPSG",8824]],<br />
PARAMETER["Easting at false origin",609601.22,<br />
LENGTHUNIT["metre",1],<br />
ID["EPSG",8826]],<br />
PARAMETER["Northing at false origin",0,<br />
LENGTHUNIT["metre",1],<br />
ID["EPSG",8827]]],<br />
CS[Cartesian,2],<br />
AXIS["easting (X)",east,<br />
ORDER[1],<br />
LENGTHUNIT["metre",1]],<br />
AXIS["northing (Y)",north,<br />
ORDER[2],<br />
LENGTHUNIT["metre",1]],<br />
USAGE[<br />
SCOPE["Engineering survey, topographic mapping."],<br />
AREA["United States (USA) - North Carolina - counties of Alamance; Alexander; Alleghany; Anson; Ashe; Avery; Beaufort; Bertie; Bladen; Brunswick; Buncombe; Burke; Cabarrus; Caldwell; Camden; Carteret; Caswell; Catawba; Chatham; Cherokee; Chowan; Clay; Cleveland; Columbus; Craven; Cumberland; Currituck; Dare; Davidson; Davie; Duplin; Durham; Edgecombe; Forsyth; Franklin; Gaston; Gates; Graham; Granville; Greene; Guilford; Halifax; Harnett; Haywood; Henderson; Hertford; Hoke; Hyde; Iredell; Jackson; Johnston; Jones; Lee; Lenoir; Lincoln; Macon; Madison; Martin; McDowell; Mecklenburg; Mitchell; Montgomery; Moore; Nash; New Hanover; Northampton; Onslow; Orange; Pamlico; Pasquotank; Pender; Perquimans; Person; Pitt; Polk; Randolph; Richmond; Robeson; Rockingham; Rowan; Rutherford; Sampson; Scotland; Stanly; Stokes; Surry; Swain; Transylvania; Tyrrell; Union; Vance; Wake; Warren; Washington; Watauga; Wayne; Wilkes; Wilson; Yadkin; Yancey."],<br />
BBOX[33.83,-84.33,36.59,-75.38]],<br />
ID["EPSG",3358]]<br />
</source><br />
<br />
=== Listing of existing maps ===<br />
<br />
List available vector maps:<br />
<source lang="rsplus"><br />
execGRASS("g.list", parameters = list(type = "vector"))<br />
</source><br />
<br />
List selected vector maps (wildcard):<br />
<source lang="rsplus"><br />
execGRASS("g.list", parameters = list(type = "vector", pattern = "precip*"))<br />
precip<br />
precip_30ynormals<br />
precip_30ynormals_3d<br />
</source><br />
<br />
Save selected vector maps into R vector:<br />
<source lang="rsplus"><br />
my_vmaps <- execGRASS("g.list", parameters = list(type = "vector", pattern = "precip*"))<br />
attributes(my_vmaps)<br />
attributes(my_vmaps)$resOut<br />
[1] "precip" "precip_30ynormals" "precip_30ynormals_3d"<br />
</source><br />
<br />
List available raster maps:<br />
<source lang="rsplus"><br />
execGRASS("g.list", parameters = list(type = "raster"))<br />
</source><br />
<br />
List selected raster maps (wildcard):<br />
<source lang="rsplus"><br />
execGRASS("g.list", parameters = list(type = "raster", pattern = "lsat7_2002*"))<br />
lsat7_2002_10<br />
lsat7_2002_20<br />
lsat7_2002_30<br />
lsat7_2002_40<br />
lsat7_2002_50<br />
lsat7_2002_61<br />
lsat7_2002_62<br />
lsat7_2002_70<br />
lsat7_2002_80<br />
</source><br />
<br />
=== Reading data from GRASS ===<br />
<br />
==== Example 1: raster maps ====<br />
<br />
Read two GRASS raster maps, "geology_30m" and "elevation", from the North Carolina sample data location into the R current session as a new object "ncdata". This object is a SpatRaster layer from terra package:<br />
<source lang="rsplus"><br />
ncdata <- read_RAST(c("geology_30m", "elevation"))<br />
</source><br />
<br />
We can verify the new R object:<br />
<source lang="rsplus"><br />
ncdata<br />
class : SpatRaster <br />
dimensions : 450, 500, 2 (nrow, ncol, nlyr)<br />
resolution : 30, 30 (x, y)<br />
extent : 630000, 645000, 215000, 228500 (xmin, xmax, ymin, ymax)<br />
coord. ref. : +proj=lcc +lat_0=33.75 +lon_0=-79 +lat_1=36.1666666666667 +lat_2=34.3333333333333 +x_0=609601.22 +y_0=0 +ellps=GRS80 +units=m +no_defs <br />
sources : file1da12a752d65.grd <br />
file1da12112d9ea4.grd <br />
names : geology_30m, elevation <br />
min values : 217, 55.92321 <br />
max values : 948, 156.25197<br />
</source><br />
<br />
Now, let's plot one of the raster layers within the SpatRaster object. We'll load terra library to have all functionality available:<br />
<source lang="rsplus"><br />
library(terra)<br />
plot(ncdata$elevation, main="North Carolina elevation")<br />
</source><br />
<br />
[[Image:ncdata_new.png|center]]<br />
<br />
In addition, we can show what is going on inside the objects read into R:<br />
<source lang="rsplus"><br />
summary(ncdata)<br />
geology_30m elevation <br />
Min. :217.0 Min. : 56.01 <br />
1st Qu.:217.0 1st Qu.: 94.77 <br />
Median :270.0 Median :108.86 <br />
Mean :311.2 Mean :110.36 <br />
3rd Qu.:270.0 3rd Qu.:126.80 <br />
Max. :948.0 Max. :156.07 <br />
</source><br />
<br />
==== Example 2: single raster map ====<br />
<br />
Here an example to transfer a single raster map from GRASS GIS to R:<br />
<br />
<source lang="rsplus"><br />
library(rgrass)<br />
library(terra)<br />
execGRASS("g.region", raster = "elevation", flags = "p")<br />
ncdata <- read_RAST("elevation")<br />
summary(ncdata)<br />
plot(ncdata)<br />
</source><br />
<br />
==== Example 3: vector maps ====<br />
<br />
Here an example to transfer a single vector map from GRASS GIS to R. In this case, vector maps from GRASS will be converted into SpatVector objects from the terra package in R:<br />
<br />
<source lang="rsplus"><br />
# needed prerequisite<br />
library(rgrass)<br />
library(terra)<br />
execGRASS("v.info", map="schools_wake", layer="1")<br />
vInfo("schools_wake")<br />
myschools <- read_VECT("schools_wake")<br />
print(summary(myschools))<br />
plot(myschools)<br />
</source><br />
<br />
==== Example 4: Summarizing data ====<br />
<br />
We can create a table of cell counts:<br />
<source lang="rsplus"><br />
freq(ncdata$geology_30m)<br />
</source><br />
<pre><br />
layer value count<br />
1 1 217 80618<br />
2 1 262 22076<br />
3 1 270 76597<br />
4 1 405 28190<br />
5 1 583 2401<br />
6 1 720 536<br />
7 1 766 786<br />
8 1 862 6858<br />
9 1 910 4996<br />
10 1 921 1392<br />
11 1 945 1<br />
12 1 946 452<br />
13 1 948 97<br />
</pre><br />
<br />
And compare with the equivalent GRASS module:<br />
<source lang="rsplus"><br />
execGRASS("r.stats", flags=c("c", "l"), parameters=list(input="geology_30m"), ignore.stderr=TRUE)<br />
</source><br />
<pre><br />
217 CZfg 80618<br />
262 CZlg 22076<br />
270 CZig 76597<br />
405 CZbg 28190<br />
583 CZve 2401<br />
720 CZam 536<br />
766 CZg 786<br />
862 CZam 6858<br />
910 CZbg 4996<br />
921 Km 1392<br />
945 CZbg 1<br />
946 CZam 452<br />
948 CZam 97<br />
</pre><br />
<br />
<!--- it does no work with terra<br />
Create a box plot of geologic types at different elevations:<br />
<source lang="rsplus"><br />
boxplot(ncdata$elevation ~ ncdata$geology_30m, medlwd = 1)<br />
</source><br />
<br />
[[Image:boxplot_geo.png|center]]<br />
---><br />
<br />
==== Example 5: Querying maps ====<br />
<br />
Sometimes you may want to query GRASS GIS maps from your R session. As an example, here the transfer of raster pixel values at the position of vector points:<br />
<br />
<source lang="rsplus"><br />
# set the computational region to the raster map:<br />
execGRASS("g.region", raster = "elev_state_500m", flags = "p")<br />
<br />
# query raster map at vector points, transfer result into R<br />
goutput <- execGRASS("r.what", map="elev_state_500m", points="geodetic_pts", separator=",", intern=TRUE)<br />
str(goutput)<br />
chr [1:29939] "571530.81289275,265739.968425953,,187.8082200648" ...<br />
<br />
# parse it<br />
con <- textConnection(goutput)<br />
go1 <- read.csv(con, header=FALSE)<br />
str(go1)<br />
'data.frame': 29939 obs. of 4 variables:<br />
$ V1: num 571531 571359 571976 572391 573011 ...<br />
$ V2: num 265740 265987 267049 267513 269615 ...<br />
$ V3: logi NA NA NA NA NA NA ...<br />
$ V4: Factor w/ 22738 levels "-0.0048115728",..: 6859 6642 6749 6411 6356 6904 7506 7224 6908 7167 ...<br />
summary(go1)<br />
V1 V2 V3 V4 <br />
Min. :121862 Min. : 7991 Mode:logical 0 : 723 <br />
1st Qu.:462706 1st Qu.:162508 NA's:29939 * : 293 <br />
Median :610328 Median :204502 0.3048 : 47 <br />
Mean :588514 Mean :200038 0.6096 : 44 <br />
3rd Qu.:717610 3rd Qu.:247633 1.524 : 42 <br />
Max. :946743 Max. :327186 0.9144 : 23 <br />
(Other):28767 <br />
</source><br />
<br />
=== Exporting data back to GRASS ===<br />
<br />
Finally, a SpatialGridDataFrame object is written back to a GRASS raster map:<br />
<br />
First prepare some data: (square root of elevation)<br />
<source lang="rsplus"><br />
ncdata$sqdem <- sqrt(ncdata$elevation)<br />
</source><br />
<br />
Export data from ''R'' back into a GRASS raster map:<br />
<source lang="rsplus"><br />
write_RAST(ncdata$sqdem, "sqdemNC", flags = c("o","overwrite"))<br />
</source><br />
<br />
Check that it imported properly:<br />
<source lang="rsplus"><br />
execGRASS("r.info", parameters=list(map="sqdemNC"))<br />
</source><br />
<br />
<pre><br />
+----------------------------------------------------------------------------+<br />
| Map: sqdemNC Date: Fri Apr 21 17:14:05 2023 |<br />
| Mapset: PERMANENT Login of Creator: veroandreo |<br />
| Location: nc_spm_08_grass7 |<br />
| DataBase: /home/veroandreo/grassdata |<br />
| Title: |<br />
| Timestamp: none |<br />
|----------------------------------------------------------------------------|<br />
| |<br />
| Type of Map: raster Number of Categories: 0 |<br />
| Data Type: FCELL Semantic label: (none) |<br />
| Rows: 450 |<br />
| Columns: 500 |<br />
| Total Cells: 225000 |<br />
| Projection: Lambert Conformal Conic |<br />
| N: 228500 S: 215000 Res: 30 |<br />
| E: 645000 W: 630000 Res: 30 |<br />
| Range of data: min = 7.478182 max = 12.50008 |<br />
| |<br />
| Data Description: |<br />
| generated by r.in.gdal |<br />
| |<br />
| Comments: |<br />
| r.in.gdal --overwrite -o input="/home/veroandreo/tmp/grass8-veroandr\ |<br />
| eo-120898/RtmpPcRHkF/file1da12dbc5b5d.grd" output="sqdemNC" memory=3\ |<br />
| 00 offset=0 num_digits=0 |<br />
| |<br />
+----------------------------------------------------------------------------+<br />
</pre><br />
<br />
=== Using RStudio in a GRASS GIS session ===<br />
<br />
If you are most used to run R through RStudio, but still want to have all GRASS data available for performing<br />
any analyses without loosing the possibility of still using GRASS command line, you can run:<br />
<br />
<source lang="bash"><br />
GRASS> rstudio &<br />
</source><br />
<br />
or, if you already are working on a certain RStudio project:<br />
<br />
<source lang="bash"><br />
GRASS> rstudio /path/to/project/folder/ &<br />
</source><br />
<br />
Then, you load rgrass library in your RStudio project<br />
<source lang="rsplus"><br />
library(rgrass)<br />
</source><br />
<br />
and you are ready to go.<br />
<br />
[[File:Grass7_rstudio.png|thumb|500px|center|RStudio used in GRASS GIS session]]<br />
<br />
== GRASS within R ==<br />
<br />
In this case, we start '''GRASS GIS within an R session''', i.e., we use <tt>initGRASS()</tt> to start GRASS in a temporary location or in an existing GRASS GIS location.<br />
<br />
The first argument in initGRASS() is gisBase=. This argument refers to the path where GRASS is installed. In the latest rgrass <br />
version, if the gisBase argument is missing, initGRASS() will do a minimal effort of guessing it. Firstly, if a GRASS_INSTALLATION environment variable is availabe, then its value will automatically be used for gisBase. If not, then the system command <tt>grass --config path</> will be tried to get the value of GISBASE that corresponds to the GRASS installation in the system PATH (if any).<br />
<br />
If users, still want/need to pass the path to GRASS installation themselves, they can run:<br />
<br />
<source lang="bash"><br />
# OSGeo4W shell, Linux, Mac OSX users:<br />
grass --config path<br />
</source><br />
<br />
It may report something like:<br />
<source lang="bash"><br />
# OSGeo4W users:<br />
C:\OSGeo4W64\apps\grass\grass<br />
<br />
# Linux, Mac OSX users:<br />
/usr/local/grass<br />
</source><br />
<br />
If GRASS GIS was installed through OSGeo4W, users should first start the OSGeo4W Shell. Note that it may start in C: or a directory<br />
where the user does not have writing permission. Before calling R or RStudio, first change to a directory where you are <br />
sure you have writing permission.<br />
<br />
<source lang="rsplus"><br />
## MS-Windows users (example for an OSGeo4W 64bit installation)<br />
# change to a directory with writing permission<br />
C:\>d:<br />
D:\>cd temp<br />
D:\temp>cd testR<br />
<br />
# start R within this directory:<br />
D:\temp\testR>R<br />
<br />
# to start RStudio from OSGeo4W Shell, run: "C:/Program Files/RStudio/bin/rstudio.exe"<br />
<br />
# load rgrass package<br />
library(rgrass)<br />
<br />
# initialisation of GRASS in the North Carolina sample dataset<br />
initGRASS(gisBase = "C:/OSGeo4W64/apps/grass/grass",<br />
gisDbase = "C:/Users/marissa/grassdata/",<br />
location = "nc_spm_08_grass7", <br />
mapset = "user1",<br />
home=tempdir(),<br />
override = TRUE)<br />
</source><br />
<br />
Linux and Mac OSX users just need to start R or RStudio the usual way, load the rgrass package and initialize GRASS as shown below:<br />
<br />
<source lang="rsplus"><br />
library(rgrass)<br />
<br />
# initialisation of GRASS in the North Carolina sample dataset<br />
initGRASS(gisBase = "/usr/lib64/grass82",<br />
gisDbase = "/home/veroandreo/grassdata/",<br />
location = "nc_basic_spm_grass7",<br />
mapset = "user1",<br />
home=tempdir(),<br />
override = TRUE)<br />
</source><br />
<br />
=== Temporary location ===<br />
<br />
If we don’t pass an existing location to initGRASS(), a temporary GRASS location will be created and set. By default this will be<br />
an XY location, i.e., no CRS defined. To define a CRS for the temporary location, we create a terra SpatRaster object that by default will be EPSG:4326.<br />
<br />
<source lang="rsplus"><br />
library(terra)<br />
x <- rast()<br />
x<br />
class : SpatRaster <br />
dimensions : 180, 360, 1 (nrow, ncol, nlyr)<br />
resolution : 1, 1 (x, y)<br />
extent : -180, 180, -90, 90 (xmin, xmax, ymin, ymax)<br />
coord. ref. : lon/lat WGS 84<br />
</source><br />
<br />
Then, we use that object to provide an EPSG to our temporary location via the SG= parameter and we start GRASS:<br />
<br />
<source lang="rsplus"><br />
initGRASS(home = tempdir(), <br />
SG = x, <br />
override = TRUE)<br />
</source><br />
<br />
After that, users can write their raster and vector maps into GRASS with write_RAST() and write_VECT(), use GRASS GIS modules over those data with execGRASS() and export the results back to R with read_RAST() and read_VECT() as exemplified above.<br />
<br />
=== Existing location ===<br />
<br />
In the case of existing locations and mapsets, users will provide the path to them via the location= and mapset= parameters, and then read data from GRASS database into R through read_RAST() and read_VECT(), do their analyses or modeling in R and potentially write results back into GRASS with write_RAST() and write_VECT(). See examples above.<br />
<br />
== R in GRASS in batch mode ==<br />
<br />
Run the following script with<br />
<br />
<source lang="bash"><br />
R CMD BATCH batch.R<br />
</source><br />
<br />
<source lang="rsplus"><br />
library(rgrass)<br />
library(terra)<br />
# initialisation of GRASS in the North Carolina sample dataset<br />
initGRASS(gisBase = "/usr/lib64/grass82", <br />
home = tempdir(), <br />
gisDbase = "/home/veroandreo/grassdata/",<br />
location = "nc_spm_08_grass7", <br />
mapset = "user1",<br />
override = TRUE)<br />
# set region to default<br />
system("g.region -dp")<br />
# verify<br />
gmeta()<br />
# read data into R<br />
ncdata <- read_RAST("geology_30m", cat=TRUE)<br />
# summary of geology map<br />
summary(ncdata$geology_30m)<br />
proc.time()<br />
</source><br />
<br />
The result is (shorted here):<br />
<source lang="bash"><br />
cat batch.Rout<br />
</source> <br />
<br />
<source lang="rsplus"><br />
R version 4.1.3 (2022-03-10) -- "One Push-Up"<br />
Copyright (C) 2022 The R Foundation for Statistical Computing<br />
Platform: x86_64-redhat-linux-gnu (64-bit)<br />
<br />
> library(rgrass)<br />
Loading required package: XML<br />
GRASS GIS interface loaded with GRASS version: (GRASS not running)<br />
> library(terra)<br />
terra 1.7.23<br />
<br />
> # initialisation of GRASS in the North Carolina sample dataset<br />
> initGRASS(gisBase = "/usr/lib64/grass82", <br />
+ home = tempdir(), <br />
+ gisDbase = "/home/veroandreo/grassdata/",<br />
+ location = "nc_spm_08_grass7", <br />
+ mapset = "user1",<br />
+ override = TRUE)<br />
gisdbase /home/veroandreo/grassdata/ <br />
location nc_spm_08_grass7 <br />
mapset user1 <br />
rows 620 <br />
columns 1630 <br />
north 320000 <br />
south 10000 <br />
west 120000 <br />
east 935000 <br />
nsres 500 <br />
ewres 500 <br />
projection:<br />
PROJCRS["NAD83(HARN) / North Carolina",<br />
BASEGEOGCRS["NAD83(HARN)",<br />
DATUM["NAD83 (High Accuracy Reference Network)",<br />
ELLIPSOID["GRS 1980",6378137,298.257222101,<br />
<br />
> # set region to default<br />
> system("g.region -dp")<br />
projection: 99 (Lambert Conformal Conic)<br />
zone: 0<br />
datum: nad83<br />
ellipsoid: a=6378137 es=0.006694380022900787<br />
north: 320000<br />
south: 10000<br />
west: 120000<br />
east: 935000<br />
nsres: 500<br />
ewres: 500<br />
rows: 620<br />
cols: 1630<br />
cells: 1010600<br />
<br />
> gmeta()<br />
gisdbase /home/veroandreo/grassdata/ <br />
location nc_spm_08_grass7 <br />
mapset user1 <br />
rows 620 <br />
columns 1630 <br />
north 320000 <br />
south 10000 <br />
west 120000 <br />
east 935000 <br />
nsres 500 <br />
ewres 500 <br />
projection:<br />
PROJCRS["NAD83(HARN) / North Carolina",<br />
BASEGEOGCRS["NAD83(HARN)",<br />
DATUM["NAD83 (High Accuracy Reference Network)",<br />
ELLIPSOID["GRS 1980",6378137,298.257222101,<br />
LENGTHUNIT["metre",1]]],<br />
... <br />
...<br />
BBOX[33.83,-84.33,36.59,-75.38]],<br />
ID["EPSG",3358]] <br />
...<br />
> ncdata <- read_RAST("elev_state_500m")<br />
...<br />
r.out.gdal complete. File </home/veroandreo/tmp/RtmpoA1IKV/file2844e28321574.grd> created.<br />
<br />
> summary(ncdata)<br />
file2844e28321574<br />
Min. : -6.47 <br />
1st Qu.: 14.36 <br />
Median : 86.55 <br />
Mean : 214.55 <br />
3rd Qu.: 252.66 <br />
Max. :1878.39 <br />
NA's :46188 <br />
<br />
> proc.time()<br />
user system elapsed <br />
15.574 1.275 16.998 <br />
</source><br />
<br />
== Troubleshooting ==<br />
<br />
=== Running out of disk space ===<br />
<br />
Linux: A common issue is that /tmp/ is used for temporary files albeit being often a small partition. To change that to a larger directory, you may '''add''' to your <tt>$HOME/.bashrc</tt> the entry:<br />
<br />
<source lang="bash"><br />
# change TMP directory of R (note: of course also another directory than suggested here is fine)<br />
mkdir -p $HOME/tmp<br />
export TMP=$HOME/tmp<br />
</source><br />
<br />
The drawback of this approach is that on modern Linux systems the /tmp/ is a fast RAM disk (based on tempfs) while HOME directories are often on slower spinning disks (unless you have a SSD drive). At least you no longer run out of disk space easily.<br />
<br />
[[Category:FAQ]]<br />
[[Category:Linking to other languages]]<br />
[[Category:R]]<br />
[[Category:Statistics]]</div>Veroandreohttps://grasswiki.osgeo.org/w/index.php?title=File:Ncdata_new.png&diff=26897File:Ncdata new.png2023-04-21T19:41:50Z<p>Veroandreo: </p>
<hr />
<div></div>Veroandreohttps://grasswiki.osgeo.org/w/index.php?title=R_statistics/rgrass&diff=26896R statistics/rgrass2023-04-21T19:41:06Z<p>Veroandreo: /* Example 1: raster maps */</p>
<hr />
<div>== Installation ==<br />
<br />
See [[R_statistics/Installation]]<br />
<br />
== Terminology ==<br />
<br />
See "Overview" in [[R_statistics]]<br />
<br />
== R within GRASS ==<br />
<br />
In this example, we will use '''R within a GRASS GIS session''', i.e. start R (or RStudio) from the GRASS GIS terminal or command line interface.<br />
<br />
=== Startup ===<br />
<br />
* First start a GRASS GIS session. Then, at the GRASS command line start ''R'' (for an 'rstudio' session, see below)<br />
: ''In this example we will use the [https://grass.osgeo.org/download/data/#NorthCarolinaDataset North Carolina sample dataset].''<br />
<br />
Reset the region settings to the defaults<br />
<source lang="bash"><br />
GRASS (nc_spm_08_grass7):~ > g.region -d<br />
</source><br />
<br />
Launch R from the GRASS prompt<br />
<source lang="bash"><br />
GRASS (nc_spm_08_grass7):~ > R<br />
</source><br />
<br />
Load the ''rgrass'' library:<br />
<source lang="rsplus"><br />
library(rgrass)<br />
</source><br />
<br />
Get the GRASS environment (mapset, region, map projection, etc.); you can display the metadata for your location by printing G:<br />
<source lang="rsplus"><br />
gmeta()<br />
gisdbase /home/mneteler/grassdata <br />
location nc_spm_08_grass7 <br />
mapset user1 <br />
rows 620 <br />
columns 1630 <br />
north 320000 <br />
south 10000 <br />
west 120000 <br />
east 935000 <br />
nsres 500 <br />
ewres 500 <br />
projection:<br />
PROJCRS["NAD83(HARN) / North Carolina",<br />
BASEGEOGCRS["NAD83(HARN)",<br />
DATUM["NAD83 (High Accuracy Reference Network)",<br />
ELLIPSOID["GRS 1980",6378137,298.257222101,<br />
LENGTHUNIT["metre",1]]],<br />
PRIMEM["Greenwich",0,<br />
ANGLEUNIT["degree",0.0174532925199433]],<br />
ID["EPSG",4152]],<br />
CONVERSION["SPCS83 North Carolina zone (meters)",<br />
METHOD["Lambert Conic Conformal (2SP)",<br />
ID["EPSG",9802]],<br />
PARAMETER["Latitude of false origin",33.75,<br />
ANGLEUNIT["degree",0.0174532925199433],<br />
ID["EPSG",8821]],<br />
PARAMETER["Longitude of false origin",-79,<br />
ANGLEUNIT["degree",0.0174532925199433],<br />
ID["EPSG",8822]],<br />
PARAMETER["Latitude of 1st standard parallel",36.1666666666667,<br />
ANGLEUNIT["degree",0.0174532925199433],<br />
ID["EPSG",8823]],<br />
PARAMETER["Latitude of 2nd standard parallel",34.3333333333333,<br />
ANGLEUNIT["degree",0.0174532925199433],<br />
ID["EPSG",8824]],<br />
PARAMETER["Easting at false origin",609601.22,<br />
LENGTHUNIT["metre",1],<br />
ID["EPSG",8826]],<br />
PARAMETER["Northing at false origin",0,<br />
LENGTHUNIT["metre",1],<br />
ID["EPSG",8827]]],<br />
CS[Cartesian,2],<br />
AXIS["easting (X)",east,<br />
ORDER[1],<br />
LENGTHUNIT["metre",1]],<br />
AXIS["northing (Y)",north,<br />
ORDER[2],<br />
LENGTHUNIT["metre",1]],<br />
USAGE[<br />
SCOPE["Engineering survey, topographic mapping."],<br />
AREA["United States (USA) - North Carolina - counties of Alamance; Alexander; Alleghany; Anson; Ashe; Avery; Beaufort; Bertie; Bladen; Brunswick; Buncombe; Burke; Cabarrus; Caldwell; Camden; Carteret; Caswell; Catawba; Chatham; Cherokee; Chowan; Clay; Cleveland; Columbus; Craven; Cumberland; Currituck; Dare; Davidson; Davie; Duplin; Durham; Edgecombe; Forsyth; Franklin; Gaston; Gates; Graham; Granville; Greene; Guilford; Halifax; Harnett; Haywood; Henderson; Hertford; Hoke; Hyde; Iredell; Jackson; Johnston; Jones; Lee; Lenoir; Lincoln; Macon; Madison; Martin; McDowell; Mecklenburg; Mitchell; Montgomery; Moore; Nash; New Hanover; Northampton; Onslow; Orange; Pamlico; Pasquotank; Pender; Perquimans; Person; Pitt; Polk; Randolph; Richmond; Robeson; Rockingham; Rowan; Rutherford; Sampson; Scotland; Stanly; Stokes; Surry; Swain; Transylvania; Tyrrell; Union; Vance; Wake; Warren; Washington; Watauga; Wayne; Wilkes; Wilson; Yadkin; Yancey."],<br />
BBOX[33.83,-84.33,36.59,-75.38]],<br />
ID["EPSG",3358]]<br />
</source><br />
<br />
=== Listing of existing maps ===<br />
<br />
List available vector maps:<br />
<source lang="rsplus"><br />
execGRASS("g.list", parameters = list(type = "vector"))<br />
</source><br />
<br />
List selected vector maps (wildcard):<br />
<source lang="rsplus"><br />
execGRASS("g.list", parameters = list(type = "vector", pattern = "precip*"))<br />
precip<br />
precip_30ynormals<br />
precip_30ynormals_3d<br />
</source><br />
<br />
Save selected vector maps into R vector:<br />
<source lang="rsplus"><br />
my_vmaps <- execGRASS("g.list", parameters = list(type = "vector", pattern = "precip*"))<br />
attributes(my_vmaps)<br />
attributes(my_vmaps)$resOut<br />
[1] "precip" "precip_30ynormals" "precip_30ynormals_3d"<br />
</source><br />
<br />
List available raster maps:<br />
<source lang="rsplus"><br />
execGRASS("g.list", parameters = list(type = "raster"))<br />
</source><br />
<br />
List selected raster maps (wildcard):<br />
<source lang="rsplus"><br />
execGRASS("g.list", parameters = list(type = "raster", pattern = "lsat7_2002*"))<br />
lsat7_2002_10<br />
lsat7_2002_20<br />
lsat7_2002_30<br />
lsat7_2002_40<br />
lsat7_2002_50<br />
lsat7_2002_61<br />
lsat7_2002_62<br />
lsat7_2002_70<br />
lsat7_2002_80<br />
</source><br />
<br />
=== Reading data from GRASS ===<br />
<br />
==== Example 1: raster maps ====<br />
<br />
Read two GRASS raster maps, "geology_30m" and "elevation", from the North Carolina sample data location into the R current session as a new object "ncdata". This object is a SpatRaster layer from terra package:<br />
<source lang="rsplus"><br />
ncdata <- read_RAST(c("geology_30m", "elevation"))<br />
</source><br />
<br />
We can verify the new R object:<br />
<source lang="rsplus"><br />
ncdata<br />
class : SpatRaster <br />
dimensions : 450, 500, 2 (nrow, ncol, nlyr)<br />
resolution : 30, 30 (x, y)<br />
extent : 630000, 645000, 215000, 228500 (xmin, xmax, ymin, ymax)<br />
coord. ref. : +proj=lcc +lat_0=33.75 +lon_0=-79 +lat_1=36.1666666666667 +lat_2=34.3333333333333 +x_0=609601.22 +y_0=0 +ellps=GRS80 +units=m +no_defs <br />
sources : file1da12a752d65.grd <br />
file1da12112d9ea4.grd <br />
names : geology_30m, elevation <br />
min values : 217, 55.92321 <br />
max values : 948, 156.25197<br />
</source><br />
<br />
Now, let's plot one of the raster layers within the SpatRaster object. We'll load terra library to have all functionality available:<br />
<source lang="rsplus"><br />
library(terra)<br />
plot(ncdata$elevation, main="North Carolina elevation")<br />
</source><br />
<br />
[[Image:ncdata_new.png|center]]<br />
<br />
In addition, we can show what is going on inside the objects read into R:<br />
<source lang="rsplus"><br />
summary(ncdata)<br />
geology_30m elevation <br />
Min. :217.0 Min. : 56.01 <br />
1st Qu.:217.0 1st Qu.: 94.77 <br />
Median :270.0 Median :108.86 <br />
Mean :311.2 Mean :110.36 <br />
3rd Qu.:270.0 3rd Qu.:126.80 <br />
Max. :948.0 Max. :156.07 <br />
</source><br />
<br />
==== Example 2: single raster map ====<br />
<br />
Here an example to transfer a single raster map from GRASS GIS to R:<br />
<br />
<source lang="rsplus"><br />
library(rgrass)<br />
library(terra)<br />
execGRASS("g.region", raster = "elevation", flags = "p")<br />
ncdata <- read_RAST("elevation")<br />
summary(ncdata)<br />
plot(ncdata)<br />
</source><br />
<br />
==== Example 3: vector maps ====<br />
<br />
Here an example to transfer a single vector map from GRASS GIS to R. In this case, vector maps from GRASS will be converted into SpatVector objects from the terra package in R:<br />
<br />
<source lang="rsplus"><br />
# needed prerequisite<br />
library(rgrass)<br />
library(terra)<br />
execGRASS("v.info", map="schools_wake", layer="1")<br />
vInfo("schools_wake")<br />
myschools <- read_VECT("schools_wake")<br />
print(summary(myschools))<br />
plot(myschools)<br />
</source><br />
<br />
==== Example 4: Summarizing data ====<br />
<br />
We can create a table of cell counts:<br />
<source lang="rsplus"><br />
freq(ncdata$geology_30m)<br />
</source><br />
<pre><br />
layer value count<br />
1 1 217 80618<br />
2 1 262 22076<br />
3 1 270 76597<br />
4 1 405 28190<br />
5 1 583 2401<br />
6 1 720 536<br />
7 1 766 786<br />
8 1 862 6858<br />
9 1 910 4996<br />
10 1 921 1392<br />
11 1 945 1<br />
12 1 946 452<br />
13 1 948 97<br />
</pre><br />
<br />
And compare with the equivalent GRASS module:<br />
<source lang="rsplus"><br />
execGRASS("r.stats", flags=c("c", "l"), parameters=list(input="geology_30m"), ignore.stderr=TRUE)<br />
</source><br />
<pre><br />
217 CZfg 80618<br />
262 CZlg 22076<br />
270 CZig 76597<br />
405 CZbg 28190<br />
583 CZve 2401<br />
720 CZam 536<br />
766 CZg 786<br />
862 CZam 6858<br />
910 CZbg 4996<br />
921 Km 1392<br />
945 CZbg 1<br />
946 CZam 452<br />
948 CZam 97<br />
</pre><br />
<br />
<!--- it does no work with terra<br />
Create a box plot of geologic types at different elevations:<br />
<source lang="rsplus"><br />
boxplot(ncdata$elevation ~ ncdata$geology_30m, medlwd = 1)<br />
</source><br />
<br />
[[Image:boxplot_geo.png|center]]<br />
---><br />
<br />
==== Example 5: Querying maps ====<br />
<br />
Sometimes you may want to query GRASS GIS maps from your R session. As an example, here the transfer of raster pixel values at the position of vector points:<br />
<br />
<source lang="rsplus"><br />
# set the computational region to the raster map:<br />
execGRASS("g.region", raster = "elev_state_500m", flags = "p")<br />
<br />
# query raster map at vector points, transfer result into R<br />
goutput <- execGRASS("r.what", map="elev_state_500m", points="geodetic_pts", separator=",", intern=TRUE)<br />
str(goutput)<br />
chr [1:29939] "571530.81289275,265739.968425953,,187.8082200648" ...<br />
<br />
# parse it<br />
con <- textConnection(goutput)<br />
go1 <- read.csv(con, header=FALSE)<br />
str(go1)<br />
'data.frame': 29939 obs. of 4 variables:<br />
$ V1: num 571531 571359 571976 572391 573011 ...<br />
$ V2: num 265740 265987 267049 267513 269615 ...<br />
$ V3: logi NA NA NA NA NA NA ...<br />
$ V4: Factor w/ 22738 levels "-0.0048115728",..: 6859 6642 6749 6411 6356 6904 7506 7224 6908 7167 ...<br />
summary(go1)<br />
V1 V2 V3 V4 <br />
Min. :121862 Min. : 7991 Mode:logical 0 : 723 <br />
1st Qu.:462706 1st Qu.:162508 NA's:29939 * : 293 <br />
Median :610328 Median :204502 0.3048 : 47 <br />
Mean :588514 Mean :200038 0.6096 : 44 <br />
3rd Qu.:717610 3rd Qu.:247633 1.524 : 42 <br />
Max. :946743 Max. :327186 0.9144 : 23 <br />
(Other):28767 <br />
</source><br />
<br />
=== Exporting data back to GRASS ===<br />
<br />
Finally, a SpatialGridDataFrame object is written back to a GRASS raster map:<br />
<br />
First prepare some data: (square root of elevation)<br />
<source lang="rsplus"><br />
ncdata$sqdem <- sqrt(ncdata$elevation)<br />
</source><br />
<br />
Export data from ''R'' back into a GRASS raster map:<br />
<source lang="rsplus"><br />
write_RAST(ncdata$sqdem, "sqdemNC", flags = c("o","overwrite"))<br />
</source><br />
<br />
Check that it imported properly:<br />
<source lang="rsplus"><br />
execGRASS("r.info", parameters=list(map="sqdemNC"))<br />
</source><br />
<br />
<pre><br />
+----------------------------------------------------------------------------+<br />
| Map: sqdemNC Date: Fri Apr 21 17:14:05 2023 |<br />
| Mapset: PERMANENT Login of Creator: veroandreo |<br />
| Location: nc_spm_08_grass7 |<br />
| DataBase: /home/veroandreo/grassdata |<br />
| Title: |<br />
| Timestamp: none |<br />
|----------------------------------------------------------------------------|<br />
| |<br />
| Type of Map: raster Number of Categories: 0 |<br />
| Data Type: FCELL Semantic label: (none) |<br />
| Rows: 450 |<br />
| Columns: 500 |<br />
| Total Cells: 225000 |<br />
| Projection: Lambert Conformal Conic |<br />
| N: 228500 S: 215000 Res: 30 |<br />
| E: 645000 W: 630000 Res: 30 |<br />
| Range of data: min = 7.478182 max = 12.50008 |<br />
| |<br />
| Data Description: |<br />
| generated by r.in.gdal |<br />
| |<br />
| Comments: |<br />
| r.in.gdal --overwrite -o input="/home/veroandreo/tmp/grass8-veroandr\ |<br />
| eo-120898/RtmpPcRHkF/file1da12dbc5b5d.grd" output="sqdemNC" memory=3\ |<br />
| 00 offset=0 num_digits=0 |<br />
| |<br />
+----------------------------------------------------------------------------+<br />
</pre><br />
<br />
=== Using RStudio in a GRASS GIS session ===<br />
<br />
If you are most used to run R through RStudio, but still want to have all GRASS data available for performing<br />
any analyses without loosing the possibility of still using GRASS command line, you can run:<br />
<br />
<source lang="bash"><br />
GRASS> rstudio &<br />
</source><br />
<br />
or, if you already are working on a certain RStudio project:<br />
<br />
<source lang="bash"><br />
GRASS> rstudio /path/to/project/folder/ &<br />
</source><br />
<br />
Then, you load rgrass library in your RStudio project<br />
<source lang="rsplus"><br />
library(rgrass)<br />
</source><br />
<br />
and you are ready to go.<br />
<br />
[[File:Grass7_rstudio.png|thumb|500px|center|RStudio used in GRASS GIS session]]<br />
<br />
== GRASS within R ==<br />
<br />
In this case, we start '''GRASS GIS within an R session''', i.e., we use <tt>initGRASS()</tt> to start GRASS in a temporary location or in an existing GRASS GIS location.<br />
<br />
The first argument in initGRASS() is gisBase=. This argument refers to the path where GRASS is installed. In the latest rgrass <br />
version, if the gisBase argument is missing, initGRASS() will do a minimal effort of guessing it. Firstly, if a GRASS_INSTALLATION environment variable is availabe, then its value will automatically be used for gisBase. If not, then the system command <tt>grass --config path</> will be tried to get the value of GISBASE that corresponds to the GRASS installation in the system PATH (if any).<br />
<br />
If users, still want/need to pass the path to GRASS installation themselves, they can run:<br />
<br />
<source lang="bash"><br />
# OSGeo4W shell, Linux, Mac OSX users:<br />
grass --config path<br />
</source><br />
<br />
It may report something like:<br />
<source lang="bash"><br />
# OSGeo4W users:<br />
C:\OSGeo4W64\apps\grass\grass<br />
<br />
# Linux, Mac OSX users:<br />
/usr/local/grass<br />
</source><br />
<br />
If GRASS GIS was installed through OSGeo4W, users should first start the OSGeo4W Shell. Note that it may start in C: or a directory<br />
where the user does not have writing permission. Before calling R or RStudio, first change to a directory where you are <br />
sure you have writing permission.<br />
<br />
<source lang="rsplus"><br />
## MS-Windows users (example for an OSGeo4W 64bit installation)<br />
# change to a directory with writing permission<br />
C:\>d:<br />
D:\>cd temp<br />
D:\temp>cd testR<br />
<br />
# start R within this directory:<br />
D:\temp\testR>R<br />
<br />
# to start RStudio from OSGeo4W Shell, run: "C:/Program Files/RStudio/bin/rstudio.exe"<br />
<br />
# load rgrass package<br />
library(rgrass)<br />
<br />
# initialisation of GRASS in the North Carolina sample dataset<br />
initGRASS(gisBase = "C:/OSGeo4W64/apps/grass/grass",<br />
gisDbase = "C:/Users/marissa/grassdata/",<br />
location = "nc_spm_08_grass7", <br />
mapset = "user1",<br />
home=tempdir(),<br />
override = TRUE)<br />
</source><br />
<br />
Linux and Mac OSX users just need to start R or RStudio the usual way, load the rgrass package and initialize GRASS as shown below:<br />
<br />
<source lang="rsplus"><br />
library(rgrass)<br />
<br />
# initialisation of GRASS in the North Carolina sample dataset<br />
initGRASS(gisBase = "/usr/lib64/grass82",<br />
gisDbase = "/home/veroandreo/grassdata/",<br />
location = "nc_basic_spm_grass7",<br />
mapset = "user1",<br />
home=tempdir(),<br />
override = TRUE)<br />
</source><br />
<br />
<br />
=== Temporary location ===<br />
<br />
If we don’t pass an existing location to initGRASS(), a temporary GRASS location will be created and set. By default this will be<br />
an XY location, i.e., no CRS defined. To define a CRS for the temporary location, we create a terra SpatRaster object that by default will be EPSG:4326.<br />
<br />
<source lang="rsplus"><br />
library(terra)<br />
x <- rast()<br />
x<br />
class : SpatRaster <br />
dimensions : 180, 360, 1 (nrow, ncol, nlyr)<br />
resolution : 1, 1 (x, y)<br />
extent : -180, 180, -90, 90 (xmin, xmax, ymin, ymax)<br />
coord. ref. : lon/lat WGS 84<br />
</source><br />
<br />
Then, we use that object to provide an EPSG to our temporary location via the SG= parameter and we start GRASS:<br />
<br />
<source lang="rsplus"><br />
initGRASS(home = tempdir(), <br />
SG = x, <br />
override = TRUE)<br />
</source><br />
<br />
After that, users can write their raster and vector maps into GRASS with write_RAST() and write_VECT(), use GRASS GIS modules over those data with execGRASS() and export the results back to R with read_RAST() and read_VECT() as exemplified above.<br />
<br />
=== Existing location ===<br />
<br />
In the case of existing locations and mapsets, users will provide the path to them via the location= and mapset= parameters, and then read data from GRASS database into R through read_RAST() and read_VECT(), do their analyses or modeling in R and potentially write results back into GRASS with write_RAST() and write_VECT(). See examples above.<br />
<br />
== R in GRASS in batch mode ==<br />
<br />
Run the following script with<br />
<br />
<source lang="bash"><br />
R CMD BATCH batch.R<br />
</source><br />
<br />
<source lang="rsplus"><br />
library(rgrass)<br />
library(terra)<br />
# initialisation of GRASS in the North Carolina sample dataset<br />
initGRASS(gisBase = "/usr/lib64/grass82", <br />
home = tempdir(), <br />
gisDbase = "/home/veroandreo/grassdata/",<br />
location = "nc_spm_08_grass7", <br />
mapset = "user1",<br />
override = TRUE)<br />
# set region to default<br />
system("g.region -dp")<br />
# verify<br />
gmeta()<br />
# read data into R<br />
ncdata <- read_RAST("geology_30m", cat=TRUE)<br />
# summary of geology map<br />
summary(ncdata$geology_30m)<br />
proc.time()<br />
</source><br />
<br />
The result is (shorted here):<br />
<source lang="bash"><br />
cat batch.Rout<br />
</source> <br />
<br />
<source lang="rsplus"><br />
R version 4.1.3 (2022-03-10) -- "One Push-Up"<br />
Copyright (C) 2022 The R Foundation for Statistical Computing<br />
Platform: x86_64-redhat-linux-gnu (64-bit)<br />
<br />
> library(rgrass)<br />
Loading required package: XML<br />
GRASS GIS interface loaded with GRASS version: (GRASS not running)<br />
> library(terra)<br />
terra 1.7.23<br />
<br />
> # initialisation of GRASS in the North Carolina sample dataset<br />
> initGRASS(gisBase = "/usr/lib64/grass82", <br />
+ home = tempdir(), <br />
+ gisDbase = "/home/veroandreo/grassdata/",<br />
+ location = "nc_spm_08_grass7", <br />
+ mapset = "user1",<br />
+ override = TRUE)<br />
gisdbase /home/veroandreo/grassdata/ <br />
location nc_spm_08_grass7 <br />
mapset user1 <br />
rows 620 <br />
columns 1630 <br />
north 320000 <br />
south 10000 <br />
west 120000 <br />
east 935000 <br />
nsres 500 <br />
ewres 500 <br />
projection:<br />
PROJCRS["NAD83(HARN) / North Carolina",<br />
BASEGEOGCRS["NAD83(HARN)",<br />
DATUM["NAD83 (High Accuracy Reference Network)",<br />
ELLIPSOID["GRS 1980",6378137,298.257222101,<br />
<br />
> # set region to default<br />
> system("g.region -dp")<br />
projection: 99 (Lambert Conformal Conic)<br />
zone: 0<br />
datum: nad83<br />
ellipsoid: a=6378137 es=0.006694380022900787<br />
north: 320000<br />
south: 10000<br />
west: 120000<br />
east: 935000<br />
nsres: 500<br />
ewres: 500<br />
rows: 620<br />
cols: 1630<br />
cells: 1010600<br />
<br />
> gmeta()<br />
gisdbase /home/veroandreo/grassdata/ <br />
location nc_spm_08_grass7 <br />
mapset user1 <br />
rows 620 <br />
columns 1630 <br />
north 320000 <br />
south 10000 <br />
west 120000 <br />
east 935000 <br />
nsres 500 <br />
ewres 500 <br />
projection:<br />
PROJCRS["NAD83(HARN) / North Carolina",<br />
BASEGEOGCRS["NAD83(HARN)",<br />
DATUM["NAD83 (High Accuracy Reference Network)",<br />
ELLIPSOID["GRS 1980",6378137,298.257222101,<br />
LENGTHUNIT["metre",1]]],<br />
... <br />
...<br />
BBOX[33.83,-84.33,36.59,-75.38]],<br />
ID["EPSG",3358]] <br />
...<br />
> ncdata <- read_RAST("elev_state_500m")<br />
...<br />
r.out.gdal complete. File </home/veroandreo/tmp/RtmpoA1IKV/file2844e28321574.grd> created.<br />
<br />
> summary(ncdata)<br />
file2844e28321574<br />
Min. : -6.47 <br />
1st Qu.: 14.36 <br />
Median : 86.55 <br />
Mean : 214.55 <br />
3rd Qu.: 252.66 <br />
Max. :1878.39 <br />
NA's :46188 <br />
<br />
> proc.time()<br />
user system elapsed <br />
15.574 1.275 16.998 <br />
</source><br />
<br />
== Troubleshooting ==<br />
<br />
=== Running out of disk space ===<br />
<br />
Linux: A common issue is that /tmp/ is used for temporary files albeit being often a small partition. To change that to a larger directory, you may '''add''' to your <tt>$HOME/.bashrc</tt> the entry:<br />
<br />
<source lang="bash"><br />
# change TMP directory of R (note: of course also another directory than suggested here is fine)<br />
mkdir -p $HOME/tmp<br />
export TMP=$HOME/tmp<br />
</source><br />
<br />
The drawback of this approach is that on modern Linux systems the /tmp/ is a fast RAM disk (based on tempfs) while HOME directories are often on slower spinning disks (unless you have a SSD drive). At least you no longer run out of disk space easily.<br />
<br />
[[Category:FAQ]]<br />
[[Category:Linking to other languages]]<br />
[[Category:R]]<br />
[[Category:Statistics]]</div>Veroandreohttps://grasswiki.osgeo.org/w/index.php?title=R_statistics/rgrass&diff=26895R statistics/rgrass2023-04-21T19:39:24Z<p>Veroandreo: edit batch section</p>
<hr />
<div>== Installation ==<br />
<br />
See [[R_statistics/Installation]]<br />
<br />
== Terminology ==<br />
<br />
See "Overview" in [[R_statistics]]<br />
<br />
== R within GRASS ==<br />
<br />
In this example, we will use '''R within a GRASS GIS session''', i.e. start R (or RStudio) from the GRASS GIS terminal or command line interface.<br />
<br />
=== Startup ===<br />
<br />
* First start a GRASS GIS session. Then, at the GRASS command line start ''R'' (for an 'rstudio' session, see below)<br />
: ''In this example we will use the [https://grass.osgeo.org/download/data/#NorthCarolinaDataset North Carolina sample dataset].''<br />
<br />
Reset the region settings to the defaults<br />
<source lang="bash"><br />
GRASS (nc_spm_08_grass7):~ > g.region -d<br />
</source><br />
<br />
Launch R from the GRASS prompt<br />
<source lang="bash"><br />
GRASS (nc_spm_08_grass7):~ > R<br />
</source><br />
<br />
Load the ''rgrass'' library:<br />
<source lang="rsplus"><br />
library(rgrass)<br />
</source><br />
<br />
Get the GRASS environment (mapset, region, map projection, etc.); you can display the metadata for your location by printing G:<br />
<source lang="rsplus"><br />
gmeta()<br />
gisdbase /home/mneteler/grassdata <br />
location nc_spm_08_grass7 <br />
mapset user1 <br />
rows 620 <br />
columns 1630 <br />
north 320000 <br />
south 10000 <br />
west 120000 <br />
east 935000 <br />
nsres 500 <br />
ewres 500 <br />
projection:<br />
PROJCRS["NAD83(HARN) / North Carolina",<br />
BASEGEOGCRS["NAD83(HARN)",<br />
DATUM["NAD83 (High Accuracy Reference Network)",<br />
ELLIPSOID["GRS 1980",6378137,298.257222101,<br />
LENGTHUNIT["metre",1]]],<br />
PRIMEM["Greenwich",0,<br />
ANGLEUNIT["degree",0.0174532925199433]],<br />
ID["EPSG",4152]],<br />
CONVERSION["SPCS83 North Carolina zone (meters)",<br />
METHOD["Lambert Conic Conformal (2SP)",<br />
ID["EPSG",9802]],<br />
PARAMETER["Latitude of false origin",33.75,<br />
ANGLEUNIT["degree",0.0174532925199433],<br />
ID["EPSG",8821]],<br />
PARAMETER["Longitude of false origin",-79,<br />
ANGLEUNIT["degree",0.0174532925199433],<br />
ID["EPSG",8822]],<br />
PARAMETER["Latitude of 1st standard parallel",36.1666666666667,<br />
ANGLEUNIT["degree",0.0174532925199433],<br />
ID["EPSG",8823]],<br />
PARAMETER["Latitude of 2nd standard parallel",34.3333333333333,<br />
ANGLEUNIT["degree",0.0174532925199433],<br />
ID["EPSG",8824]],<br />
PARAMETER["Easting at false origin",609601.22,<br />
LENGTHUNIT["metre",1],<br />
ID["EPSG",8826]],<br />
PARAMETER["Northing at false origin",0,<br />
LENGTHUNIT["metre",1],<br />
ID["EPSG",8827]]],<br />
CS[Cartesian,2],<br />
AXIS["easting (X)",east,<br />
ORDER[1],<br />
LENGTHUNIT["metre",1]],<br />
AXIS["northing (Y)",north,<br />
ORDER[2],<br />
LENGTHUNIT["metre",1]],<br />
USAGE[<br />
SCOPE["Engineering survey, topographic mapping."],<br />
AREA["United States (USA) - North Carolina - counties of Alamance; Alexander; Alleghany; Anson; Ashe; Avery; Beaufort; Bertie; Bladen; Brunswick; Buncombe; Burke; Cabarrus; Caldwell; Camden; Carteret; Caswell; Catawba; Chatham; Cherokee; Chowan; Clay; Cleveland; Columbus; Craven; Cumberland; Currituck; Dare; Davidson; Davie; Duplin; Durham; Edgecombe; Forsyth; Franklin; Gaston; Gates; Graham; Granville; Greene; Guilford; Halifax; Harnett; Haywood; Henderson; Hertford; Hoke; Hyde; Iredell; Jackson; Johnston; Jones; Lee; Lenoir; Lincoln; Macon; Madison; Martin; McDowell; Mecklenburg; Mitchell; Montgomery; Moore; Nash; New Hanover; Northampton; Onslow; Orange; Pamlico; Pasquotank; Pender; Perquimans; Person; Pitt; Polk; Randolph; Richmond; Robeson; Rockingham; Rowan; Rutherford; Sampson; Scotland; Stanly; Stokes; Surry; Swain; Transylvania; Tyrrell; Union; Vance; Wake; Warren; Washington; Watauga; Wayne; Wilkes; Wilson; Yadkin; Yancey."],<br />
BBOX[33.83,-84.33,36.59,-75.38]],<br />
ID["EPSG",3358]]<br />
</source><br />
<br />
=== Listing of existing maps ===<br />
<br />
List available vector maps:<br />
<source lang="rsplus"><br />
execGRASS("g.list", parameters = list(type = "vector"))<br />
</source><br />
<br />
List selected vector maps (wildcard):<br />
<source lang="rsplus"><br />
execGRASS("g.list", parameters = list(type = "vector", pattern = "precip*"))<br />
precip<br />
precip_30ynormals<br />
precip_30ynormals_3d<br />
</source><br />
<br />
Save selected vector maps into R vector:<br />
<source lang="rsplus"><br />
my_vmaps <- execGRASS("g.list", parameters = list(type = "vector", pattern = "precip*"))<br />
attributes(my_vmaps)<br />
attributes(my_vmaps)$resOut<br />
[1] "precip" "precip_30ynormals" "precip_30ynormals_3d"<br />
</source><br />
<br />
List available raster maps:<br />
<source lang="rsplus"><br />
execGRASS("g.list", parameters = list(type = "raster"))<br />
</source><br />
<br />
List selected raster maps (wildcard):<br />
<source lang="rsplus"><br />
execGRASS("g.list", parameters = list(type = "raster", pattern = "lsat7_2002*"))<br />
lsat7_2002_10<br />
lsat7_2002_20<br />
lsat7_2002_30<br />
lsat7_2002_40<br />
lsat7_2002_50<br />
lsat7_2002_61<br />
lsat7_2002_62<br />
lsat7_2002_70<br />
lsat7_2002_80<br />
</source><br />
<br />
=== Reading data from GRASS ===<br />
<br />
==== Example 1: raster maps ====<br />
<br />
Manual page: [https://search.r-project.org/CRAN/refmans/rgrass/html/readRAST.html read_RAST()]<br />
<br />
Read two GRASS raster maps, "geology_30m" and "elevation", from the North Carolina sample data location into the R current session as a new object "ncdata". This object is a SpatRaster layer from terra package:<br />
<source lang="rsplus"><br />
ncdata <- read_RAST(c("geology_30m", "elevation"))<br />
</source><br />
<br />
We can verify the new R object:<br />
<source lang="rsplus"><br />
ncdata<br />
class : SpatRaster <br />
dimensions : 450, 500, 2 (nrow, ncol, nlyr)<br />
resolution : 30, 30 (x, y)<br />
extent : 630000, 645000, 215000, 228500 (xmin, xmax, ymin, ymax)<br />
coord. ref. : +proj=lcc +lat_0=33.75 +lon_0=-79 +lat_1=36.1666666666667 +lat_2=34.3333333333333 +x_0=609601.22 +y_0=0 +ellps=GRS80 +units=m +no_defs <br />
sources : file1da12a752d65.grd <br />
file1da12112d9ea4.grd <br />
names : geology_30m, elevation <br />
min values : 217, 55.92321 <br />
max values : 948, 156.25197<br />
</source><br />
<br />
Now, let's plot one of the raster layers within the SpatRaster object. We'll load terra library to have all functionality available:<br />
<source lang="rsplus"><br />
library(terra)<br />
plot(ncdata$elevation, main="North Carolina elevation")<br />
</source><br />
<br />
[[Image:ncdata.png|center]]<br />
<br />
In addition, we can show what is going on inside the objects read into R:<br />
<source lang="rsplus"><br />
summary(ncdata)<br />
geology_30m elevation <br />
Min. :217.0 Min. : 56.01 <br />
1st Qu.:217.0 1st Qu.: 94.77 <br />
Median :270.0 Median :108.86 <br />
Mean :311.2 Mean :110.36 <br />
3rd Qu.:270.0 3rd Qu.:126.80 <br />
Max. :948.0 Max. :156.07 <br />
</source><br />
<br />
==== Example 2: single raster map ====<br />
<br />
Here an example to transfer a single raster map from GRASS GIS to R:<br />
<br />
<source lang="rsplus"><br />
library(rgrass)<br />
library(terra)<br />
execGRASS("g.region", raster = "elevation", flags = "p")<br />
ncdata <- read_RAST("elevation")<br />
summary(ncdata)<br />
plot(ncdata)<br />
</source><br />
<br />
==== Example 3: vector maps ====<br />
<br />
Here an example to transfer a single vector map from GRASS GIS to R. In this case, vector maps from GRASS will be converted into SpatVector objects from the terra package in R:<br />
<br />
<source lang="rsplus"><br />
# needed prerequisite<br />
library(rgrass)<br />
library(terra)<br />
execGRASS("v.info", map="schools_wake", layer="1")<br />
vInfo("schools_wake")<br />
myschools <- read_VECT("schools_wake")<br />
print(summary(myschools))<br />
plot(myschools)<br />
</source><br />
<br />
==== Example 4: Summarizing data ====<br />
<br />
We can create a table of cell counts:<br />
<source lang="rsplus"><br />
freq(ncdata$geology_30m)<br />
</source><br />
<pre><br />
layer value count<br />
1 1 217 80618<br />
2 1 262 22076<br />
3 1 270 76597<br />
4 1 405 28190<br />
5 1 583 2401<br />
6 1 720 536<br />
7 1 766 786<br />
8 1 862 6858<br />
9 1 910 4996<br />
10 1 921 1392<br />
11 1 945 1<br />
12 1 946 452<br />
13 1 948 97<br />
</pre><br />
<br />
And compare with the equivalent GRASS module:<br />
<source lang="rsplus"><br />
execGRASS("r.stats", flags=c("c", "l"), parameters=list(input="geology_30m"), ignore.stderr=TRUE)<br />
</source><br />
<pre><br />
217 CZfg 80618<br />
262 CZlg 22076<br />
270 CZig 76597<br />
405 CZbg 28190<br />
583 CZve 2401<br />
720 CZam 536<br />
766 CZg 786<br />
862 CZam 6858<br />
910 CZbg 4996<br />
921 Km 1392<br />
945 CZbg 1<br />
946 CZam 452<br />
948 CZam 97<br />
</pre><br />
<br />
<!--- it does no work with terra<br />
Create a box plot of geologic types at different elevations:<br />
<source lang="rsplus"><br />
boxplot(ncdata$elevation ~ ncdata$geology_30m, medlwd = 1)<br />
</source><br />
<br />
[[Image:boxplot_geo.png|center]]<br />
---><br />
<br />
==== Example 5: Querying maps ====<br />
<br />
Sometimes you may want to query GRASS GIS maps from your R session. As an example, here the transfer of raster pixel values at the position of vector points:<br />
<br />
<source lang="rsplus"><br />
# set the computational region to the raster map:<br />
execGRASS("g.region", raster = "elev_state_500m", flags = "p")<br />
<br />
# query raster map at vector points, transfer result into R<br />
goutput <- execGRASS("r.what", map="elev_state_500m", points="geodetic_pts", separator=",", intern=TRUE)<br />
str(goutput)<br />
chr [1:29939] "571530.81289275,265739.968425953,,187.8082200648" ...<br />
<br />
# parse it<br />
con <- textConnection(goutput)<br />
go1 <- read.csv(con, header=FALSE)<br />
str(go1)<br />
'data.frame': 29939 obs. of 4 variables:<br />
$ V1: num 571531 571359 571976 572391 573011 ...<br />
$ V2: num 265740 265987 267049 267513 269615 ...<br />
$ V3: logi NA NA NA NA NA NA ...<br />
$ V4: Factor w/ 22738 levels "-0.0048115728",..: 6859 6642 6749 6411 6356 6904 7506 7224 6908 7167 ...<br />
summary(go1)<br />
V1 V2 V3 V4 <br />
Min. :121862 Min. : 7991 Mode:logical 0 : 723 <br />
1st Qu.:462706 1st Qu.:162508 NA's:29939 * : 293 <br />
Median :610328 Median :204502 0.3048 : 47 <br />
Mean :588514 Mean :200038 0.6096 : 44 <br />
3rd Qu.:717610 3rd Qu.:247633 1.524 : 42 <br />
Max. :946743 Max. :327186 0.9144 : 23 <br />
(Other):28767 <br />
</source><br />
<br />
=== Exporting data back to GRASS ===<br />
<br />
Finally, a SpatialGridDataFrame object is written back to a GRASS raster map:<br />
<br />
First prepare some data: (square root of elevation)<br />
<source lang="rsplus"><br />
ncdata$sqdem <- sqrt(ncdata$elevation)<br />
</source><br />
<br />
Export data from ''R'' back into a GRASS raster map:<br />
<source lang="rsplus"><br />
write_RAST(ncdata$sqdem, "sqdemNC", flags = c("o","overwrite"))<br />
</source><br />
<br />
Check that it imported properly:<br />
<source lang="rsplus"><br />
execGRASS("r.info", parameters=list(map="sqdemNC"))<br />
</source><br />
<br />
<pre><br />
+----------------------------------------------------------------------------+<br />
| Map: sqdemNC Date: Fri Apr 21 17:14:05 2023 |<br />
| Mapset: PERMANENT Login of Creator: veroandreo |<br />
| Location: nc_spm_08_grass7 |<br />
| DataBase: /home/veroandreo/grassdata |<br />
| Title: |<br />
| Timestamp: none |<br />
|----------------------------------------------------------------------------|<br />
| |<br />
| Type of Map: raster Number of Categories: 0 |<br />
| Data Type: FCELL Semantic label: (none) |<br />
| Rows: 450 |<br />
| Columns: 500 |<br />
| Total Cells: 225000 |<br />
| Projection: Lambert Conformal Conic |<br />
| N: 228500 S: 215000 Res: 30 |<br />
| E: 645000 W: 630000 Res: 30 |<br />
| Range of data: min = 7.478182 max = 12.50008 |<br />
| |<br />
| Data Description: |<br />
| generated by r.in.gdal |<br />
| |<br />
| Comments: |<br />
| r.in.gdal --overwrite -o input="/home/veroandreo/tmp/grass8-veroandr\ |<br />
| eo-120898/RtmpPcRHkF/file1da12dbc5b5d.grd" output="sqdemNC" memory=3\ |<br />
| 00 offset=0 num_digits=0 |<br />
| |<br />
+----------------------------------------------------------------------------+<br />
</pre><br />
<br />
=== Using RStudio in a GRASS GIS session ===<br />
<br />
If you are most used to run R through RStudio, but still want to have all GRASS data available for performing<br />
any analyses without loosing the possibility of still using GRASS command line, you can run:<br />
<br />
<source lang="bash"><br />
GRASS> rstudio &<br />
</source><br />
<br />
or, if you already are working on a certain RStudio project:<br />
<br />
<source lang="bash"><br />
GRASS> rstudio /path/to/project/folder/ &<br />
</source><br />
<br />
Then, you load rgrass library in your RStudio project<br />
<source lang="rsplus"><br />
library(rgrass)<br />
</source><br />
<br />
and you are ready to go.<br />
<br />
[[File:Grass7_rstudio.png|thumb|500px|center|RStudio used in GRASS GIS session]]<br />
<br />
== GRASS within R ==<br />
<br />
In this case, we start '''GRASS GIS within an R session''', i.e., we use <tt>initGRASS()</tt> to start GRASS in a temporary location or in an existing GRASS GIS location.<br />
<br />
The first argument in initGRASS() is gisBase=. This argument refers to the path where GRASS is installed. In the latest rgrass <br />
version, if the gisBase argument is missing, initGRASS() will do a minimal effort of guessing it. Firstly, if a GRASS_INSTALLATION environment variable is availabe, then its value will automatically be used for gisBase. If not, then the system command <tt>grass --config path</> will be tried to get the value of GISBASE that corresponds to the GRASS installation in the system PATH (if any).<br />
<br />
If users, still want/need to pass the path to GRASS installation themselves, they can run:<br />
<br />
<source lang="bash"><br />
# OSGeo4W shell, Linux, Mac OSX users:<br />
grass --config path<br />
</source><br />
<br />
It may report something like:<br />
<source lang="bash"><br />
# OSGeo4W users:<br />
C:\OSGeo4W64\apps\grass\grass<br />
<br />
# Linux, Mac OSX users:<br />
/usr/local/grass<br />
</source><br />
<br />
If GRASS GIS was installed through OSGeo4W, users should first start the OSGeo4W Shell. Note that it may start in C: or a directory<br />
where the user does not have writing permission. Before calling R or RStudio, first change to a directory where you are <br />
sure you have writing permission.<br />
<br />
<source lang="rsplus"><br />
## MS-Windows users (example for an OSGeo4W 64bit installation)<br />
# change to a directory with writing permission<br />
C:\>d:<br />
D:\>cd temp<br />
D:\temp>cd testR<br />
<br />
# start R within this directory:<br />
D:\temp\testR>R<br />
<br />
# to start RStudio from OSGeo4W Shell, run: "C:/Program Files/RStudio/bin/rstudio.exe"<br />
<br />
# load rgrass package<br />
library(rgrass)<br />
<br />
# initialisation of GRASS in the North Carolina sample dataset<br />
initGRASS(gisBase = "C:/OSGeo4W64/apps/grass/grass",<br />
gisDbase = "C:/Users/marissa/grassdata/",<br />
location = "nc_spm_08_grass7", <br />
mapset = "user1",<br />
home=tempdir(),<br />
override = TRUE)<br />
</source><br />
<br />
Linux and Mac OSX users just need to start R or RStudio the usual way, load the rgrass package and initialize GRASS as shown below:<br />
<br />
<source lang="rsplus"><br />
library(rgrass)<br />
<br />
# initialisation of GRASS in the North Carolina sample dataset<br />
initGRASS(gisBase = "/usr/lib64/grass82",<br />
gisDbase = "/home/veroandreo/grassdata/",<br />
location = "nc_basic_spm_grass7",<br />
mapset = "user1",<br />
home=tempdir(),<br />
override = TRUE)<br />
</source><br />
<br />
<br />
=== Temporary location ===<br />
<br />
If we don’t pass an existing location to initGRASS(), a temporary GRASS location will be created and set. By default this will be<br />
an XY location, i.e., no CRS defined. To define a CRS for the temporary location, we create a terra SpatRaster object that by default will be EPSG:4326.<br />
<br />
<source lang="rsplus"><br />
library(terra)<br />
x <- rast()<br />
x<br />
class : SpatRaster <br />
dimensions : 180, 360, 1 (nrow, ncol, nlyr)<br />
resolution : 1, 1 (x, y)<br />
extent : -180, 180, -90, 90 (xmin, xmax, ymin, ymax)<br />
coord. ref. : lon/lat WGS 84<br />
</source><br />
<br />
Then, we use that object to provide an EPSG to our temporary location via the SG= parameter and we start GRASS:<br />
<br />
<source lang="rsplus"><br />
initGRASS(home = tempdir(), <br />
SG = x, <br />
override = TRUE)<br />
</source><br />
<br />
After that, users can write their raster and vector maps into GRASS with write_RAST() and write_VECT(), use GRASS GIS modules over those data with execGRASS() and export the results back to R with read_RAST() and read_VECT() as exemplified above.<br />
<br />
=== Existing location ===<br />
<br />
In the case of existing locations and mapsets, users will provide the path to them via the location= and mapset= parameters, and then read data from GRASS database into R through read_RAST() and read_VECT(), do their analyses or modeling in R and potentially write results back into GRASS with write_RAST() and write_VECT(). See examples above.<br />
<br />
== R in GRASS in batch mode ==<br />
<br />
Run the following script with<br />
<br />
<source lang="bash"><br />
R CMD BATCH batch.R<br />
</source><br />
<br />
<source lang="rsplus"><br />
library(rgrass)<br />
library(terra)<br />
# initialisation of GRASS in the North Carolina sample dataset<br />
initGRASS(gisBase = "/usr/lib64/grass82", <br />
home = tempdir(), <br />
gisDbase = "/home/veroandreo/grassdata/",<br />
location = "nc_spm_08_grass7", <br />
mapset = "user1",<br />
override = TRUE)<br />
# set region to default<br />
system("g.region -dp")<br />
# verify<br />
gmeta()<br />
# read data into R<br />
ncdata <- read_RAST("geology_30m", cat=TRUE)<br />
# summary of geology map<br />
summary(ncdata$geology_30m)<br />
proc.time()<br />
</source><br />
<br />
The result is (shorted here):<br />
<source lang="bash"><br />
cat batch.Rout<br />
</source> <br />
<br />
<source lang="rsplus"><br />
R version 4.1.3 (2022-03-10) -- "One Push-Up"<br />
Copyright (C) 2022 The R Foundation for Statistical Computing<br />
Platform: x86_64-redhat-linux-gnu (64-bit)<br />
<br />
> library(rgrass)<br />
Loading required package: XML<br />
GRASS GIS interface loaded with GRASS version: (GRASS not running)<br />
> library(terra)<br />
terra 1.7.23<br />
<br />
> # initialisation of GRASS in the North Carolina sample dataset<br />
> initGRASS(gisBase = "/usr/lib64/grass82", <br />
+ home = tempdir(), <br />
+ gisDbase = "/home/veroandreo/grassdata/",<br />
+ location = "nc_spm_08_grass7", <br />
+ mapset = "user1",<br />
+ override = TRUE)<br />
gisdbase /home/veroandreo/grassdata/ <br />
location nc_spm_08_grass7 <br />
mapset user1 <br />
rows 620 <br />
columns 1630 <br />
north 320000 <br />
south 10000 <br />
west 120000 <br />
east 935000 <br />
nsres 500 <br />
ewres 500 <br />
projection:<br />
PROJCRS["NAD83(HARN) / North Carolina",<br />
BASEGEOGCRS["NAD83(HARN)",<br />
DATUM["NAD83 (High Accuracy Reference Network)",<br />
ELLIPSOID["GRS 1980",6378137,298.257222101,<br />
<br />
> # set region to default<br />
> system("g.region -dp")<br />
projection: 99 (Lambert Conformal Conic)<br />
zone: 0<br />
datum: nad83<br />
ellipsoid: a=6378137 es=0.006694380022900787<br />
north: 320000<br />
south: 10000<br />
west: 120000<br />
east: 935000<br />
nsres: 500<br />
ewres: 500<br />
rows: 620<br />
cols: 1630<br />
cells: 1010600<br />
<br />
> gmeta()<br />
gisdbase /home/veroandreo/grassdata/ <br />
location nc_spm_08_grass7 <br />
mapset user1 <br />
rows 620 <br />
columns 1630 <br />
north 320000 <br />
south 10000 <br />
west 120000 <br />
east 935000 <br />
nsres 500 <br />
ewres 500 <br />
projection:<br />
PROJCRS["NAD83(HARN) / North Carolina",<br />
BASEGEOGCRS["NAD83(HARN)",<br />
DATUM["NAD83 (High Accuracy Reference Network)",<br />
ELLIPSOID["GRS 1980",6378137,298.257222101,<br />
LENGTHUNIT["metre",1]]],<br />
... <br />
...<br />
BBOX[33.83,-84.33,36.59,-75.38]],<br />
ID["EPSG",3358]] <br />
...<br />
> ncdata <- read_RAST("elev_state_500m")<br />
...<br />
r.out.gdal complete. File </home/veroandreo/tmp/RtmpoA1IKV/file2844e28321574.grd> created.<br />
<br />
> summary(ncdata)<br />
file2844e28321574<br />
Min. : -6.47 <br />
1st Qu.: 14.36 <br />
Median : 86.55 <br />
Mean : 214.55 <br />
3rd Qu.: 252.66 <br />
Max. :1878.39 <br />
NA's :46188 <br />
<br />
> proc.time()<br />
user system elapsed <br />
15.574 1.275 16.998 <br />
</source><br />
<br />
== Troubleshooting ==<br />
<br />
=== Running out of disk space ===<br />
<br />
Linux: A common issue is that /tmp/ is used for temporary files albeit being often a small partition. To change that to a larger directory, you may '''add''' to your <tt>$HOME/.bashrc</tt> the entry:<br />
<br />
<source lang="bash"><br />
# change TMP directory of R (note: of course also another directory than suggested here is fine)<br />
mkdir -p $HOME/tmp<br />
export TMP=$HOME/tmp<br />
</source><br />
<br />
The drawback of this approach is that on modern Linux systems the /tmp/ is a fast RAM disk (based on tempfs) while HOME directories are often on slower spinning disks (unless you have a SSD drive). At least you no longer run out of disk space easily.<br />
<br />
[[Category:FAQ]]<br />
[[Category:Linking to other languages]]<br />
[[Category:R]]<br />
[[Category:Statistics]]</div>Veroandreohttps://grasswiki.osgeo.org/w/index.php?title=R_statistics/rgrass&diff=26893R statistics/rgrass2023-04-21T19:10:03Z<p>Veroandreo: GRASS in R - rewrite most of the section</p>
<hr />
<div>== Installation ==<br />
<br />
See [[R_statistics/Installation]]<br />
<br />
== Terminology ==<br />
<br />
See "Overview" in [[R_statistics]]<br />
<br />
== R within GRASS ==<br />
<br />
In this example, we will use '''R within a GRASS GIS session''', i.e. start R (or RStudio) from the GRASS GIS terminal or command line interface.<br />
<br />
=== Startup ===<br />
<br />
* First start a GRASS GIS session. Then, at the GRASS command line start ''R'' (for an 'rstudio' session, see below)<br />
: ''In this example we will use the [https://grass.osgeo.org/download/data/#NorthCarolinaDataset North Carolina sample dataset].''<br />
<br />
Reset the region settings to the defaults<br />
<source lang="bash"><br />
GRASS (nc_spm_08_grass7):~ > g.region -d<br />
</source><br />
<br />
Launch R from the GRASS prompt<br />
<source lang="bash"><br />
GRASS (nc_spm_08_grass7):~ > R<br />
</source><br />
<br />
Load the ''rgrass'' library:<br />
<source lang="rsplus"><br />
library(rgrass)<br />
</source><br />
<br />
Get the GRASS environment (mapset, region, map projection, etc.); you can display the metadata for your location by printing G:<br />
<source lang="rsplus"><br />
gmeta()<br />
gisdbase /home/mneteler/grassdata <br />
location nc_spm_08_grass7 <br />
mapset user1 <br />
rows 620 <br />
columns 1630 <br />
north 320000 <br />
south 10000 <br />
west 120000 <br />
east 935000 <br />
nsres 500 <br />
ewres 500 <br />
projection:<br />
PROJCRS["NAD83(HARN) / North Carolina",<br />
BASEGEOGCRS["NAD83(HARN)",<br />
DATUM["NAD83 (High Accuracy Reference Network)",<br />
ELLIPSOID["GRS 1980",6378137,298.257222101,<br />
LENGTHUNIT["metre",1]]],<br />
PRIMEM["Greenwich",0,<br />
ANGLEUNIT["degree",0.0174532925199433]],<br />
ID["EPSG",4152]],<br />
CONVERSION["SPCS83 North Carolina zone (meters)",<br />
METHOD["Lambert Conic Conformal (2SP)",<br />
ID["EPSG",9802]],<br />
PARAMETER["Latitude of false origin",33.75,<br />
ANGLEUNIT["degree",0.0174532925199433],<br />
ID["EPSG",8821]],<br />
PARAMETER["Longitude of false origin",-79,<br />
ANGLEUNIT["degree",0.0174532925199433],<br />
ID["EPSG",8822]],<br />
PARAMETER["Latitude of 1st standard parallel",36.1666666666667,<br />
ANGLEUNIT["degree",0.0174532925199433],<br />
ID["EPSG",8823]],<br />
PARAMETER["Latitude of 2nd standard parallel",34.3333333333333,<br />
ANGLEUNIT["degree",0.0174532925199433],<br />
ID["EPSG",8824]],<br />
PARAMETER["Easting at false origin",609601.22,<br />
LENGTHUNIT["metre",1],<br />
ID["EPSG",8826]],<br />
PARAMETER["Northing at false origin",0,<br />
LENGTHUNIT["metre",1],<br />
ID["EPSG",8827]]],<br />
CS[Cartesian,2],<br />
AXIS["easting (X)",east,<br />
ORDER[1],<br />
LENGTHUNIT["metre",1]],<br />
AXIS["northing (Y)",north,<br />
ORDER[2],<br />
LENGTHUNIT["metre",1]],<br />
USAGE[<br />
SCOPE["Engineering survey, topographic mapping."],<br />
AREA["United States (USA) - North Carolina - counties of Alamance; Alexander; Alleghany; Anson; Ashe; Avery; Beaufort; Bertie; Bladen; Brunswick; Buncombe; Burke; Cabarrus; Caldwell; Camden; Carteret; Caswell; Catawba; Chatham; Cherokee; Chowan; Clay; Cleveland; Columbus; Craven; Cumberland; Currituck; Dare; Davidson; Davie; Duplin; Durham; Edgecombe; Forsyth; Franklin; Gaston; Gates; Graham; Granville; Greene; Guilford; Halifax; Harnett; Haywood; Henderson; Hertford; Hoke; Hyde; Iredell; Jackson; Johnston; Jones; Lee; Lenoir; Lincoln; Macon; Madison; Martin; McDowell; Mecklenburg; Mitchell; Montgomery; Moore; Nash; New Hanover; Northampton; Onslow; Orange; Pamlico; Pasquotank; Pender; Perquimans; Person; Pitt; Polk; Randolph; Richmond; Robeson; Rockingham; Rowan; Rutherford; Sampson; Scotland; Stanly; Stokes; Surry; Swain; Transylvania; Tyrrell; Union; Vance; Wake; Warren; Washington; Watauga; Wayne; Wilkes; Wilson; Yadkin; Yancey."],<br />
BBOX[33.83,-84.33,36.59,-75.38]],<br />
ID["EPSG",3358]]<br />
</source><br />
<br />
=== Listing of existing maps ===<br />
<br />
List available vector maps:<br />
<source lang="rsplus"><br />
execGRASS("g.list", parameters = list(type = "vector"))<br />
</source><br />
<br />
List selected vector maps (wildcard):<br />
<source lang="rsplus"><br />
execGRASS("g.list", parameters = list(type = "vector", pattern = "precip*"))<br />
precip<br />
precip_30ynormals<br />
precip_30ynormals_3d<br />
</source><br />
<br />
Save selected vector maps into R vector:<br />
<source lang="rsplus"><br />
my_vmaps <- execGRASS("g.list", parameters = list(type = "vector", pattern = "precip*"))<br />
attributes(my_vmaps)<br />
attributes(my_vmaps)$resOut<br />
[1] "precip" "precip_30ynormals" "precip_30ynormals_3d"<br />
</source><br />
<br />
List available raster maps:<br />
<source lang="rsplus"><br />
execGRASS("g.list", parameters = list(type = "raster"))<br />
</source><br />
<br />
List selected raster maps (wildcard):<br />
<source lang="rsplus"><br />
execGRASS("g.list", parameters = list(type = "raster", pattern = "lsat7_2002*"))<br />
lsat7_2002_10<br />
lsat7_2002_20<br />
lsat7_2002_30<br />
lsat7_2002_40<br />
lsat7_2002_50<br />
lsat7_2002_61<br />
lsat7_2002_62<br />
lsat7_2002_70<br />
lsat7_2002_80<br />
</source><br />
<br />
=== Reading data from GRASS ===<br />
<br />
==== Example 1: raster maps ====<br />
<br />
Manual page: [https://search.r-project.org/CRAN/refmans/rgrass/html/readRAST.html read_RAST()]<br />
<br />
Read two GRASS raster maps, "geology_30m" and "elevation", from the North Carolina sample data location into the R current session as a new object "ncdata". This object is a SpatRaster layer from terra package:<br />
<source lang="rsplus"><br />
ncdata <- read_RAST(c("geology_30m", "elevation"))<br />
</source><br />
<br />
We can verify the new R object:<br />
<source lang="rsplus"><br />
ncdata<br />
class : SpatRaster <br />
dimensions : 450, 500, 2 (nrow, ncol, nlyr)<br />
resolution : 30, 30 (x, y)<br />
extent : 630000, 645000, 215000, 228500 (xmin, xmax, ymin, ymax)<br />
coord. ref. : +proj=lcc +lat_0=33.75 +lon_0=-79 +lat_1=36.1666666666667 +lat_2=34.3333333333333 +x_0=609601.22 +y_0=0 +ellps=GRS80 +units=m +no_defs <br />
sources : file1da12a752d65.grd <br />
file1da12112d9ea4.grd <br />
names : geology_30m, elevation <br />
min values : 217, 55.92321 <br />
max values : 948, 156.25197<br />
</source><br />
<br />
Now, let's plot one of the raster layers within the SpatRaster object. We'll load terra library to have all functionality available:<br />
<source lang="rsplus"><br />
library(terra)<br />
plot(ncdata$elevation, main="North Carolina elevation")<br />
</source><br />
<br />
[[Image:ncdata.png|center]]<br />
<br />
In addition, we can show what is going on inside the objects read into R:<br />
<source lang="rsplus"><br />
summary(ncdata)<br />
geology_30m elevation <br />
Min. :217.0 Min. : 56.01 <br />
1st Qu.:217.0 1st Qu.: 94.77 <br />
Median :270.0 Median :108.86 <br />
Mean :311.2 Mean :110.36 <br />
3rd Qu.:270.0 3rd Qu.:126.80 <br />
Max. :948.0 Max. :156.07 <br />
</source><br />
<br />
==== Example 2: single raster map ====<br />
<br />
Here an example to transfer a single raster map from GRASS GIS to R:<br />
<br />
<source lang="rsplus"><br />
library(rgrass)<br />
library(terra)<br />
execGRASS("g.region", raster = "elevation", flags = "p")<br />
ncdata <- read_RAST("elevation")<br />
summary(ncdata)<br />
plot(ncdata)<br />
</source><br />
<br />
==== Example 3: vector maps ====<br />
<br />
Here an example to transfer a single vector map from GRASS GIS to R. In this case, vector maps from GRASS will be converted into SpatVector objects from the terra package in R:<br />
<br />
<source lang="rsplus"><br />
# needed prerequisite<br />
library(rgrass)<br />
library(terra)<br />
execGRASS("v.info", map="schools_wake", layer="1")<br />
vInfo("schools_wake")<br />
myschools <- read_VECT("schools_wake")<br />
print(summary(myschools))<br />
plot(myschools)<br />
</source><br />
<br />
==== Example 4: Summarizing data ====<br />
<br />
We can create a table of cell counts:<br />
<source lang="rsplus"><br />
freq(ncdata$geology_30m)<br />
</source><br />
<pre><br />
layer value count<br />
1 1 217 80618<br />
2 1 262 22076<br />
3 1 270 76597<br />
4 1 405 28190<br />
5 1 583 2401<br />
6 1 720 536<br />
7 1 766 786<br />
8 1 862 6858<br />
9 1 910 4996<br />
10 1 921 1392<br />
11 1 945 1<br />
12 1 946 452<br />
13 1 948 97<br />
</pre><br />
<br />
And compare with the equivalent GRASS module:<br />
<source lang="rsplus"><br />
execGRASS("r.stats", flags=c("c", "l"), parameters=list(input="geology_30m"), ignore.stderr=TRUE)<br />
</source><br />
<pre><br />
217 CZfg 80618<br />
262 CZlg 22076<br />
270 CZig 76597<br />
405 CZbg 28190<br />
583 CZve 2401<br />
720 CZam 536<br />
766 CZg 786<br />
862 CZam 6858<br />
910 CZbg 4996<br />
921 Km 1392<br />
945 CZbg 1<br />
946 CZam 452<br />
948 CZam 97<br />
</pre><br />
<br />
<!--- it does no work with terra<br />
Create a box plot of geologic types at different elevations:<br />
<source lang="rsplus"><br />
boxplot(ncdata$elevation ~ ncdata$geology_30m, medlwd = 1)<br />
</source><br />
<br />
[[Image:boxplot_geo.png|center]]<br />
---><br />
<br />
==== Example 5: Querying maps ====<br />
<br />
Sometimes you may want to query GRASS GIS maps from your R session. As an example, here the transfer of raster pixel values at the position of vector points:<br />
<br />
<source lang="rsplus"><br />
# set the computational region to the raster map:<br />
execGRASS("g.region", raster = "elev_state_500m", flags = "p")<br />
<br />
# query raster map at vector points, transfer result into R<br />
goutput <- execGRASS("r.what", map="elev_state_500m", points="geodetic_pts", separator=",", intern=TRUE)<br />
str(goutput)<br />
chr [1:29939] "571530.81289275,265739.968425953,,187.8082200648" ...<br />
<br />
# parse it<br />
con <- textConnection(goutput)<br />
go1 <- read.csv(con, header=FALSE)<br />
str(go1)<br />
'data.frame': 29939 obs. of 4 variables:<br />
$ V1: num 571531 571359 571976 572391 573011 ...<br />
$ V2: num 265740 265987 267049 267513 269615 ...<br />
$ V3: logi NA NA NA NA NA NA ...<br />
$ V4: Factor w/ 22738 levels "-0.0048115728",..: 6859 6642 6749 6411 6356 6904 7506 7224 6908 7167 ...<br />
summary(go1)<br />
V1 V2 V3 V4 <br />
Min. :121862 Min. : 7991 Mode:logical 0 : 723 <br />
1st Qu.:462706 1st Qu.:162508 NA's:29939 * : 293 <br />
Median :610328 Median :204502 0.3048 : 47 <br />
Mean :588514 Mean :200038 0.6096 : 44 <br />
3rd Qu.:717610 3rd Qu.:247633 1.524 : 42 <br />
Max. :946743 Max. :327186 0.9144 : 23 <br />
(Other):28767 <br />
</source><br />
<br />
=== Exporting data back to GRASS ===<br />
<br />
Finally, a SpatialGridDataFrame object is written back to a GRASS raster map:<br />
<br />
First prepare some data: (square root of elevation)<br />
<source lang="rsplus"><br />
ncdata$sqdem <- sqrt(ncdata$elevation)<br />
</source><br />
<br />
Export data from ''R'' back into a GRASS raster map:<br />
<source lang="rsplus"><br />
write_RAST(ncdata$sqdem, "sqdemNC", flags = c("o","overwrite"))<br />
</source><br />
<br />
Check that it imported properly:<br />
<source lang="rsplus"><br />
execGRASS("r.info", parameters=list(map="sqdemNC"))<br />
</source><br />
<br />
<pre><br />
+----------------------------------------------------------------------------+<br />
| Map: sqdemNC Date: Fri Apr 21 17:14:05 2023 |<br />
| Mapset: PERMANENT Login of Creator: veroandreo |<br />
| Location: nc_spm_08_grass7 |<br />
| DataBase: /home/veroandreo/grassdata |<br />
| Title: |<br />
| Timestamp: none |<br />
|----------------------------------------------------------------------------|<br />
| |<br />
| Type of Map: raster Number of Categories: 0 |<br />
| Data Type: FCELL Semantic label: (none) |<br />
| Rows: 450 |<br />
| Columns: 500 |<br />
| Total Cells: 225000 |<br />
| Projection: Lambert Conformal Conic |<br />
| N: 228500 S: 215000 Res: 30 |<br />
| E: 645000 W: 630000 Res: 30 |<br />
| Range of data: min = 7.478182 max = 12.50008 |<br />
| |<br />
| Data Description: |<br />
| generated by r.in.gdal |<br />
| |<br />
| Comments: |<br />
| r.in.gdal --overwrite -o input="/home/veroandreo/tmp/grass8-veroandr\ |<br />
| eo-120898/RtmpPcRHkF/file1da12dbc5b5d.grd" output="sqdemNC" memory=3\ |<br />
| 00 offset=0 num_digits=0 |<br />
| |<br />
+----------------------------------------------------------------------------+<br />
</pre><br />
<br />
=== Using RStudio in a GRASS GIS session ===<br />
<br />
If you are most used to run R through RStudio, but still want to have all GRASS data available for performing<br />
any analyses without loosing the possibility of still using GRASS command line, you can run:<br />
<br />
<source lang="bash"><br />
GRASS> rstudio &<br />
</source><br />
<br />
or, if you already are working on a certain RStudio project:<br />
<br />
<source lang="bash"><br />
GRASS> rstudio /path/to/project/folder/ &<br />
</source><br />
<br />
Then, you load rgrass library in your RStudio project<br />
<source lang="rsplus"><br />
library(rgrass)<br />
</source><br />
<br />
and you are ready to go.<br />
<br />
[[File:Grass7_rstudio.png|thumb|500px|center|RStudio used in GRASS GIS session]]<br />
<br />
== GRASS within R ==<br />
<br />
== GRASS within R ==<br />
<br />
In this case, we start '''GRASS GIS within an R session''', i.e., we use <tt>initGRASS()</tt> to start GRASS in a temporary location or in an existing GRASS GIS location.<br />
<br />
The first argument in initGRASS() is gisBase=. This argument refers to the path where GRASS is installed. In the latest rgrass <br />
version, if the gisBase argument is missing, initGRASS() will do a minimal effort of guessing it. Firstly, if a GRASS_INSTALLATION environment variable is availabe, then its value will automatically be used for gisBase. If not, then the system command <tt>grass --config path</> will be tried to get the value of GISBASE that corresponds to the GRASS installation in the system PATH (if any).<br />
<br />
If users, in any case want to pass the path to GRASS installation themselves, they can run:<br />
<br />
<source lang="bash"><br />
# OSGeo4W shell, Linux, Mac OSX users:<br />
grass --config path<br />
</source><br />
<br />
It may report something like:<br />
<source lang="bash"><br />
# OSGeo4W users:<br />
C:\OSGeo4W64\apps\grass\grass<br />
<br />
# Linux, Mac OSX users:<br />
/usr/local/grass<br />
</source><br />
<br />
If GRASS GIS was installed through OSGeo4W, users should first start the OSGeo4W Shell. Note that it may start in C: or a directory<br />
where the user does not have writing permission. Before calling R or RStudio, first change to a directory where you are <br />
sure you have writing permission.<br />
<br />
<source lang="rsplus"><br />
## MS-Windows users (example for an OSGeo4W 64bit installation)<br />
# change to a directory with writing permission<br />
C:\>d:<br />
D:\>cd temp<br />
D:\temp>cd testR<br />
<br />
# start R within this directory:<br />
D:\temp\testR>R<br />
<br />
# to start RStudio from OSGeo4W Shell, run: "C:/Program Files/RStudio/bin/rstudio.exe"<br />
<br />
# load rgrass package<br />
library(rgrass)<br />
<br />
# initialisation of GRASS in the North Carolina sample dataset<br />
initGRASS(gisBase = "C:/OSGeo4W64/apps/grass/grass",<br />
gisDbase = "C:/Users/marissa/grassdata/",<br />
location = "nc_spm_08_grass7", <br />
mapset = "user1",<br />
home=tempdir(),<br />
override = TRUE)<br />
</source><br />
<br />
Linux and Mac OSX users just need to start R or RStudio the usual way, load the rgrass package and initialize GRASS as shown below:<br />
<br />
<source lang="rsplus"><br />
library(rgrass)<br />
<br />
# initialisation of GRASS in the North Carolina sample dataset<br />
initGRASS(gisBase = "/usr/lib64/grass82",<br />
gisDbase = "/home/veroandreo/grassdata/",<br />
location = "nc_basic_spm_grass7",<br />
mapset = "user1",<br />
home=tempdir(),<br />
override = TRUE)<br />
</source><br />
<br />
<br />
=== Temporary location ===<br />
<br />
If we don’t pass an existing location to initGRASS(), a temporary GRASS location will be created and set. By default this will be<br />
an XY location, i.e., no CRS defined. To define a CRS for the temporary location, we create a terra SpatRaster object that by default will be EPSG:4326.<br />
<br />
<source lang="rsplus"><br />
x <- rast()<br />
x<br />
class : SpatRaster <br />
dimensions : 180, 360, 1 (nrow, ncol, nlyr)<br />
resolution : 1, 1 (x, y)<br />
extent : -180, 180, -90, 90 (xmin, xmax, ymin, ymax)<br />
coord. ref. : lon/lat WGS 84<br />
</source><br />
<br />
Then, we use that object to provide an EPSG to our temporary location via the SG= parameter and start GRASS:<br />
<br />
<source lang="rsplus"><br />
initGRASS(home = tempdir(), <br />
SG = x, <br />
override = TRUE)<br />
</source><br />
<br />
After that, users can write raster and vector maps into GRASS with write_RAST() and write_VECT(), use GRASS GIS modules over those data with execGRASS() and export the results back to R with read_RAST() and read_VECT() as exemplified above.<br />
<br />
=== Existing location ===<br />
<br />
In the case of existing locations, users will provide the path to them as shown before and read data from GRASS database into R<br />
through read_RAST() and read_VECT(), do their analyses or modeling in R and potentially write results back into GRASS with write_RAST() and write_VECT().<br />
<br />
== R in GRASS in batch mode ==<br />
<br />
Run the following script with<br />
<br />
<source lang="bash"><br />
R CMD BATCH batch.R<br />
</source><br />
<br />
<source lang="rsplus"><br />
library(rgrass)<br />
# initialisation of GRASS in the North Carolina sample dataset (example with a compiled version)<br />
initGRASS(gisBase = "/home/veroandreo/software/grass/dist.x86_64-pc-linux-gnu", <br />
home = tempdir(), <br />
gisDbase = "/home/veroandreo/grassdata/",<br />
location = "nc_spm_08_grass7", mapset = "user1", SG="elevation",<br />
override = TRUE)<br />
# set region to default<br />
system("g.region -dp")<br />
# verify<br />
gmeta()<br />
# read data into R<br />
ncdata <- read_RAST(c("geology_30m", "elevation"), cat=c(TRUE, FALSE))<br />
# summary of geology map<br />
summary(ncdata$geology_30m)<br />
proc.time()<br />
</source><br />
<br />
The result is (shorted here):<br />
<source lang="bash"><br />
cat batch.Rout<br />
</source> <br />
<br />
<source lang="rsplus"><br />
R version 4.0.2 (2020-06-22) -- "Taking Off Again"<br />
Copyright (C) 2020 The R Foundation for Statistical Computing<br />
Platform: x86_64-redhat-linux-gnu (64-bit)<br />
...<br />
> library(rgrass)<br />
Loading required package: XML<br />
GRASS GIS interface loaded with GRASS version: (GRASS not running)<br />
> # initialisation and the use of north carolina dataset<br />
> initGRASS(gisBase = "/home/veroandreo/software/grass/dist.x86_64-pc-linux-gnu", home = tempdir(), <br />
+ gisDbase = "/home/veroandreo/grassdata/",<br />
+ location = "nc_spm_08_grass7", mapset = "user1", SG="elevation",<br />
+ override = TRUE)<br />
gisdbase /home/veroandreo/grassdata/ <br />
location nc_spm_08_grass7 <br />
mapset user1 <br />
rows 13500 <br />
columns 15000 <br />
north 228500 <br />
south 215000 <br />
west 630000 <br />
east 645000 <br />
nsres 1 <br />
ewres 1 <br />
projection +proj=lcc +lat_1=36.16666666666666 +lat_2=34.33333333333334<br />
+lat_0=33.75 +lon_0=-79 +x_0=609601.22 +y_0=0 +no_defs +a=6378137<br />
+rf=298.257222101 +towgs84=0.000,0.000,0.000 +type=crs +to_meter=1 <br />
<br />
> system("g.region -dp")<br />
projection: 99 (Lambert Conformal Conic)<br />
zone: 0<br />
datum: nad83<br />
ellipsoid: a=6378137 es=0.006694380022900787<br />
north: 320000<br />
south: 10000<br />
west: 120000<br />
east: 935000<br />
nsres: 500<br />
ewres: 500<br />
rows: 620<br />
cols: 1630<br />
cells: 1010600<br />
> gmeta()<br />
gisdbase /home/veroandreo/grassdata/ <br />
location nc_spm_08_grass7 <br />
mapset user1 <br />
rows 620 <br />
columns 1630 <br />
north 320000 <br />
south 10000 <br />
...<br />
> ncdata <- read_RAST(c("geology_30m", "elevation"), cat=c(TRUE, FALSE))<br />
...<br />
> summary(ncdata$geology_30m)<br />
CZfg_217 CZlg_262 CZig_270 CZbg_405 CZve_583 CZam_720 CZg_766 CZam_862 <br />
292 78 277 102 8 1 2 25 <br />
CZbg_910 Km_921 CZam_946 NA's <br />
18 5 2 1009790 <br />
> proc.time()<br />
user system elapsed <br />
8.061 2.016 10.048<br />
</source><br />
<br />
== Troubleshooting ==<br />
<br />
=== Running out of disk space ===<br />
<br />
Linux: A common issue is that /tmp/ is used for temporary files albeit being often a small partition. To change that to a larger directory, you may '''add''' to your <tt>$HOME/.bashrc</tt> the entry:<br />
<br />
<source lang="bash"><br />
# change TMP directory of R (note: of course also another directory than suggested here is fine)<br />
mkdir -p $HOME/tmp<br />
export TMP=$HOME/tmp<br />
</source><br />
<br />
The drawback of this approach is that on modern Linux systems the /tmp/ is a fast RAM disk (based on tempfs) while HOME directories are often on slower spinning disks (unless you have a SSD drive). At least you no longer run out of disk space easily.<br />
<br />
[[Category:FAQ]]<br />
[[Category:Linking to other languages]]<br />
[[Category:R]]<br />
[[Category:Statistics]]</div>Veroandreohttps://grasswiki.osgeo.org/w/index.php?title=R_statistics/rgrass&diff=26892R statistics/rgrass2023-04-21T15:16:14Z<p>Veroandreo: /* Exporting data back to GRASS */ update exaple 5</p>
<hr />
<div>== Installation ==<br />
<br />
See [[R_statistics/Installation]]<br />
<br />
== Terminology ==<br />
<br />
See "Overview" in [[R_statistics]]<br />
<br />
== R within GRASS ==<br />
<br />
In this example, we will use '''R within a GRASS GIS session''', i.e. start R (or RStudio) from the GRASS GIS terminal or command line interface.<br />
<br />
=== Startup ===<br />
<br />
* First start a GRASS GIS session. Then, at the GRASS command line start ''R'' (for an 'rstudio' session, see below)<br />
: ''In this example we will use the [https://grass.osgeo.org/download/data/#NorthCarolinaDataset North Carolina sample dataset].''<br />
<br />
Reset the region settings to the defaults<br />
<source lang="bash"><br />
GRASS (nc_spm_08_grass7):~ > g.region -d<br />
</source><br />
<br />
Launch R from the GRASS prompt<br />
<source lang="bash"><br />
GRASS (nc_spm_08_grass7):~ > R<br />
</source><br />
<br />
Load the ''rgrass'' library:<br />
<source lang="rsplus"><br />
library(rgrass)<br />
</source><br />
<br />
Get the GRASS environment (mapset, region, map projection, etc.); you can display the metadata for your location by printing G:<br />
<source lang="rsplus"><br />
gmeta()<br />
gisdbase /home/mneteler/grassdata <br />
location nc_spm_08_grass7 <br />
mapset user1 <br />
rows 620 <br />
columns 1630 <br />
north 320000 <br />
south 10000 <br />
west 120000 <br />
east 935000 <br />
nsres 500 <br />
ewres 500 <br />
projection:<br />
PROJCRS["NAD83(HARN) / North Carolina",<br />
BASEGEOGCRS["NAD83(HARN)",<br />
DATUM["NAD83 (High Accuracy Reference Network)",<br />
ELLIPSOID["GRS 1980",6378137,298.257222101,<br />
LENGTHUNIT["metre",1]]],<br />
PRIMEM["Greenwich",0,<br />
ANGLEUNIT["degree",0.0174532925199433]],<br />
ID["EPSG",4152]],<br />
CONVERSION["SPCS83 North Carolina zone (meters)",<br />
METHOD["Lambert Conic Conformal (2SP)",<br />
ID["EPSG",9802]],<br />
PARAMETER["Latitude of false origin",33.75,<br />
ANGLEUNIT["degree",0.0174532925199433],<br />
ID["EPSG",8821]],<br />
PARAMETER["Longitude of false origin",-79,<br />
ANGLEUNIT["degree",0.0174532925199433],<br />
ID["EPSG",8822]],<br />
PARAMETER["Latitude of 1st standard parallel",36.1666666666667,<br />
ANGLEUNIT["degree",0.0174532925199433],<br />
ID["EPSG",8823]],<br />
PARAMETER["Latitude of 2nd standard parallel",34.3333333333333,<br />
ANGLEUNIT["degree",0.0174532925199433],<br />
ID["EPSG",8824]],<br />
PARAMETER["Easting at false origin",609601.22,<br />
LENGTHUNIT["metre",1],<br />
ID["EPSG",8826]],<br />
PARAMETER["Northing at false origin",0,<br />
LENGTHUNIT["metre",1],<br />
ID["EPSG",8827]]],<br />
CS[Cartesian,2],<br />
AXIS["easting (X)",east,<br />
ORDER[1],<br />
LENGTHUNIT["metre",1]],<br />
AXIS["northing (Y)",north,<br />
ORDER[2],<br />
LENGTHUNIT["metre",1]],<br />
USAGE[<br />
SCOPE["Engineering survey, topographic mapping."],<br />
AREA["United States (USA) - North Carolina - counties of Alamance; Alexander; Alleghany; Anson; Ashe; Avery; Beaufort; Bertie; Bladen; Brunswick; Buncombe; Burke; Cabarrus; Caldwell; Camden; Carteret; Caswell; Catawba; Chatham; Cherokee; Chowan; Clay; Cleveland; Columbus; Craven; Cumberland; Currituck; Dare; Davidson; Davie; Duplin; Durham; Edgecombe; Forsyth; Franklin; Gaston; Gates; Graham; Granville; Greene; Guilford; Halifax; Harnett; Haywood; Henderson; Hertford; Hoke; Hyde; Iredell; Jackson; Johnston; Jones; Lee; Lenoir; Lincoln; Macon; Madison; Martin; McDowell; Mecklenburg; Mitchell; Montgomery; Moore; Nash; New Hanover; Northampton; Onslow; Orange; Pamlico; Pasquotank; Pender; Perquimans; Person; Pitt; Polk; Randolph; Richmond; Robeson; Rockingham; Rowan; Rutherford; Sampson; Scotland; Stanly; Stokes; Surry; Swain; Transylvania; Tyrrell; Union; Vance; Wake; Warren; Washington; Watauga; Wayne; Wilkes; Wilson; Yadkin; Yancey."],<br />
BBOX[33.83,-84.33,36.59,-75.38]],<br />
ID["EPSG",3358]]<br />
</source><br />
<br />
=== Listing of existing maps ===<br />
<br />
List available vector maps:<br />
<source lang="rsplus"><br />
execGRASS("g.list", parameters = list(type = "vector"))<br />
</source><br />
<br />
List selected vector maps (wildcard):<br />
<source lang="rsplus"><br />
execGRASS("g.list", parameters = list(type = "vector", pattern = "precip*"))<br />
precip<br />
precip_30ynormals<br />
precip_30ynormals_3d<br />
</source><br />
<br />
Save selected vector maps into R vector:<br />
<source lang="rsplus"><br />
my_vmaps <- execGRASS("g.list", parameters = list(type = "vector", pattern = "precip*"))<br />
attributes(my_vmaps)<br />
attributes(my_vmaps)$resOut<br />
[1] "precip" "precip_30ynormals" "precip_30ynormals_3d"<br />
</source><br />
<br />
List available raster maps:<br />
<source lang="rsplus"><br />
execGRASS("g.list", parameters = list(type = "raster"))<br />
</source><br />
<br />
List selected raster maps (wildcard):<br />
<source lang="rsplus"><br />
execGRASS("g.list", parameters = list(type = "raster", pattern = "lsat7_2002*"))<br />
lsat7_2002_10<br />
lsat7_2002_20<br />
lsat7_2002_30<br />
lsat7_2002_40<br />
lsat7_2002_50<br />
lsat7_2002_61<br />
lsat7_2002_62<br />
lsat7_2002_70<br />
lsat7_2002_80<br />
</source><br />
<br />
=== Reading data from GRASS ===<br />
<br />
==== Example 1: raster maps ====<br />
<br />
Manual page: [https://search.r-project.org/CRAN/refmans/rgrass/html/readRAST.html read_RAST()]<br />
<br />
Read two GRASS raster maps, "geology_30m" and "elevation", from the North Carolina sample data location into the R current session as a new object "ncdata". This object is a SpatRaster layer from terra package:<br />
<source lang="rsplus"><br />
ncdata <- read_RAST(c("geology_30m", "elevation"))<br />
</source><br />
<br />
We can verify the new R object:<br />
<source lang="rsplus"><br />
ncdata<br />
class : SpatRaster <br />
dimensions : 450, 500, 2 (nrow, ncol, nlyr)<br />
resolution : 30, 30 (x, y)<br />
extent : 630000, 645000, 215000, 228500 (xmin, xmax, ymin, ymax)<br />
coord. ref. : +proj=lcc +lat_0=33.75 +lon_0=-79 +lat_1=36.1666666666667 +lat_2=34.3333333333333 +x_0=609601.22 +y_0=0 +ellps=GRS80 +units=m +no_defs <br />
sources : file1da12a752d65.grd <br />
file1da12112d9ea4.grd <br />
names : geology_30m, elevation <br />
min values : 217, 55.92321 <br />
max values : 948, 156.25197<br />
</source><br />
<br />
Now, let's plot one of the raster layers within the SpatRaster object. We'll load terra library to have all functionality available:<br />
<source lang="rsplus"><br />
library(terra)<br />
plot(ncdata$elevation, main="North Carolina elevation")<br />
</source><br />
<br />
[[Image:ncdata.png|center]]<br />
<br />
In addition, we can show what is going on inside the objects read into R:<br />
<source lang="rsplus"><br />
summary(ncdata)<br />
geology_30m elevation <br />
Min. :217.0 Min. : 56.01 <br />
1st Qu.:217.0 1st Qu.: 94.77 <br />
Median :270.0 Median :108.86 <br />
Mean :311.2 Mean :110.36 <br />
3rd Qu.:270.0 3rd Qu.:126.80 <br />
Max. :948.0 Max. :156.07 <br />
</source><br />
<br />
==== Example 2: single raster map ====<br />
<br />
Here an example to transfer a single raster map from GRASS GIS to R:<br />
<br />
<source lang="rsplus"><br />
library(rgrass)<br />
library(terra)<br />
execGRASS("g.region", raster = "elevation", flags = "p")<br />
ncdata <- read_RAST("elevation")<br />
summary(ncdata)<br />
plot(ncdata)<br />
</source><br />
<br />
==== Example 3: vector maps ====<br />
<br />
Here an example to transfer a single vector map from GRASS GIS to R. In this case, vector maps from GRASS will be converted into SpatVector objects from the terra package in R:<br />
<br />
<source lang="rsplus"><br />
# needed prerequisite<br />
library(rgrass)<br />
library(terra)<br />
execGRASS("v.info", map="schools_wake", layer="1")<br />
vInfo("schools_wake")<br />
myschools <- read_VECT("schools_wake")<br />
print(summary(myschools))<br />
plot(myschools)<br />
</source><br />
<br />
==== Example 4: Summarizing data ====<br />
<br />
We can create a table of cell counts:<br />
<source lang="rsplus"><br />
freq(ncdata$geology_30m)<br />
</source><br />
<pre><br />
layer value count<br />
1 1 217 80618<br />
2 1 262 22076<br />
3 1 270 76597<br />
4 1 405 28190<br />
5 1 583 2401<br />
6 1 720 536<br />
7 1 766 786<br />
8 1 862 6858<br />
9 1 910 4996<br />
10 1 921 1392<br />
11 1 945 1<br />
12 1 946 452<br />
13 1 948 97<br />
</pre><br />
<br />
And compare with the equivalent GRASS module:<br />
<source lang="rsplus"><br />
execGRASS("r.stats", flags=c("c", "l"), parameters=list(input="geology_30m"), ignore.stderr=TRUE)<br />
</source><br />
<pre><br />
217 CZfg 80618<br />
262 CZlg 22076<br />
270 CZig 76597<br />
405 CZbg 28190<br />
583 CZve 2401<br />
720 CZam 536<br />
766 CZg 786<br />
862 CZam 6858<br />
910 CZbg 4996<br />
921 Km 1392<br />
945 CZbg 1<br />
946 CZam 452<br />
948 CZam 97<br />
</pre><br />
<br />
<!--- it does no work with terra<br />
Create a box plot of geologic types at different elevations:<br />
<source lang="rsplus"><br />
boxplot(ncdata$elevation ~ ncdata$geology_30m, medlwd = 1)<br />
</source><br />
<br />
[[Image:boxplot_geo.png|center]]<br />
---><br />
<br />
==== Example 5: Querying maps ====<br />
<br />
Sometimes you may want to query GRASS GIS maps from your R session. As an example, here the transfer of raster pixel values at the position of vector points:<br />
<br />
<source lang="rsplus"><br />
# set the computational region to the raster map:<br />
execGRASS("g.region", raster = "elev_state_500m", flags = "p")<br />
<br />
# query raster map at vector points, transfer result into R<br />
goutput <- execGRASS("r.what", map="elev_state_500m", points="geodetic_pts", separator=",", intern=TRUE)<br />
str(goutput)<br />
chr [1:29939] "571530.81289275,265739.968425953,,187.8082200648" ...<br />
<br />
# parse it<br />
con <- textConnection(goutput)<br />
go1 <- read.csv(con, header=FALSE)<br />
str(go1)<br />
'data.frame': 29939 obs. of 4 variables:<br />
$ V1: num 571531 571359 571976 572391 573011 ...<br />
$ V2: num 265740 265987 267049 267513 269615 ...<br />
$ V3: logi NA NA NA NA NA NA ...<br />
$ V4: Factor w/ 22738 levels "-0.0048115728",..: 6859 6642 6749 6411 6356 6904 7506 7224 6908 7167 ...<br />
summary(go1)<br />
V1 V2 V3 V4 <br />
Min. :121862 Min. : 7991 Mode:logical 0 : 723 <br />
1st Qu.:462706 1st Qu.:162508 NA's:29939 * : 293 <br />
Median :610328 Median :204502 0.3048 : 47 <br />
Mean :588514 Mean :200038 0.6096 : 44 <br />
3rd Qu.:717610 3rd Qu.:247633 1.524 : 42 <br />
Max. :946743 Max. :327186 0.9144 : 23 <br />
(Other):28767 <br />
</source><br />
<br />
=== Exporting data back to GRASS ===<br />
<br />
Finally, a SpatialGridDataFrame object is written back to a GRASS raster map:<br />
<br />
First prepare some data: (square root of elevation)<br />
<source lang="rsplus"><br />
ncdata$sqdem <- sqrt(ncdata$elevation)<br />
</source><br />
<br />
Export data from ''R'' back into a GRASS raster map:<br />
<source lang="rsplus"><br />
write_RAST(ncdata$sqdem, "sqdemNC", flags = c("o","overwrite"))<br />
</source><br />
<br />
Check that it imported properly:<br />
<source lang="rsplus"><br />
execGRASS("r.info", parameters=list(map="sqdemNC"))<br />
</source><br />
<br />
<pre><br />
+----------------------------------------------------------------------------+<br />
| Map: sqdemNC Date: Fri Apr 21 17:14:05 2023 |<br />
| Mapset: PERMANENT Login of Creator: veroandreo |<br />
| Location: nc_spm_08_grass7 |<br />
| DataBase: /home/veroandreo/grassdata |<br />
| Title: |<br />
| Timestamp: none |<br />
|----------------------------------------------------------------------------|<br />
| |<br />
| Type of Map: raster Number of Categories: 0 |<br />
| Data Type: FCELL Semantic label: (none) |<br />
| Rows: 450 |<br />
| Columns: 500 |<br />
| Total Cells: 225000 |<br />
| Projection: Lambert Conformal Conic |<br />
| N: 228500 S: 215000 Res: 30 |<br />
| E: 645000 W: 630000 Res: 30 |<br />
| Range of data: min = 7.478182 max = 12.50008 |<br />
| |<br />
| Data Description: |<br />
| generated by r.in.gdal |<br />
| |<br />
| Comments: |<br />
| r.in.gdal --overwrite -o input="/home/veroandreo/tmp/grass8-veroandr\ |<br />
| eo-120898/RtmpPcRHkF/file1da12dbc5b5d.grd" output="sqdemNC" memory=3\ |<br />
| 00 offset=0 num_digits=0 |<br />
| |<br />
+----------------------------------------------------------------------------+<br />
</pre><br />
<br />
=== Using RStudio in a GRASS GIS session ===<br />
<br />
If you are most used to run R through RStudio, but still want to have all GRASS data available for performing<br />
any analyses without loosing the possibility of still using GRASS command line, you can run:<br />
<br />
<source lang="bash"><br />
GRASS> rstudio &<br />
</source><br />
<br />
or, if you already are working on a certain RStudio project:<br />
<br />
<source lang="bash"><br />
GRASS> rstudio /path/to/project/folder/ &<br />
</source><br />
<br />
Then, you load rgrass library in your RStudio project<br />
<source lang="rsplus"><br />
library(rgrass)<br />
</source><br />
<br />
and you are ready to go.<br />
<br />
[[File:Grass7_rstudio.png|thumb|500px|center|RStudio used in GRASS GIS session]]<br />
<br />
== GRASS within R ==<br />
<br />
Using '''GRASS GIS within a R session''', i.e. you connect to a GRASS GIS location/mapset from within R (or RStudio).<br />
<br />
=== Startup ===<br />
<br />
In the first place, find out the path to the GRASS GIS library. This can be easily done with the following command (still outside of R; or through a system() call inside of R):<br />
<br />
<source lang="bash"><br />
# OSGeo4W, Linux, Mac OSX users:<br />
grass --config path<br />
</source><br />
<br />
It may report something like:<br />
<source lang="bash"><br />
# OSGeo4W users:<br />
C:\OSGeo4W64\apps\grass\grass<br />
<br />
# Linux, Mac OSX users:<br />
/usr/local/grass<br />
</source><br />
<br />
To call GRASS GIS functionality from R, start R and use the initGRASS() function to define the GRASS settings. If GRASS GIS was <br />
installed through OSGeo4W, first start the OSGeo4W Shell. Note that it may start in C: or a directory where the user does not have<br />
writing permission. Before calling R or RStudio, first change to a directory where you are sure you have writing permission.<br />
<br />
<source lang="rsplus"><br />
## MS-Windows users (example for an OSGeo4W 64bit installation)<br />
# change to a directory with writing permission<br />
C:\>d:<br />
D:\>cd temp<br />
D:\temp>cd testR<br />
<br />
# start R within this directory:<br />
D:\temp\testR>R<br />
<br />
# to start RStudio from OSGeo4W Shell, run: "C:/Program Files/RStudio/bin/rstudio.exe"<br />
<br />
# load rgrass package<br />
library(rgrass)<br />
<br />
# initialisation of GRASS in the North Carolina sample dataset<br />
initGRASS(gisBase = "C:/OSGeo4W64/apps/grass/grass",<br />
gisDbase = "C:/Users/marissa/grassdata/",<br />
location = "nc_spm_08_grass7", <br />
mapset = "user1", <br />
SG="elevation")<br />
</source><br />
<br />
Linux and Mac OSX users just need to start R or RStudio the usual way, load the rgrass package and initialize GRASS GIS with initGRASS() as shown below:<br />
<br />
<source lang="rsplus"><br />
# load rgrass package<br />
library(rgrass)<br />
# initialisation of GRASS in the North Carolina sample dataset<br />
initGRASS(gisBase = "/usr/local/grass", <br />
home = tempdir(), <br />
gisDbase = "/home/veroandreo/grassdata/",<br />
location = "nc_spm_08_grass7", <br />
mapset = "user1", <br />
SG="elevation")<br />
</source><br />
<br />
Note: the optional SG parameter is a 'SpatialGrid' object to define the ‘DEFAULT_WIND’ of the temporary location.<br />
<br />
<source lang="rsplus"><br />
# set computational region to default (optional)<br />
system("g.region -dp")<br />
# verify metadata<br />
gmeta()<br />
<br />
# get two raster maps into R space<br />
ncdata <- read_RAST(c("geology_30m", "elevation"), cat=c(TRUE, FALSE))<br />
<br />
# calculate object summaries<br />
summary(ncdata$geology_30m)<br />
CZfg_217 CZlg_262 CZig_270 CZbg_405 CZve_583 CZam_720 CZg_766 CZam_862 <br />
292 78 277 102 8 1 2 25 <br />
CZbg_910 Km_921 CZam_946 NA's <br />
18 5 2 1009790 <br />
</source><br />
<br />
== R in GRASS in batch mode ==<br />
<br />
Run the following script with<br />
<br />
<source lang="bash"><br />
R CMD BATCH batch.R<br />
</source><br />
<br />
<source lang="rsplus"><br />
library(rgrass)<br />
# initialisation of GRASS in the North Carolina sample dataset (example with a compiled version)<br />
initGRASS(gisBase = "/home/veroandreo/software/grass/dist.x86_64-pc-linux-gnu", <br />
home = tempdir(), <br />
gisDbase = "/home/veroandreo/grassdata/",<br />
location = "nc_spm_08_grass7", mapset = "user1", SG="elevation",<br />
override = TRUE)<br />
# set region to default<br />
system("g.region -dp")<br />
# verify<br />
gmeta()<br />
# read data into R<br />
ncdata <- read_RAST(c("geology_30m", "elevation"), cat=c(TRUE, FALSE))<br />
# summary of geology map<br />
summary(ncdata$geology_30m)<br />
proc.time()<br />
</source><br />
<br />
The result is (shorted here):<br />
<source lang="bash"><br />
cat batch.Rout<br />
</source> <br />
<br />
<source lang="rsplus"><br />
R version 4.0.2 (2020-06-22) -- "Taking Off Again"<br />
Copyright (C) 2020 The R Foundation for Statistical Computing<br />
Platform: x86_64-redhat-linux-gnu (64-bit)<br />
...<br />
> library(rgrass)<br />
Loading required package: XML<br />
GRASS GIS interface loaded with GRASS version: (GRASS not running)<br />
> # initialisation and the use of north carolina dataset<br />
> initGRASS(gisBase = "/home/veroandreo/software/grass/dist.x86_64-pc-linux-gnu", home = tempdir(), <br />
+ gisDbase = "/home/veroandreo/grassdata/",<br />
+ location = "nc_spm_08_grass7", mapset = "user1", SG="elevation",<br />
+ override = TRUE)<br />
gisdbase /home/veroandreo/grassdata/ <br />
location nc_spm_08_grass7 <br />
mapset user1 <br />
rows 13500 <br />
columns 15000 <br />
north 228500 <br />
south 215000 <br />
west 630000 <br />
east 645000 <br />
nsres 1 <br />
ewres 1 <br />
projection +proj=lcc +lat_1=36.16666666666666 +lat_2=34.33333333333334<br />
+lat_0=33.75 +lon_0=-79 +x_0=609601.22 +y_0=0 +no_defs +a=6378137<br />
+rf=298.257222101 +towgs84=0.000,0.000,0.000 +type=crs +to_meter=1 <br />
<br />
> system("g.region -dp")<br />
projection: 99 (Lambert Conformal Conic)<br />
zone: 0<br />
datum: nad83<br />
ellipsoid: a=6378137 es=0.006694380022900787<br />
north: 320000<br />
south: 10000<br />
west: 120000<br />
east: 935000<br />
nsres: 500<br />
ewres: 500<br />
rows: 620<br />
cols: 1630<br />
cells: 1010600<br />
> gmeta()<br />
gisdbase /home/veroandreo/grassdata/ <br />
location nc_spm_08_grass7 <br />
mapset user1 <br />
rows 620 <br />
columns 1630 <br />
north 320000 <br />
south 10000 <br />
...<br />
> ncdata <- read_RAST(c("geology_30m", "elevation"), cat=c(TRUE, FALSE))<br />
...<br />
> summary(ncdata$geology_30m)<br />
CZfg_217 CZlg_262 CZig_270 CZbg_405 CZve_583 CZam_720 CZg_766 CZam_862 <br />
292 78 277 102 8 1 2 25 <br />
CZbg_910 Km_921 CZam_946 NA's <br />
18 5 2 1009790 <br />
> proc.time()<br />
user system elapsed <br />
8.061 2.016 10.048<br />
</source><br />
<br />
== Troubleshooting ==<br />
<br />
=== Running out of disk space ===<br />
<br />
Linux: A common issue is that /tmp/ is used for temporary files albeit being often a small partition. To change that to a larger directory, you may '''add''' to your <tt>$HOME/.bashrc</tt> the entry:<br />
<br />
<source lang="bash"><br />
# change TMP directory of R (note: of course also another directory than suggested here is fine)<br />
mkdir -p $HOME/tmp<br />
export TMP=$HOME/tmp<br />
</source><br />
<br />
The drawback of this approach is that on modern Linux systems the /tmp/ is a fast RAM disk (based on tempfs) while HOME directories are often on slower spinning disks (unless you have a SSD drive). At least you no longer run out of disk space easily.<br />
<br />
[[Category:FAQ]]<br />
[[Category:Linking to other languages]]<br />
[[Category:R]]<br />
[[Category:Statistics]]</div>Veroandreohttps://grasswiki.osgeo.org/w/index.php?title=R_statistics/rgrass&diff=26891R statistics/rgrass2023-04-21T15:05:33Z<p>Veroandreo: /* Example 5: Querying maps */ edit example level</p>
<hr />
<div>== Installation ==<br />
<br />
See [[R_statistics/Installation]]<br />
<br />
== Terminology ==<br />
<br />
See "Overview" in [[R_statistics]]<br />
<br />
== R within GRASS ==<br />
<br />
In this example, we will use '''R within a GRASS GIS session''', i.e. start R (or RStudio) from the GRASS GIS terminal or command line interface.<br />
<br />
=== Startup ===<br />
<br />
* First start a GRASS GIS session. Then, at the GRASS command line start ''R'' (for an 'rstudio' session, see below)<br />
: ''In this example we will use the [https://grass.osgeo.org/download/data/#NorthCarolinaDataset North Carolina sample dataset].''<br />
<br />
Reset the region settings to the defaults<br />
<source lang="bash"><br />
GRASS (nc_spm_08_grass7):~ > g.region -d<br />
</source><br />
<br />
Launch R from the GRASS prompt<br />
<source lang="bash"><br />
GRASS (nc_spm_08_grass7):~ > R<br />
</source><br />
<br />
Load the ''rgrass'' library:<br />
<source lang="rsplus"><br />
library(rgrass)<br />
</source><br />
<br />
Get the GRASS environment (mapset, region, map projection, etc.); you can display the metadata for your location by printing G:<br />
<source lang="rsplus"><br />
gmeta()<br />
gisdbase /home/mneteler/grassdata <br />
location nc_spm_08_grass7 <br />
mapset user1 <br />
rows 620 <br />
columns 1630 <br />
north 320000 <br />
south 10000 <br />
west 120000 <br />
east 935000 <br />
nsres 500 <br />
ewres 500 <br />
projection:<br />
PROJCRS["NAD83(HARN) / North Carolina",<br />
BASEGEOGCRS["NAD83(HARN)",<br />
DATUM["NAD83 (High Accuracy Reference Network)",<br />
ELLIPSOID["GRS 1980",6378137,298.257222101,<br />
LENGTHUNIT["metre",1]]],<br />
PRIMEM["Greenwich",0,<br />
ANGLEUNIT["degree",0.0174532925199433]],<br />
ID["EPSG",4152]],<br />
CONVERSION["SPCS83 North Carolina zone (meters)",<br />
METHOD["Lambert Conic Conformal (2SP)",<br />
ID["EPSG",9802]],<br />
PARAMETER["Latitude of false origin",33.75,<br />
ANGLEUNIT["degree",0.0174532925199433],<br />
ID["EPSG",8821]],<br />
PARAMETER["Longitude of false origin",-79,<br />
ANGLEUNIT["degree",0.0174532925199433],<br />
ID["EPSG",8822]],<br />
PARAMETER["Latitude of 1st standard parallel",36.1666666666667,<br />
ANGLEUNIT["degree",0.0174532925199433],<br />
ID["EPSG",8823]],<br />
PARAMETER["Latitude of 2nd standard parallel",34.3333333333333,<br />
ANGLEUNIT["degree",0.0174532925199433],<br />
ID["EPSG",8824]],<br />
PARAMETER["Easting at false origin",609601.22,<br />
LENGTHUNIT["metre",1],<br />
ID["EPSG",8826]],<br />
PARAMETER["Northing at false origin",0,<br />
LENGTHUNIT["metre",1],<br />
ID["EPSG",8827]]],<br />
CS[Cartesian,2],<br />
AXIS["easting (X)",east,<br />
ORDER[1],<br />
LENGTHUNIT["metre",1]],<br />
AXIS["northing (Y)",north,<br />
ORDER[2],<br />
LENGTHUNIT["metre",1]],<br />
USAGE[<br />
SCOPE["Engineering survey, topographic mapping."],<br />
AREA["United States (USA) - North Carolina - counties of Alamance; Alexander; Alleghany; Anson; Ashe; Avery; Beaufort; Bertie; Bladen; Brunswick; Buncombe; Burke; Cabarrus; Caldwell; Camden; Carteret; Caswell; Catawba; Chatham; Cherokee; Chowan; Clay; Cleveland; Columbus; Craven; Cumberland; Currituck; Dare; Davidson; Davie; Duplin; Durham; Edgecombe; Forsyth; Franklin; Gaston; Gates; Graham; Granville; Greene; Guilford; Halifax; Harnett; Haywood; Henderson; Hertford; Hoke; Hyde; Iredell; Jackson; Johnston; Jones; Lee; Lenoir; Lincoln; Macon; Madison; Martin; McDowell; Mecklenburg; Mitchell; Montgomery; Moore; Nash; New Hanover; Northampton; Onslow; Orange; Pamlico; Pasquotank; Pender; Perquimans; Person; Pitt; Polk; Randolph; Richmond; Robeson; Rockingham; Rowan; Rutherford; Sampson; Scotland; Stanly; Stokes; Surry; Swain; Transylvania; Tyrrell; Union; Vance; Wake; Warren; Washington; Watauga; Wayne; Wilkes; Wilson; Yadkin; Yancey."],<br />
BBOX[33.83,-84.33,36.59,-75.38]],<br />
ID["EPSG",3358]]<br />
</source><br />
<br />
=== Listing of existing maps ===<br />
<br />
List available vector maps:<br />
<source lang="rsplus"><br />
execGRASS("g.list", parameters = list(type = "vector"))<br />
</source><br />
<br />
List selected vector maps (wildcard):<br />
<source lang="rsplus"><br />
execGRASS("g.list", parameters = list(type = "vector", pattern = "precip*"))<br />
precip<br />
precip_30ynormals<br />
precip_30ynormals_3d<br />
</source><br />
<br />
Save selected vector maps into R vector:<br />
<source lang="rsplus"><br />
my_vmaps <- execGRASS("g.list", parameters = list(type = "vector", pattern = "precip*"))<br />
attributes(my_vmaps)<br />
attributes(my_vmaps)$resOut<br />
[1] "precip" "precip_30ynormals" "precip_30ynormals_3d"<br />
</source><br />
<br />
List available raster maps:<br />
<source lang="rsplus"><br />
execGRASS("g.list", parameters = list(type = "raster"))<br />
</source><br />
<br />
List selected raster maps (wildcard):<br />
<source lang="rsplus"><br />
execGRASS("g.list", parameters = list(type = "raster", pattern = "lsat7_2002*"))<br />
lsat7_2002_10<br />
lsat7_2002_20<br />
lsat7_2002_30<br />
lsat7_2002_40<br />
lsat7_2002_50<br />
lsat7_2002_61<br />
lsat7_2002_62<br />
lsat7_2002_70<br />
lsat7_2002_80<br />
</source><br />
<br />
=== Reading data from GRASS ===<br />
<br />
==== Example 1: raster maps ====<br />
<br />
Manual page: [https://search.r-project.org/CRAN/refmans/rgrass/html/readRAST.html read_RAST()]<br />
<br />
Read two GRASS raster maps, "geology_30m" and "elevation", from the North Carolina sample data location into the R current session as a new object "ncdata". This object is a SpatRaster layer from terra package:<br />
<source lang="rsplus"><br />
ncdata <- read_RAST(c("geology_30m", "elevation"))<br />
</source><br />
<br />
We can verify the new R object:<br />
<source lang="rsplus"><br />
ncdata<br />
class : SpatRaster <br />
dimensions : 450, 500, 2 (nrow, ncol, nlyr)<br />
resolution : 30, 30 (x, y)<br />
extent : 630000, 645000, 215000, 228500 (xmin, xmax, ymin, ymax)<br />
coord. ref. : +proj=lcc +lat_0=33.75 +lon_0=-79 +lat_1=36.1666666666667 +lat_2=34.3333333333333 +x_0=609601.22 +y_0=0 +ellps=GRS80 +units=m +no_defs <br />
sources : file1da12a752d65.grd <br />
file1da12112d9ea4.grd <br />
names : geology_30m, elevation <br />
min values : 217, 55.92321 <br />
max values : 948, 156.25197<br />
</source><br />
<br />
Now, let's plot one of the raster layers within the SpatRaster object. We'll load terra library to have all functionality available:<br />
<source lang="rsplus"><br />
library(terra)<br />
plot(ncdata$elevation, main="North Carolina elevation")<br />
</source><br />
<br />
[[Image:ncdata.png|center]]<br />
<br />
In addition, we can show what is going on inside the objects read into R:<br />
<source lang="rsplus"><br />
summary(ncdata)<br />
geology_30m elevation <br />
Min. :217.0 Min. : 56.01 <br />
1st Qu.:217.0 1st Qu.: 94.77 <br />
Median :270.0 Median :108.86 <br />
Mean :311.2 Mean :110.36 <br />
3rd Qu.:270.0 3rd Qu.:126.80 <br />
Max. :948.0 Max. :156.07 <br />
</source><br />
<br />
==== Example 2: single raster map ====<br />
<br />
Here an example to transfer a single raster map from GRASS GIS to R:<br />
<br />
<source lang="rsplus"><br />
library(rgrass)<br />
library(terra)<br />
execGRASS("g.region", raster = "elevation", flags = "p")<br />
ncdata <- read_RAST("elevation")<br />
summary(ncdata)<br />
plot(ncdata)<br />
</source><br />
<br />
==== Example 3: vector maps ====<br />
<br />
Here an example to transfer a single vector map from GRASS GIS to R. In this case, vector maps from GRASS will be converted into SpatVector objects from the terra package in R:<br />
<br />
<source lang="rsplus"><br />
# needed prerequisite<br />
library(rgrass)<br />
library(terra)<br />
execGRASS("v.info", map="schools_wake", layer="1")<br />
vInfo("schools_wake")<br />
myschools <- read_VECT("schools_wake")<br />
print(summary(myschools))<br />
plot(myschools)<br />
</source><br />
<br />
==== Example 4: Summarizing data ====<br />
<br />
We can create a table of cell counts:<br />
<source lang="rsplus"><br />
freq(ncdata$geology_30m)<br />
</source><br />
<pre><br />
layer value count<br />
1 1 217 80618<br />
2 1 262 22076<br />
3 1 270 76597<br />
4 1 405 28190<br />
5 1 583 2401<br />
6 1 720 536<br />
7 1 766 786<br />
8 1 862 6858<br />
9 1 910 4996<br />
10 1 921 1392<br />
11 1 945 1<br />
12 1 946 452<br />
13 1 948 97<br />
</pre><br />
<br />
And compare with the equivalent GRASS module:<br />
<source lang="rsplus"><br />
execGRASS("r.stats", flags=c("c", "l"), parameters=list(input="geology_30m"), ignore.stderr=TRUE)<br />
</source><br />
<pre><br />
217 CZfg 80618<br />
262 CZlg 22076<br />
270 CZig 76597<br />
405 CZbg 28190<br />
583 CZve 2401<br />
720 CZam 536<br />
766 CZg 786<br />
862 CZam 6858<br />
910 CZbg 4996<br />
921 Km 1392<br />
945 CZbg 1<br />
946 CZam 452<br />
948 CZam 97<br />
</pre><br />
<br />
<!--- it does no work with terra<br />
Create a box plot of geologic types at different elevations:<br />
<source lang="rsplus"><br />
boxplot(ncdata$elevation ~ ncdata$geology_30m, medlwd = 1)<br />
</source><br />
<br />
[[Image:boxplot_geo.png|center]]<br />
---><br />
<br />
==== Example 5: Querying maps ====<br />
<br />
Sometimes you may want to query GRASS GIS maps from your R session. As an example, here the transfer of raster pixel values at the position of vector points:<br />
<br />
<source lang="rsplus"><br />
# set the computational region to the raster map:<br />
execGRASS("g.region", raster = "elev_state_500m", flags = "p")<br />
<br />
# query raster map at vector points, transfer result into R<br />
goutput <- execGRASS("r.what", map="elev_state_500m", points="geodetic_pts", separator=",", intern=TRUE)<br />
str(goutput)<br />
chr [1:29939] "571530.81289275,265739.968425953,,187.8082200648" ...<br />
<br />
# parse it<br />
con <- textConnection(goutput)<br />
go1 <- read.csv(con, header=FALSE)<br />
str(go1)<br />
'data.frame': 29939 obs. of 4 variables:<br />
$ V1: num 571531 571359 571976 572391 573011 ...<br />
$ V2: num 265740 265987 267049 267513 269615 ...<br />
$ V3: logi NA NA NA NA NA NA ...<br />
$ V4: Factor w/ 22738 levels "-0.0048115728",..: 6859 6642 6749 6411 6356 6904 7506 7224 6908 7167 ...<br />
summary(go1)<br />
V1 V2 V3 V4 <br />
Min. :121862 Min. : 7991 Mode:logical 0 : 723 <br />
1st Qu.:462706 1st Qu.:162508 NA's:29939 * : 293 <br />
Median :610328 Median :204502 0.3048 : 47 <br />
Mean :588514 Mean :200038 0.6096 : 44 <br />
3rd Qu.:717610 3rd Qu.:247633 1.524 : 42 <br />
Max. :946743 Max. :327186 0.9144 : 23 <br />
(Other):28767 <br />
</source><br />
<br />
=== Exporting data back to GRASS ===<br />
<br />
Finally, a SpatialGridDataFrame object is written back to a GRASS raster map:<br />
<br />
First prepare some data: (square root of elevation)<br />
<source lang="rsplus"><br />
ncdata$sqdem <- sqrt(ncdata$elevation)<br />
</source><br />
<br />
Export data from ''R'' back into a GRASS raster map:<br />
<source lang="rsplus"><br />
writeRAST(ncdata, "sqdemNC", zcol="sqdem", ignore.stderr=TRUE)<br />
</source><br />
<br />
Check that it imported into GRASS ok:<br />
<source lang="rsplus"><br />
execGRASS("r.info", parameters=list(map="sqdemNC"))<br />
</source><br />
<br />
<pre><br />
+----------------------------------------------------------------------------+<br />
| Map: sqdemNC Date: Sun Jul 19 13:06:34 2015 |<br />
| Mapset: PERMANENT Login of Creator: veroandreo |<br />
| Location: nc_spm_08_grass7 |<br />
| DataBase: /home/veroandreo/grassdata |<br />
| Title: ( sqdemNC ) |<br />
| Timestamp: none |<br />
|----------------------------------------------------------------------------|<br />
| |<br />
| Type of Map: raster Number of Categories: 0 |<br />
| Data Type: DCELL |<br />
| Rows: 491 |<br />
| Columns: 400 |<br />
| Total Cells: 196400 |<br />
| Projection: Lambert Conformal Conic |<br />
| N: 228500 S: 215000.0002 Res: 27.49490794 |<br />
| E: 645000 W: 630000 Res: 37.5 |<br />
| Range of data: min = 7.47818253045085 max = 12.5000787351036 |<br />
| |<br />
| Data Description: |<br />
| generated by r.in.bin |<br />
| |<br />
| Comments: |<br />
| |<br />
+----------------------------------------------------------------------------+<br />
</pre><br />
<br />
=== Using RStudio in a GRASS GIS session ===<br />
<br />
If you are most used to run R through RStudio, but still want to have all GRASS data available for performing<br />
any analyses without loosing the possibility of still using GRASS command line, you can run:<br />
<br />
<source lang="bash"><br />
GRASS> rstudio &<br />
</source><br />
<br />
or, if you already are working on a certain RStudio project:<br />
<br />
<source lang="bash"><br />
GRASS> rstudio /path/to/project/folder/ &<br />
</source><br />
<br />
Then, you load rgrass library in your RStudio project<br />
<source lang="rsplus"><br />
library(rgrass)<br />
</source><br />
<br />
and you are ready to go.<br />
<br />
[[File:Grass7_rstudio.png|thumb|500px|center|RStudio used in GRASS GIS session]]<br />
<br />
== GRASS within R ==<br />
<br />
Using '''GRASS GIS within a R session''', i.e. you connect to a GRASS GIS location/mapset from within R (or RStudio).<br />
<br />
=== Startup ===<br />
<br />
In the first place, find out the path to the GRASS GIS library. This can be easily done with the following command (still outside of R; or through a system() call inside of R):<br />
<br />
<source lang="bash"><br />
# OSGeo4W, Linux, Mac OSX users:<br />
grass --config path<br />
</source><br />
<br />
It may report something like:<br />
<source lang="bash"><br />
# OSGeo4W users:<br />
C:\OSGeo4W64\apps\grass\grass<br />
<br />
# Linux, Mac OSX users:<br />
/usr/local/grass<br />
</source><br />
<br />
To call GRASS GIS functionality from R, start R and use the initGRASS() function to define the GRASS settings. If GRASS GIS was <br />
installed through OSGeo4W, first start the OSGeo4W Shell. Note that it may start in C: or a directory where the user does not have<br />
writing permission. Before calling R or RStudio, first change to a directory where you are sure you have writing permission.<br />
<br />
<source lang="rsplus"><br />
## MS-Windows users (example for an OSGeo4W 64bit installation)<br />
# change to a directory with writing permission<br />
C:\>d:<br />
D:\>cd temp<br />
D:\temp>cd testR<br />
<br />
# start R within this directory:<br />
D:\temp\testR>R<br />
<br />
# to start RStudio from OSGeo4W Shell, run: "C:/Program Files/RStudio/bin/rstudio.exe"<br />
<br />
# load rgrass package<br />
library(rgrass)<br />
<br />
# initialisation of GRASS in the North Carolina sample dataset<br />
initGRASS(gisBase = "C:/OSGeo4W64/apps/grass/grass",<br />
gisDbase = "C:/Users/marissa/grassdata/",<br />
location = "nc_spm_08_grass7", <br />
mapset = "user1", <br />
SG="elevation")<br />
</source><br />
<br />
Linux and Mac OSX users just need to start R or RStudio the usual way, load the rgrass package and initialize GRASS GIS with initGRASS() as shown below:<br />
<br />
<source lang="rsplus"><br />
# load rgrass package<br />
library(rgrass)<br />
# initialisation of GRASS in the North Carolina sample dataset<br />
initGRASS(gisBase = "/usr/local/grass", <br />
home = tempdir(), <br />
gisDbase = "/home/veroandreo/grassdata/",<br />
location = "nc_spm_08_grass7", <br />
mapset = "user1", <br />
SG="elevation")<br />
</source><br />
<br />
Note: the optional SG parameter is a 'SpatialGrid' object to define the ‘DEFAULT_WIND’ of the temporary location.<br />
<br />
<source lang="rsplus"><br />
# set computational region to default (optional)<br />
system("g.region -dp")<br />
# verify metadata<br />
gmeta()<br />
<br />
# get two raster maps into R space<br />
ncdata <- read_RAST(c("geology_30m", "elevation"), cat=c(TRUE, FALSE))<br />
<br />
# calculate object summaries<br />
summary(ncdata$geology_30m)<br />
CZfg_217 CZlg_262 CZig_270 CZbg_405 CZve_583 CZam_720 CZg_766 CZam_862 <br />
292 78 277 102 8 1 2 25 <br />
CZbg_910 Km_921 CZam_946 NA's <br />
18 5 2 1009790 <br />
</source><br />
<br />
== R in GRASS in batch mode ==<br />
<br />
Run the following script with<br />
<br />
<source lang="bash"><br />
R CMD BATCH batch.R<br />
</source><br />
<br />
<source lang="rsplus"><br />
library(rgrass)<br />
# initialisation of GRASS in the North Carolina sample dataset (example with a compiled version)<br />
initGRASS(gisBase = "/home/veroandreo/software/grass/dist.x86_64-pc-linux-gnu", <br />
home = tempdir(), <br />
gisDbase = "/home/veroandreo/grassdata/",<br />
location = "nc_spm_08_grass7", mapset = "user1", SG="elevation",<br />
override = TRUE)<br />
# set region to default<br />
system("g.region -dp")<br />
# verify<br />
gmeta()<br />
# read data into R<br />
ncdata <- read_RAST(c("geology_30m", "elevation"), cat=c(TRUE, FALSE))<br />
# summary of geology map<br />
summary(ncdata$geology_30m)<br />
proc.time()<br />
</source><br />
<br />
The result is (shorted here):<br />
<source lang="bash"><br />
cat batch.Rout<br />
</source> <br />
<br />
<source lang="rsplus"><br />
R version 4.0.2 (2020-06-22) -- "Taking Off Again"<br />
Copyright (C) 2020 The R Foundation for Statistical Computing<br />
Platform: x86_64-redhat-linux-gnu (64-bit)<br />
...<br />
> library(rgrass)<br />
Loading required package: XML<br />
GRASS GIS interface loaded with GRASS version: (GRASS not running)<br />
> # initialisation and the use of north carolina dataset<br />
> initGRASS(gisBase = "/home/veroandreo/software/grass/dist.x86_64-pc-linux-gnu", home = tempdir(), <br />
+ gisDbase = "/home/veroandreo/grassdata/",<br />
+ location = "nc_spm_08_grass7", mapset = "user1", SG="elevation",<br />
+ override = TRUE)<br />
gisdbase /home/veroandreo/grassdata/ <br />
location nc_spm_08_grass7 <br />
mapset user1 <br />
rows 13500 <br />
columns 15000 <br />
north 228500 <br />
south 215000 <br />
west 630000 <br />
east 645000 <br />
nsres 1 <br />
ewres 1 <br />
projection +proj=lcc +lat_1=36.16666666666666 +lat_2=34.33333333333334<br />
+lat_0=33.75 +lon_0=-79 +x_0=609601.22 +y_0=0 +no_defs +a=6378137<br />
+rf=298.257222101 +towgs84=0.000,0.000,0.000 +type=crs +to_meter=1 <br />
<br />
> system("g.region -dp")<br />
projection: 99 (Lambert Conformal Conic)<br />
zone: 0<br />
datum: nad83<br />
ellipsoid: a=6378137 es=0.006694380022900787<br />
north: 320000<br />
south: 10000<br />
west: 120000<br />
east: 935000<br />
nsres: 500<br />
ewres: 500<br />
rows: 620<br />
cols: 1630<br />
cells: 1010600<br />
> gmeta()<br />
gisdbase /home/veroandreo/grassdata/ <br />
location nc_spm_08_grass7 <br />
mapset user1 <br />
rows 620 <br />
columns 1630 <br />
north 320000 <br />
south 10000 <br />
...<br />
> ncdata <- read_RAST(c("geology_30m", "elevation"), cat=c(TRUE, FALSE))<br />
...<br />
> summary(ncdata$geology_30m)<br />
CZfg_217 CZlg_262 CZig_270 CZbg_405 CZve_583 CZam_720 CZg_766 CZam_862 <br />
292 78 277 102 8 1 2 25 <br />
CZbg_910 Km_921 CZam_946 NA's <br />
18 5 2 1009790 <br />
> proc.time()<br />
user system elapsed <br />
8.061 2.016 10.048<br />
</source><br />
<br />
== Troubleshooting ==<br />
<br />
=== Running out of disk space ===<br />
<br />
Linux: A common issue is that /tmp/ is used for temporary files albeit being often a small partition. To change that to a larger directory, you may '''add''' to your <tt>$HOME/.bashrc</tt> the entry:<br />
<br />
<source lang="bash"><br />
# change TMP directory of R (note: of course also another directory than suggested here is fine)<br />
mkdir -p $HOME/tmp<br />
export TMP=$HOME/tmp<br />
</source><br />
<br />
The drawback of this approach is that on modern Linux systems the /tmp/ is a fast RAM disk (based on tempfs) while HOME directories are often on slower spinning disks (unless you have a SSD drive). At least you no longer run out of disk space easily.<br />
<br />
[[Category:FAQ]]<br />
[[Category:Linking to other languages]]<br />
[[Category:R]]<br />
[[Category:Statistics]]</div>Veroandreohttps://grasswiki.osgeo.org/w/index.php?title=R_statistics/rgrass&diff=26890R statistics/rgrass2023-04-21T15:02:26Z<p>Veroandreo: /* Example 4: Summarizing data */ remove boxplot, does not work with terra objects</p>
<hr />
<div>== Installation ==<br />
<br />
See [[R_statistics/Installation]]<br />
<br />
== Terminology ==<br />
<br />
See "Overview" in [[R_statistics]]<br />
<br />
== R within GRASS ==<br />
<br />
In this example, we will use '''R within a GRASS GIS session''', i.e. start R (or RStudio) from the GRASS GIS terminal or command line interface.<br />
<br />
=== Startup ===<br />
<br />
* First start a GRASS GIS session. Then, at the GRASS command line start ''R'' (for an 'rstudio' session, see below)<br />
: ''In this example we will use the [https://grass.osgeo.org/download/data/#NorthCarolinaDataset North Carolina sample dataset].''<br />
<br />
Reset the region settings to the defaults<br />
<source lang="bash"><br />
GRASS (nc_spm_08_grass7):~ > g.region -d<br />
</source><br />
<br />
Launch R from the GRASS prompt<br />
<source lang="bash"><br />
GRASS (nc_spm_08_grass7):~ > R<br />
</source><br />
<br />
Load the ''rgrass'' library:<br />
<source lang="rsplus"><br />
library(rgrass)<br />
</source><br />
<br />
Get the GRASS environment (mapset, region, map projection, etc.); you can display the metadata for your location by printing G:<br />
<source lang="rsplus"><br />
gmeta()<br />
gisdbase /home/mneteler/grassdata <br />
location nc_spm_08_grass7 <br />
mapset user1 <br />
rows 620 <br />
columns 1630 <br />
north 320000 <br />
south 10000 <br />
west 120000 <br />
east 935000 <br />
nsres 500 <br />
ewres 500 <br />
projection:<br />
PROJCRS["NAD83(HARN) / North Carolina",<br />
BASEGEOGCRS["NAD83(HARN)",<br />
DATUM["NAD83 (High Accuracy Reference Network)",<br />
ELLIPSOID["GRS 1980",6378137,298.257222101,<br />
LENGTHUNIT["metre",1]]],<br />
PRIMEM["Greenwich",0,<br />
ANGLEUNIT["degree",0.0174532925199433]],<br />
ID["EPSG",4152]],<br />
CONVERSION["SPCS83 North Carolina zone (meters)",<br />
METHOD["Lambert Conic Conformal (2SP)",<br />
ID["EPSG",9802]],<br />
PARAMETER["Latitude of false origin",33.75,<br />
ANGLEUNIT["degree",0.0174532925199433],<br />
ID["EPSG",8821]],<br />
PARAMETER["Longitude of false origin",-79,<br />
ANGLEUNIT["degree",0.0174532925199433],<br />
ID["EPSG",8822]],<br />
PARAMETER["Latitude of 1st standard parallel",36.1666666666667,<br />
ANGLEUNIT["degree",0.0174532925199433],<br />
ID["EPSG",8823]],<br />
PARAMETER["Latitude of 2nd standard parallel",34.3333333333333,<br />
ANGLEUNIT["degree",0.0174532925199433],<br />
ID["EPSG",8824]],<br />
PARAMETER["Easting at false origin",609601.22,<br />
LENGTHUNIT["metre",1],<br />
ID["EPSG",8826]],<br />
PARAMETER["Northing at false origin",0,<br />
LENGTHUNIT["metre",1],<br />
ID["EPSG",8827]]],<br />
CS[Cartesian,2],<br />
AXIS["easting (X)",east,<br />
ORDER[1],<br />
LENGTHUNIT["metre",1]],<br />
AXIS["northing (Y)",north,<br />
ORDER[2],<br />
LENGTHUNIT["metre",1]],<br />
USAGE[<br />
SCOPE["Engineering survey, topographic mapping."],<br />
AREA["United States (USA) - North Carolina - counties of Alamance; Alexander; Alleghany; Anson; Ashe; Avery; Beaufort; Bertie; Bladen; Brunswick; Buncombe; Burke; Cabarrus; Caldwell; Camden; Carteret; Caswell; Catawba; Chatham; Cherokee; Chowan; Clay; Cleveland; Columbus; Craven; Cumberland; Currituck; Dare; Davidson; Davie; Duplin; Durham; Edgecombe; Forsyth; Franklin; Gaston; Gates; Graham; Granville; Greene; Guilford; Halifax; Harnett; Haywood; Henderson; Hertford; Hoke; Hyde; Iredell; Jackson; Johnston; Jones; Lee; Lenoir; Lincoln; Macon; Madison; Martin; McDowell; Mecklenburg; Mitchell; Montgomery; Moore; Nash; New Hanover; Northampton; Onslow; Orange; Pamlico; Pasquotank; Pender; Perquimans; Person; Pitt; Polk; Randolph; Richmond; Robeson; Rockingham; Rowan; Rutherford; Sampson; Scotland; Stanly; Stokes; Surry; Swain; Transylvania; Tyrrell; Union; Vance; Wake; Warren; Washington; Watauga; Wayne; Wilkes; Wilson; Yadkin; Yancey."],<br />
BBOX[33.83,-84.33,36.59,-75.38]],<br />
ID["EPSG",3358]]<br />
</source><br />
<br />
=== Listing of existing maps ===<br />
<br />
List available vector maps:<br />
<source lang="rsplus"><br />
execGRASS("g.list", parameters = list(type = "vector"))<br />
</source><br />
<br />
List selected vector maps (wildcard):<br />
<source lang="rsplus"><br />
execGRASS("g.list", parameters = list(type = "vector", pattern = "precip*"))<br />
precip<br />
precip_30ynormals<br />
precip_30ynormals_3d<br />
</source><br />
<br />
Save selected vector maps into R vector:<br />
<source lang="rsplus"><br />
my_vmaps <- execGRASS("g.list", parameters = list(type = "vector", pattern = "precip*"))<br />
attributes(my_vmaps)<br />
attributes(my_vmaps)$resOut<br />
[1] "precip" "precip_30ynormals" "precip_30ynormals_3d"<br />
</source><br />
<br />
List available raster maps:<br />
<source lang="rsplus"><br />
execGRASS("g.list", parameters = list(type = "raster"))<br />
</source><br />
<br />
List selected raster maps (wildcard):<br />
<source lang="rsplus"><br />
execGRASS("g.list", parameters = list(type = "raster", pattern = "lsat7_2002*"))<br />
lsat7_2002_10<br />
lsat7_2002_20<br />
lsat7_2002_30<br />
lsat7_2002_40<br />
lsat7_2002_50<br />
lsat7_2002_61<br />
lsat7_2002_62<br />
lsat7_2002_70<br />
lsat7_2002_80<br />
</source><br />
<br />
=== Reading data from GRASS ===<br />
<br />
==== Example 1: raster maps ====<br />
<br />
Manual page: [https://search.r-project.org/CRAN/refmans/rgrass/html/readRAST.html read_RAST()]<br />
<br />
Read two GRASS raster maps, "geology_30m" and "elevation", from the North Carolina sample data location into the R current session as a new object "ncdata". This object is a SpatRaster layer from terra package:<br />
<source lang="rsplus"><br />
ncdata <- read_RAST(c("geology_30m", "elevation"))<br />
</source><br />
<br />
We can verify the new R object:<br />
<source lang="rsplus"><br />
ncdata<br />
class : SpatRaster <br />
dimensions : 450, 500, 2 (nrow, ncol, nlyr)<br />
resolution : 30, 30 (x, y)<br />
extent : 630000, 645000, 215000, 228500 (xmin, xmax, ymin, ymax)<br />
coord. ref. : +proj=lcc +lat_0=33.75 +lon_0=-79 +lat_1=36.1666666666667 +lat_2=34.3333333333333 +x_0=609601.22 +y_0=0 +ellps=GRS80 +units=m +no_defs <br />
sources : file1da12a752d65.grd <br />
file1da12112d9ea4.grd <br />
names : geology_30m, elevation <br />
min values : 217, 55.92321 <br />
max values : 948, 156.25197<br />
</source><br />
<br />
Now, let's plot one of the raster layers within the SpatRaster object. We'll load terra library to have all functionality available:<br />
<source lang="rsplus"><br />
library(terra)<br />
plot(ncdata$elevation, main="North Carolina elevation")<br />
</source><br />
<br />
[[Image:ncdata.png|center]]<br />
<br />
In addition, we can show what is going on inside the objects read into R:<br />
<source lang="rsplus"><br />
summary(ncdata)<br />
geology_30m elevation <br />
Min. :217.0 Min. : 56.01 <br />
1st Qu.:217.0 1st Qu.: 94.77 <br />
Median :270.0 Median :108.86 <br />
Mean :311.2 Mean :110.36 <br />
3rd Qu.:270.0 3rd Qu.:126.80 <br />
Max. :948.0 Max. :156.07 <br />
</source><br />
<br />
==== Example 2: single raster map ====<br />
<br />
Here an example to transfer a single raster map from GRASS GIS to R:<br />
<br />
<source lang="rsplus"><br />
library(rgrass)<br />
library(terra)<br />
execGRASS("g.region", raster = "elevation", flags = "p")<br />
ncdata <- read_RAST("elevation")<br />
summary(ncdata)<br />
plot(ncdata)<br />
</source><br />
<br />
==== Example 3: vector maps ====<br />
<br />
Here an example to transfer a single vector map from GRASS GIS to R. In this case, vector maps from GRASS will be converted into SpatVector objects from the terra package in R:<br />
<br />
<source lang="rsplus"><br />
# needed prerequisite<br />
library(rgrass)<br />
library(terra)<br />
execGRASS("v.info", map="schools_wake", layer="1")<br />
vInfo("schools_wake")<br />
myschools <- read_VECT("schools_wake")<br />
print(summary(myschools))<br />
plot(myschools)<br />
</source><br />
<br />
==== Example 4: Summarizing data ====<br />
<br />
We can create a table of cell counts:<br />
<source lang="rsplus"><br />
freq(ncdata$geology_30m)<br />
</source><br />
<pre><br />
layer value count<br />
1 1 217 80618<br />
2 1 262 22076<br />
3 1 270 76597<br />
4 1 405 28190<br />
5 1 583 2401<br />
6 1 720 536<br />
7 1 766 786<br />
8 1 862 6858<br />
9 1 910 4996<br />
10 1 921 1392<br />
11 1 945 1<br />
12 1 946 452<br />
13 1 948 97<br />
</pre><br />
<br />
And compare with the equivalent GRASS module:<br />
<source lang="rsplus"><br />
execGRASS("r.stats", flags=c("c", "l"), parameters=list(input="geology_30m"), ignore.stderr=TRUE)<br />
</source><br />
<pre><br />
217 CZfg 80618<br />
262 CZlg 22076<br />
270 CZig 76597<br />
405 CZbg 28190<br />
583 CZve 2401<br />
720 CZam 536<br />
766 CZg 786<br />
862 CZam 6858<br />
910 CZbg 4996<br />
921 Km 1392<br />
945 CZbg 1<br />
946 CZam 452<br />
948 CZam 97<br />
</pre><br />
<br />
<!--- it does no work with terra<br />
Create a box plot of geologic types at different elevations:<br />
<source lang="rsplus"><br />
boxplot(ncdata$elevation ~ ncdata$geology_30m, medlwd = 1)<br />
</source><br />
<br />
[[Image:boxplot_geo.png|center]]<br />
---><br />
<br />
=== Example 5: Querying maps ===<br />
<br />
Sometimes you may want to query GRASS GIS maps from your R session.<br />
<br />
As an example, here the transfer of raster pixel values at the position of vector points:<br />
<br />
<source lang="rsplus"><br />
# set the computational region first to the raster map:<br />
execGRASS("g.region", raster = "elev_state_500m", flags = "p")<br />
<br />
# query raster map at vector points, transfer result into R<br />
goutput <- execGRASS("r.what", map="elev_state_500m", points="geodetic_pts", separator=",", intern=TRUE)<br />
str(goutput)<br />
chr [1:29939] "571530.81289275,265739.968425953,,187.8082200648" ...<br />
<br />
# parse it<br />
con <- textConnection(goutput)<br />
go1 <- read.csv(con, header=FALSE)<br />
str(go1)<br />
'data.frame': 29939 obs. of 4 variables:<br />
$ V1: num 571531 571359 571976 572391 573011 ...<br />
$ V2: num 265740 265987 267049 267513 269615 ...<br />
$ V3: logi NA NA NA NA NA NA ...<br />
$ V4: Factor w/ 22738 levels "-0.0048115728",..: 6859 6642 6749 6411 6356 6904 7506 7224 6908 7167 ...<br />
summary(go1)<br />
V1 V2 V3 V4 <br />
Min. :121862 Min. : 7991 Mode:logical 0 : 723 <br />
1st Qu.:462706 1st Qu.:162508 NA's:29939 * : 293 <br />
Median :610328 Median :204502 0.3048 : 47 <br />
Mean :588514 Mean :200038 0.6096 : 44 <br />
3rd Qu.:717610 3rd Qu.:247633 1.524 : 42 <br />
Max. :946743 Max. :327186 0.9144 : 23 <br />
(Other):28767 <br />
</source><br />
<br />
=== Exporting data back to GRASS ===<br />
<br />
Finally, a SpatialGridDataFrame object is written back to a GRASS raster map:<br />
<br />
First prepare some data: (square root of elevation)<br />
<source lang="rsplus"><br />
ncdata$sqdem <- sqrt(ncdata$elevation)<br />
</source><br />
<br />
Export data from ''R'' back into a GRASS raster map:<br />
<source lang="rsplus"><br />
writeRAST(ncdata, "sqdemNC", zcol="sqdem", ignore.stderr=TRUE)<br />
</source><br />
<br />
Check that it imported into GRASS ok:<br />
<source lang="rsplus"><br />
execGRASS("r.info", parameters=list(map="sqdemNC"))<br />
</source><br />
<br />
<pre><br />
+----------------------------------------------------------------------------+<br />
| Map: sqdemNC Date: Sun Jul 19 13:06:34 2015 |<br />
| Mapset: PERMANENT Login of Creator: veroandreo |<br />
| Location: nc_spm_08_grass7 |<br />
| DataBase: /home/veroandreo/grassdata |<br />
| Title: ( sqdemNC ) |<br />
| Timestamp: none |<br />
|----------------------------------------------------------------------------|<br />
| |<br />
| Type of Map: raster Number of Categories: 0 |<br />
| Data Type: DCELL |<br />
| Rows: 491 |<br />
| Columns: 400 |<br />
| Total Cells: 196400 |<br />
| Projection: Lambert Conformal Conic |<br />
| N: 228500 S: 215000.0002 Res: 27.49490794 |<br />
| E: 645000 W: 630000 Res: 37.5 |<br />
| Range of data: min = 7.47818253045085 max = 12.5000787351036 |<br />
| |<br />
| Data Description: |<br />
| generated by r.in.bin |<br />
| |<br />
| Comments: |<br />
| |<br />
+----------------------------------------------------------------------------+<br />
</pre><br />
<br />
=== Using RStudio in a GRASS GIS session ===<br />
<br />
If you are most used to run R through RStudio, but still want to have all GRASS data available for performing<br />
any analyses without loosing the possibility of still using GRASS command line, you can run:<br />
<br />
<source lang="bash"><br />
GRASS> rstudio &<br />
</source><br />
<br />
or, if you already are working on a certain RStudio project:<br />
<br />
<source lang="bash"><br />
GRASS> rstudio /path/to/project/folder/ &<br />
</source><br />
<br />
Then, you load rgrass library in your RStudio project<br />
<source lang="rsplus"><br />
library(rgrass)<br />
</source><br />
<br />
and you are ready to go.<br />
<br />
[[File:Grass7_rstudio.png|thumb|500px|center|RStudio used in GRASS GIS session]]<br />
<br />
== GRASS within R ==<br />
<br />
Using '''GRASS GIS within a R session''', i.e. you connect to a GRASS GIS location/mapset from within R (or RStudio).<br />
<br />
=== Startup ===<br />
<br />
In the first place, find out the path to the GRASS GIS library. This can be easily done with the following command (still outside of R; or through a system() call inside of R):<br />
<br />
<source lang="bash"><br />
# OSGeo4W, Linux, Mac OSX users:<br />
grass --config path<br />
</source><br />
<br />
It may report something like:<br />
<source lang="bash"><br />
# OSGeo4W users:<br />
C:\OSGeo4W64\apps\grass\grass<br />
<br />
# Linux, Mac OSX users:<br />
/usr/local/grass<br />
</source><br />
<br />
To call GRASS GIS functionality from R, start R and use the initGRASS() function to define the GRASS settings. If GRASS GIS was <br />
installed through OSGeo4W, first start the OSGeo4W Shell. Note that it may start in C: or a directory where the user does not have<br />
writing permission. Before calling R or RStudio, first change to a directory where you are sure you have writing permission.<br />
<br />
<source lang="rsplus"><br />
## MS-Windows users (example for an OSGeo4W 64bit installation)<br />
# change to a directory with writing permission<br />
C:\>d:<br />
D:\>cd temp<br />
D:\temp>cd testR<br />
<br />
# start R within this directory:<br />
D:\temp\testR>R<br />
<br />
# to start RStudio from OSGeo4W Shell, run: "C:/Program Files/RStudio/bin/rstudio.exe"<br />
<br />
# load rgrass package<br />
library(rgrass)<br />
<br />
# initialisation of GRASS in the North Carolina sample dataset<br />
initGRASS(gisBase = "C:/OSGeo4W64/apps/grass/grass",<br />
gisDbase = "C:/Users/marissa/grassdata/",<br />
location = "nc_spm_08_grass7", <br />
mapset = "user1", <br />
SG="elevation")<br />
</source><br />
<br />
Linux and Mac OSX users just need to start R or RStudio the usual way, load the rgrass package and initialize GRASS GIS with initGRASS() as shown below:<br />
<br />
<source lang="rsplus"><br />
# load rgrass package<br />
library(rgrass)<br />
# initialisation of GRASS in the North Carolina sample dataset<br />
initGRASS(gisBase = "/usr/local/grass", <br />
home = tempdir(), <br />
gisDbase = "/home/veroandreo/grassdata/",<br />
location = "nc_spm_08_grass7", <br />
mapset = "user1", <br />
SG="elevation")<br />
</source><br />
<br />
Note: the optional SG parameter is a 'SpatialGrid' object to define the ‘DEFAULT_WIND’ of the temporary location.<br />
<br />
<source lang="rsplus"><br />
# set computational region to default (optional)<br />
system("g.region -dp")<br />
# verify metadata<br />
gmeta()<br />
<br />
# get two raster maps into R space<br />
ncdata <- read_RAST(c("geology_30m", "elevation"), cat=c(TRUE, FALSE))<br />
<br />
# calculate object summaries<br />
summary(ncdata$geology_30m)<br />
CZfg_217 CZlg_262 CZig_270 CZbg_405 CZve_583 CZam_720 CZg_766 CZam_862 <br />
292 78 277 102 8 1 2 25 <br />
CZbg_910 Km_921 CZam_946 NA's <br />
18 5 2 1009790 <br />
</source><br />
<br />
== R in GRASS in batch mode ==<br />
<br />
Run the following script with<br />
<br />
<source lang="bash"><br />
R CMD BATCH batch.R<br />
</source><br />
<br />
<source lang="rsplus"><br />
library(rgrass)<br />
# initialisation of GRASS in the North Carolina sample dataset (example with a compiled version)<br />
initGRASS(gisBase = "/home/veroandreo/software/grass/dist.x86_64-pc-linux-gnu", <br />
home = tempdir(), <br />
gisDbase = "/home/veroandreo/grassdata/",<br />
location = "nc_spm_08_grass7", mapset = "user1", SG="elevation",<br />
override = TRUE)<br />
# set region to default<br />
system("g.region -dp")<br />
# verify<br />
gmeta()<br />
# read data into R<br />
ncdata <- read_RAST(c("geology_30m", "elevation"), cat=c(TRUE, FALSE))<br />
# summary of geology map<br />
summary(ncdata$geology_30m)<br />
proc.time()<br />
</source><br />
<br />
The result is (shorted here):<br />
<source lang="bash"><br />
cat batch.Rout<br />
</source> <br />
<br />
<source lang="rsplus"><br />
R version 4.0.2 (2020-06-22) -- "Taking Off Again"<br />
Copyright (C) 2020 The R Foundation for Statistical Computing<br />
Platform: x86_64-redhat-linux-gnu (64-bit)<br />
...<br />
> library(rgrass)<br />
Loading required package: XML<br />
GRASS GIS interface loaded with GRASS version: (GRASS not running)<br />
> # initialisation and the use of north carolina dataset<br />
> initGRASS(gisBase = "/home/veroandreo/software/grass/dist.x86_64-pc-linux-gnu", home = tempdir(), <br />
+ gisDbase = "/home/veroandreo/grassdata/",<br />
+ location = "nc_spm_08_grass7", mapset = "user1", SG="elevation",<br />
+ override = TRUE)<br />
gisdbase /home/veroandreo/grassdata/ <br />
location nc_spm_08_grass7 <br />
mapset user1 <br />
rows 13500 <br />
columns 15000 <br />
north 228500 <br />
south 215000 <br />
west 630000 <br />
east 645000 <br />
nsres 1 <br />
ewres 1 <br />
projection +proj=lcc +lat_1=36.16666666666666 +lat_2=34.33333333333334<br />
+lat_0=33.75 +lon_0=-79 +x_0=609601.22 +y_0=0 +no_defs +a=6378137<br />
+rf=298.257222101 +towgs84=0.000,0.000,0.000 +type=crs +to_meter=1 <br />
<br />
> system("g.region -dp")<br />
projection: 99 (Lambert Conformal Conic)<br />
zone: 0<br />
datum: nad83<br />
ellipsoid: a=6378137 es=0.006694380022900787<br />
north: 320000<br />
south: 10000<br />
west: 120000<br />
east: 935000<br />
nsres: 500<br />
ewres: 500<br />
rows: 620<br />
cols: 1630<br />
cells: 1010600<br />
> gmeta()<br />
gisdbase /home/veroandreo/grassdata/ <br />
location nc_spm_08_grass7 <br />
mapset user1 <br />
rows 620 <br />
columns 1630 <br />
north 320000 <br />
south 10000 <br />
...<br />
> ncdata <- read_RAST(c("geology_30m", "elevation"), cat=c(TRUE, FALSE))<br />
...<br />
> summary(ncdata$geology_30m)<br />
CZfg_217 CZlg_262 CZig_270 CZbg_405 CZve_583 CZam_720 CZg_766 CZam_862 <br />
292 78 277 102 8 1 2 25 <br />
CZbg_910 Km_921 CZam_946 NA's <br />
18 5 2 1009790 <br />
> proc.time()<br />
user system elapsed <br />
8.061 2.016 10.048<br />
</source><br />
<br />
== Troubleshooting ==<br />
<br />
=== Running out of disk space ===<br />
<br />
Linux: A common issue is that /tmp/ is used for temporary files albeit being often a small partition. To change that to a larger directory, you may '''add''' to your <tt>$HOME/.bashrc</tt> the entry:<br />
<br />
<source lang="bash"><br />
# change TMP directory of R (note: of course also another directory than suggested here is fine)<br />
mkdir -p $HOME/tmp<br />
export TMP=$HOME/tmp<br />
</source><br />
<br />
The drawback of this approach is that on modern Linux systems the /tmp/ is a fast RAM disk (based on tempfs) while HOME directories are often on slower spinning disks (unless you have a SSD drive). At least you no longer run out of disk space easily.<br />
<br />
[[Category:FAQ]]<br />
[[Category:Linking to other languages]]<br />
[[Category:R]]<br />
[[Category:Statistics]]</div>Veroandreohttps://grasswiki.osgeo.org/w/index.php?title=R_statistics/rgrass&diff=26889R statistics/rgrass2023-04-21T13:18:40Z<p>Veroandreo: /* Example 4: Summarizing data */ re-adding summary, it works just fine</p>
<hr />
<div>== Installation ==<br />
<br />
See [[R_statistics/Installation]]<br />
<br />
== Terminology ==<br />
<br />
See "Overview" in [[R_statistics]]<br />
<br />
== R within GRASS ==<br />
<br />
In this example, we will use '''R within a GRASS GIS session''', i.e. start R (or RStudio) from the GRASS GIS terminal or command line interface.<br />
<br />
=== Startup ===<br />
<br />
* First start a GRASS GIS session. Then, at the GRASS command line start ''R'' (for an 'rstudio' session, see below)<br />
: ''In this example we will use the [https://grass.osgeo.org/download/data/#NorthCarolinaDataset North Carolina sample dataset].''<br />
<br />
Reset the region settings to the defaults<br />
<source lang="bash"><br />
GRASS (nc_spm_08_grass7):~ > g.region -d<br />
</source><br />
<br />
Launch R from the GRASS prompt<br />
<source lang="bash"><br />
GRASS (nc_spm_08_grass7):~ > R<br />
</source><br />
<br />
Load the ''rgrass'' library:<br />
<source lang="rsplus"><br />
library(rgrass)<br />
</source><br />
<br />
Get the GRASS environment (mapset, region, map projection, etc.); you can display the metadata for your location by printing G:<br />
<source lang="rsplus"><br />
gmeta()<br />
gisdbase /home/mneteler/grassdata <br />
location nc_spm_08_grass7 <br />
mapset user1 <br />
rows 620 <br />
columns 1630 <br />
north 320000 <br />
south 10000 <br />
west 120000 <br />
east 935000 <br />
nsres 500 <br />
ewres 500 <br />
projection:<br />
PROJCRS["NAD83(HARN) / North Carolina",<br />
BASEGEOGCRS["NAD83(HARN)",<br />
DATUM["NAD83 (High Accuracy Reference Network)",<br />
ELLIPSOID["GRS 1980",6378137,298.257222101,<br />
LENGTHUNIT["metre",1]]],<br />
PRIMEM["Greenwich",0,<br />
ANGLEUNIT["degree",0.0174532925199433]],<br />
ID["EPSG",4152]],<br />
CONVERSION["SPCS83 North Carolina zone (meters)",<br />
METHOD["Lambert Conic Conformal (2SP)",<br />
ID["EPSG",9802]],<br />
PARAMETER["Latitude of false origin",33.75,<br />
ANGLEUNIT["degree",0.0174532925199433],<br />
ID["EPSG",8821]],<br />
PARAMETER["Longitude of false origin",-79,<br />
ANGLEUNIT["degree",0.0174532925199433],<br />
ID["EPSG",8822]],<br />
PARAMETER["Latitude of 1st standard parallel",36.1666666666667,<br />
ANGLEUNIT["degree",0.0174532925199433],<br />
ID["EPSG",8823]],<br />
PARAMETER["Latitude of 2nd standard parallel",34.3333333333333,<br />
ANGLEUNIT["degree",0.0174532925199433],<br />
ID["EPSG",8824]],<br />
PARAMETER["Easting at false origin",609601.22,<br />
LENGTHUNIT["metre",1],<br />
ID["EPSG",8826]],<br />
PARAMETER["Northing at false origin",0,<br />
LENGTHUNIT["metre",1],<br />
ID["EPSG",8827]]],<br />
CS[Cartesian,2],<br />
AXIS["easting (X)",east,<br />
ORDER[1],<br />
LENGTHUNIT["metre",1]],<br />
AXIS["northing (Y)",north,<br />
ORDER[2],<br />
LENGTHUNIT["metre",1]],<br />
USAGE[<br />
SCOPE["Engineering survey, topographic mapping."],<br />
AREA["United States (USA) - North Carolina - counties of Alamance; Alexander; Alleghany; Anson; Ashe; Avery; Beaufort; Bertie; Bladen; Brunswick; Buncombe; Burke; Cabarrus; Caldwell; Camden; Carteret; Caswell; Catawba; Chatham; Cherokee; Chowan; Clay; Cleveland; Columbus; Craven; Cumberland; Currituck; Dare; Davidson; Davie; Duplin; Durham; Edgecombe; Forsyth; Franklin; Gaston; Gates; Graham; Granville; Greene; Guilford; Halifax; Harnett; Haywood; Henderson; Hertford; Hoke; Hyde; Iredell; Jackson; Johnston; Jones; Lee; Lenoir; Lincoln; Macon; Madison; Martin; McDowell; Mecklenburg; Mitchell; Montgomery; Moore; Nash; New Hanover; Northampton; Onslow; Orange; Pamlico; Pasquotank; Pender; Perquimans; Person; Pitt; Polk; Randolph; Richmond; Robeson; Rockingham; Rowan; Rutherford; Sampson; Scotland; Stanly; Stokes; Surry; Swain; Transylvania; Tyrrell; Union; Vance; Wake; Warren; Washington; Watauga; Wayne; Wilkes; Wilson; Yadkin; Yancey."],<br />
BBOX[33.83,-84.33,36.59,-75.38]],<br />
ID["EPSG",3358]]<br />
</source><br />
<br />
=== Listing of existing maps ===<br />
<br />
List available vector maps:<br />
<source lang="rsplus"><br />
execGRASS("g.list", parameters = list(type = "vector"))<br />
</source><br />
<br />
List selected vector maps (wildcard):<br />
<source lang="rsplus"><br />
execGRASS("g.list", parameters = list(type = "vector", pattern = "precip*"))<br />
precip<br />
precip_30ynormals<br />
precip_30ynormals_3d<br />
</source><br />
<br />
Save selected vector maps into R vector:<br />
<source lang="rsplus"><br />
my_vmaps <- execGRASS("g.list", parameters = list(type = "vector", pattern = "precip*"))<br />
attributes(my_vmaps)<br />
attributes(my_vmaps)$resOut<br />
[1] "precip" "precip_30ynormals" "precip_30ynormals_3d"<br />
</source><br />
<br />
List available raster maps:<br />
<source lang="rsplus"><br />
execGRASS("g.list", parameters = list(type = "raster"))<br />
</source><br />
<br />
List selected raster maps (wildcard):<br />
<source lang="rsplus"><br />
execGRASS("g.list", parameters = list(type = "raster", pattern = "lsat7_2002*"))<br />
lsat7_2002_10<br />
lsat7_2002_20<br />
lsat7_2002_30<br />
lsat7_2002_40<br />
lsat7_2002_50<br />
lsat7_2002_61<br />
lsat7_2002_62<br />
lsat7_2002_70<br />
lsat7_2002_80<br />
</source><br />
<br />
=== Reading data from GRASS ===<br />
<br />
==== Example 1: raster maps ====<br />
<br />
Manual page: [https://search.r-project.org/CRAN/refmans/rgrass/html/readRAST.html read_RAST()]<br />
<br />
Read two GRASS raster maps, "geology_30m" and "elevation", from the North Carolina sample data location into the R current session as a new object "ncdata". This object is a SpatRaster layer from terra package:<br />
<source lang="rsplus"><br />
ncdata <- read_RAST(c("geology_30m", "elevation"))<br />
</source><br />
<br />
We can verify the new R object:<br />
<source lang="rsplus"><br />
ncdata<br />
class : SpatRaster <br />
dimensions : 450, 500, 2 (nrow, ncol, nlyr)<br />
resolution : 30, 30 (x, y)<br />
extent : 630000, 645000, 215000, 228500 (xmin, xmax, ymin, ymax)<br />
coord. ref. : +proj=lcc +lat_0=33.75 +lon_0=-79 +lat_1=36.1666666666667 +lat_2=34.3333333333333 +x_0=609601.22 +y_0=0 +ellps=GRS80 +units=m +no_defs <br />
sources : file1da12a752d65.grd <br />
file1da12112d9ea4.grd <br />
names : geology_30m, elevation <br />
min values : 217, 55.92321 <br />
max values : 948, 156.25197<br />
</source><br />
<br />
Now, let's plot one of the raster layers within the SpatRaster object. We'll load terra library to have all functionality available:<br />
<source lang="rsplus"><br />
library(terra)<br />
plot(ncdata$elevation, main="North Carolina elevation")<br />
</source><br />
<br />
[[Image:ncdata.png|center]]<br />
<br />
In addition, we can show what is going on inside the objects read into R:<br />
<source lang="rsplus"><br />
summary(ncdata)<br />
geology_30m elevation <br />
Min. :217.0 Min. : 56.01 <br />
1st Qu.:217.0 1st Qu.: 94.77 <br />
Median :270.0 Median :108.86 <br />
Mean :311.2 Mean :110.36 <br />
3rd Qu.:270.0 3rd Qu.:126.80 <br />
Max. :948.0 Max. :156.07 <br />
</source><br />
<br />
==== Example 2: single raster map ====<br />
<br />
Here an example to transfer a single raster map from GRASS GIS to R:<br />
<br />
<source lang="rsplus"><br />
library(rgrass)<br />
library(terra)<br />
execGRASS("g.region", raster = "elevation", flags = "p")<br />
ncdata <- read_RAST("elevation")<br />
summary(ncdata)<br />
plot(ncdata)<br />
</source><br />
<br />
==== Example 3: vector maps ====<br />
<br />
Here an example to transfer a single vector map from GRASS GIS to R. In this case, vector maps from GRASS will be converted into SpatVector objects from the terra package in R:<br />
<br />
<source lang="rsplus"><br />
# needed prerequisite<br />
library(rgrass)<br />
library(terra)<br />
execGRASS("v.info", map="schools_wake", layer="1")<br />
vInfo("schools_wake")<br />
myschools <- read_VECT("schools_wake")<br />
print(summary(myschools))<br />
plot(myschools)<br />
</source><br />
<br />
=== Example 4: Summarizing data ===<br />
<br />
We can create a table of cell counts:<br />
<source lang="rsplus"><br />
freq(ncdata$geology_30m)<br />
</source><br />
<pre><br />
layer value count<br />
1 1 217 80618<br />
2 1 262 22076<br />
3 1 270 76597<br />
4 1 405 28190<br />
5 1 583 2401<br />
6 1 720 536<br />
7 1 766 786<br />
8 1 862 6858<br />
9 1 910 4996<br />
10 1 921 1392<br />
11 1 945 1<br />
12 1 946 452<br />
13 1 948 97<br />
</pre><br />
<br />
And compare with the equivalent GRASS module:<br />
<source lang="rsplus"><br />
execGRASS("r.stats", flags=c("c", "l"), parameters=list(input="geology_30m"), ignore.stderr=TRUE)<br />
</source><br />
<pre><br />
217 CZfg 80618<br />
262 CZlg 22076<br />
270 CZig 76597<br />
405 CZbg 28190<br />
583 CZve 2401<br />
720 CZam 536<br />
766 CZg 786<br />
862 CZam 6858<br />
910 CZbg 4996<br />
921 Km 1392<br />
945 CZbg 1<br />
946 CZam 452<br />
948 CZam 97<br />
</pre><br />
<br />
Create a box plot of geologic types at different elevations:<br />
<source lang="rsplus"><br />
boxplot(ncdata$elevation ~ ncdata$geology_30m, medlwd = 1)<br />
</source><br />
<br />
[[Image:boxplot_geo.png|center]]<br />
<br />
=== Example 5: Querying maps ===<br />
<br />
Sometimes you may want to query GRASS GIS maps from your R session.<br />
<br />
As an example, here the transfer of raster pixel values at the position of vector points:<br />
<br />
<source lang="rsplus"><br />
# set the computational region first to the raster map:<br />
execGRASS("g.region", raster = "elev_state_500m", flags = "p")<br />
<br />
# query raster map at vector points, transfer result into R<br />
goutput <- execGRASS("r.what", map="elev_state_500m", points="geodetic_pts", separator=",", intern=TRUE)<br />
str(goutput)<br />
chr [1:29939] "571530.81289275,265739.968425953,,187.8082200648" ...<br />
<br />
# parse it<br />
con <- textConnection(goutput)<br />
go1 <- read.csv(con, header=FALSE)<br />
str(go1)<br />
'data.frame': 29939 obs. of 4 variables:<br />
$ V1: num 571531 571359 571976 572391 573011 ...<br />
$ V2: num 265740 265987 267049 267513 269615 ...<br />
$ V3: logi NA NA NA NA NA NA ...<br />
$ V4: Factor w/ 22738 levels "-0.0048115728",..: 6859 6642 6749 6411 6356 6904 7506 7224 6908 7167 ...<br />
summary(go1)<br />
V1 V2 V3 V4 <br />
Min. :121862 Min. : 7991 Mode:logical 0 : 723 <br />
1st Qu.:462706 1st Qu.:162508 NA's:29939 * : 293 <br />
Median :610328 Median :204502 0.3048 : 47 <br />
Mean :588514 Mean :200038 0.6096 : 44 <br />
3rd Qu.:717610 3rd Qu.:247633 1.524 : 42 <br />
Max. :946743 Max. :327186 0.9144 : 23 <br />
(Other):28767 <br />
</source><br />
<br />
=== Exporting data back to GRASS ===<br />
<br />
Finally, a SpatialGridDataFrame object is written back to a GRASS raster map:<br />
<br />
First prepare some data: (square root of elevation)<br />
<source lang="rsplus"><br />
ncdata$sqdem <- sqrt(ncdata$elevation)<br />
</source><br />
<br />
Export data from ''R'' back into a GRASS raster map:<br />
<source lang="rsplus"><br />
writeRAST(ncdata, "sqdemNC", zcol="sqdem", ignore.stderr=TRUE)<br />
</source><br />
<br />
Check that it imported into GRASS ok:<br />
<source lang="rsplus"><br />
execGRASS("r.info", parameters=list(map="sqdemNC"))<br />
</source><br />
<br />
<pre><br />
+----------------------------------------------------------------------------+<br />
| Map: sqdemNC Date: Sun Jul 19 13:06:34 2015 |<br />
| Mapset: PERMANENT Login of Creator: veroandreo |<br />
| Location: nc_spm_08_grass7 |<br />
| DataBase: /home/veroandreo/grassdata |<br />
| Title: ( sqdemNC ) |<br />
| Timestamp: none |<br />
|----------------------------------------------------------------------------|<br />
| |<br />
| Type of Map: raster Number of Categories: 0 |<br />
| Data Type: DCELL |<br />
| Rows: 491 |<br />
| Columns: 400 |<br />
| Total Cells: 196400 |<br />
| Projection: Lambert Conformal Conic |<br />
| N: 228500 S: 215000.0002 Res: 27.49490794 |<br />
| E: 645000 W: 630000 Res: 37.5 |<br />
| Range of data: min = 7.47818253045085 max = 12.5000787351036 |<br />
| |<br />
| Data Description: |<br />
| generated by r.in.bin |<br />
| |<br />
| Comments: |<br />
| |<br />
+----------------------------------------------------------------------------+<br />
</pre><br />
<br />
=== Using RStudio in a GRASS GIS session ===<br />
<br />
If you are most used to run R through RStudio, but still want to have all GRASS data available for performing<br />
any analyses without loosing the possibility of still using GRASS command line, you can run:<br />
<br />
<source lang="bash"><br />
GRASS> rstudio &<br />
</source><br />
<br />
or, if you already are working on a certain RStudio project:<br />
<br />
<source lang="bash"><br />
GRASS> rstudio /path/to/project/folder/ &<br />
</source><br />
<br />
Then, you load rgrass library in your RStudio project<br />
<source lang="rsplus"><br />
library(rgrass)<br />
</source><br />
<br />
and you are ready to go.<br />
<br />
[[File:Grass7_rstudio.png|thumb|500px|center|RStudio used in GRASS GIS session]]<br />
<br />
== GRASS within R ==<br />
<br />
Using '''GRASS GIS within a R session''', i.e. you connect to a GRASS GIS location/mapset from within R (or RStudio).<br />
<br />
=== Startup ===<br />
<br />
In the first place, find out the path to the GRASS GIS library. This can be easily done with the following command (still outside of R; or through a system() call inside of R):<br />
<br />
<source lang="bash"><br />
# OSGeo4W, Linux, Mac OSX users:<br />
grass --config path<br />
</source><br />
<br />
It may report something like:<br />
<source lang="bash"><br />
# OSGeo4W users:<br />
C:\OSGeo4W64\apps\grass\grass<br />
<br />
# Linux, Mac OSX users:<br />
/usr/local/grass<br />
</source><br />
<br />
To call GRASS GIS functionality from R, start R and use the initGRASS() function to define the GRASS settings. If GRASS GIS was <br />
installed through OSGeo4W, first start the OSGeo4W Shell. Note that it may start in C: or a directory where the user does not have<br />
writing permission. Before calling R or RStudio, first change to a directory where you are sure you have writing permission.<br />
<br />
<source lang="rsplus"><br />
## MS-Windows users (example for an OSGeo4W 64bit installation)<br />
# change to a directory with writing permission<br />
C:\>d:<br />
D:\>cd temp<br />
D:\temp>cd testR<br />
<br />
# start R within this directory:<br />
D:\temp\testR>R<br />
<br />
# to start RStudio from OSGeo4W Shell, run: "C:/Program Files/RStudio/bin/rstudio.exe"<br />
<br />
# load rgrass package<br />
library(rgrass)<br />
<br />
# initialisation of GRASS in the North Carolina sample dataset<br />
initGRASS(gisBase = "C:/OSGeo4W64/apps/grass/grass",<br />
gisDbase = "C:/Users/marissa/grassdata/",<br />
location = "nc_spm_08_grass7", <br />
mapset = "user1", <br />
SG="elevation")<br />
</source><br />
<br />
Linux and Mac OSX users just need to start R or RStudio the usual way, load the rgrass package and initialize GRASS GIS with initGRASS() as shown below:<br />
<br />
<source lang="rsplus"><br />
# load rgrass package<br />
library(rgrass)<br />
# initialisation of GRASS in the North Carolina sample dataset<br />
initGRASS(gisBase = "/usr/local/grass", <br />
home = tempdir(), <br />
gisDbase = "/home/veroandreo/grassdata/",<br />
location = "nc_spm_08_grass7", <br />
mapset = "user1", <br />
SG="elevation")<br />
</source><br />
<br />
Note: the optional SG parameter is a 'SpatialGrid' object to define the ‘DEFAULT_WIND’ of the temporary location.<br />
<br />
<source lang="rsplus"><br />
# set computational region to default (optional)<br />
system("g.region -dp")<br />
# verify metadata<br />
gmeta()<br />
<br />
# get two raster maps into R space<br />
ncdata <- read_RAST(c("geology_30m", "elevation"), cat=c(TRUE, FALSE))<br />
<br />
# calculate object summaries<br />
summary(ncdata$geology_30m)<br />
CZfg_217 CZlg_262 CZig_270 CZbg_405 CZve_583 CZam_720 CZg_766 CZam_862 <br />
292 78 277 102 8 1 2 25 <br />
CZbg_910 Km_921 CZam_946 NA's <br />
18 5 2 1009790 <br />
</source><br />
<br />
== R in GRASS in batch mode ==<br />
<br />
Run the following script with<br />
<br />
<source lang="bash"><br />
R CMD BATCH batch.R<br />
</source><br />
<br />
<source lang="rsplus"><br />
library(rgrass)<br />
# initialisation of GRASS in the North Carolina sample dataset (example with a compiled version)<br />
initGRASS(gisBase = "/home/veroandreo/software/grass/dist.x86_64-pc-linux-gnu", <br />
home = tempdir(), <br />
gisDbase = "/home/veroandreo/grassdata/",<br />
location = "nc_spm_08_grass7", mapset = "user1", SG="elevation",<br />
override = TRUE)<br />
# set region to default<br />
system("g.region -dp")<br />
# verify<br />
gmeta()<br />
# read data into R<br />
ncdata <- read_RAST(c("geology_30m", "elevation"), cat=c(TRUE, FALSE))<br />
# summary of geology map<br />
summary(ncdata$geology_30m)<br />
proc.time()<br />
</source><br />
<br />
The result is (shorted here):<br />
<source lang="bash"><br />
cat batch.Rout<br />
</source> <br />
<br />
<source lang="rsplus"><br />
R version 4.0.2 (2020-06-22) -- "Taking Off Again"<br />
Copyright (C) 2020 The R Foundation for Statistical Computing<br />
Platform: x86_64-redhat-linux-gnu (64-bit)<br />
...<br />
> library(rgrass)<br />
Loading required package: XML<br />
GRASS GIS interface loaded with GRASS version: (GRASS not running)<br />
> # initialisation and the use of north carolina dataset<br />
> initGRASS(gisBase = "/home/veroandreo/software/grass/dist.x86_64-pc-linux-gnu", home = tempdir(), <br />
+ gisDbase = "/home/veroandreo/grassdata/",<br />
+ location = "nc_spm_08_grass7", mapset = "user1", SG="elevation",<br />
+ override = TRUE)<br />
gisdbase /home/veroandreo/grassdata/ <br />
location nc_spm_08_grass7 <br />
mapset user1 <br />
rows 13500 <br />
columns 15000 <br />
north 228500 <br />
south 215000 <br />
west 630000 <br />
east 645000 <br />
nsres 1 <br />
ewres 1 <br />
projection +proj=lcc +lat_1=36.16666666666666 +lat_2=34.33333333333334<br />
+lat_0=33.75 +lon_0=-79 +x_0=609601.22 +y_0=0 +no_defs +a=6378137<br />
+rf=298.257222101 +towgs84=0.000,0.000,0.000 +type=crs +to_meter=1 <br />
<br />
> system("g.region -dp")<br />
projection: 99 (Lambert Conformal Conic)<br />
zone: 0<br />
datum: nad83<br />
ellipsoid: a=6378137 es=0.006694380022900787<br />
north: 320000<br />
south: 10000<br />
west: 120000<br />
east: 935000<br />
nsres: 500<br />
ewres: 500<br />
rows: 620<br />
cols: 1630<br />
cells: 1010600<br />
> gmeta()<br />
gisdbase /home/veroandreo/grassdata/ <br />
location nc_spm_08_grass7 <br />
mapset user1 <br />
rows 620 <br />
columns 1630 <br />
north 320000 <br />
south 10000 <br />
...<br />
> ncdata <- read_RAST(c("geology_30m", "elevation"), cat=c(TRUE, FALSE))<br />
...<br />
> summary(ncdata$geology_30m)<br />
CZfg_217 CZlg_262 CZig_270 CZbg_405 CZve_583 CZam_720 CZg_766 CZam_862 <br />
292 78 277 102 8 1 2 25 <br />
CZbg_910 Km_921 CZam_946 NA's <br />
18 5 2 1009790 <br />
> proc.time()<br />
user system elapsed <br />
8.061 2.016 10.048<br />
</source><br />
<br />
== Troubleshooting ==<br />
<br />
=== Running out of disk space ===<br />
<br />
Linux: A common issue is that /tmp/ is used for temporary files albeit being often a small partition. To change that to a larger directory, you may '''add''' to your <tt>$HOME/.bashrc</tt> the entry:<br />
<br />
<source lang="bash"><br />
# change TMP directory of R (note: of course also another directory than suggested here is fine)<br />
mkdir -p $HOME/tmp<br />
export TMP=$HOME/tmp<br />
</source><br />
<br />
The drawback of this approach is that on modern Linux systems the /tmp/ is a fast RAM disk (based on tempfs) while HOME directories are often on slower spinning disks (unless you have a SSD drive). At least you no longer run out of disk space easily.<br />
<br />
[[Category:FAQ]]<br />
[[Category:Linking to other languages]]<br />
[[Category:R]]<br />
[[Category:Statistics]]</div>Veroandreohttps://grasswiki.osgeo.org/w/index.php?title=R_statistics/rgrass&diff=26888R statistics/rgrass2023-04-21T12:53:06Z<p>Veroandreo: /* Reading in data from GRASS */ remove terra:: and call the library instead</p>
<hr />
<div>== Installation ==<br />
<br />
See [[R_statistics/Installation]]<br />
<br />
== Terminology ==<br />
<br />
See "Overview" in [[R_statistics]]<br />
<br />
== R within GRASS ==<br />
<br />
In this example, we will use '''R within a GRASS GIS session''', i.e. start R (or RStudio) from the GRASS GIS terminal or command line interface.<br />
<br />
=== Startup ===<br />
<br />
* First start a GRASS GIS session. Then, at the GRASS command line start ''R'' (for an 'rstudio' session, see below)<br />
: ''In this example we will use the [https://grass.osgeo.org/download/data/#NorthCarolinaDataset North Carolina sample dataset].''<br />
<br />
Reset the region settings to the defaults<br />
<source lang="bash"><br />
GRASS (nc_spm_08_grass7):~ > g.region -d<br />
</source><br />
<br />
Launch R from the GRASS prompt<br />
<source lang="bash"><br />
GRASS (nc_spm_08_grass7):~ > R<br />
</source><br />
<br />
Load the ''rgrass'' library:<br />
<source lang="rsplus"><br />
library(rgrass)<br />
</source><br />
<br />
Get the GRASS environment (mapset, region, map projection, etc.); you can display the metadata for your location by printing G:<br />
<source lang="rsplus"><br />
gmeta()<br />
gisdbase /home/mneteler/grassdata <br />
location nc_spm_08_grass7 <br />
mapset user1 <br />
rows 620 <br />
columns 1630 <br />
north 320000 <br />
south 10000 <br />
west 120000 <br />
east 935000 <br />
nsres 500 <br />
ewres 500 <br />
projection:<br />
PROJCRS["NAD83(HARN) / North Carolina",<br />
BASEGEOGCRS["NAD83(HARN)",<br />
DATUM["NAD83 (High Accuracy Reference Network)",<br />
ELLIPSOID["GRS 1980",6378137,298.257222101,<br />
LENGTHUNIT["metre",1]]],<br />
PRIMEM["Greenwich",0,<br />
ANGLEUNIT["degree",0.0174532925199433]],<br />
ID["EPSG",4152]],<br />
CONVERSION["SPCS83 North Carolina zone (meters)",<br />
METHOD["Lambert Conic Conformal (2SP)",<br />
ID["EPSG",9802]],<br />
PARAMETER["Latitude of false origin",33.75,<br />
ANGLEUNIT["degree",0.0174532925199433],<br />
ID["EPSG",8821]],<br />
PARAMETER["Longitude of false origin",-79,<br />
ANGLEUNIT["degree",0.0174532925199433],<br />
ID["EPSG",8822]],<br />
PARAMETER["Latitude of 1st standard parallel",36.1666666666667,<br />
ANGLEUNIT["degree",0.0174532925199433],<br />
ID["EPSG",8823]],<br />
PARAMETER["Latitude of 2nd standard parallel",34.3333333333333,<br />
ANGLEUNIT["degree",0.0174532925199433],<br />
ID["EPSG",8824]],<br />
PARAMETER["Easting at false origin",609601.22,<br />
LENGTHUNIT["metre",1],<br />
ID["EPSG",8826]],<br />
PARAMETER["Northing at false origin",0,<br />
LENGTHUNIT["metre",1],<br />
ID["EPSG",8827]]],<br />
CS[Cartesian,2],<br />
AXIS["easting (X)",east,<br />
ORDER[1],<br />
LENGTHUNIT["metre",1]],<br />
AXIS["northing (Y)",north,<br />
ORDER[2],<br />
LENGTHUNIT["metre",1]],<br />
USAGE[<br />
SCOPE["Engineering survey, topographic mapping."],<br />
AREA["United States (USA) - North Carolina - counties of Alamance; Alexander; Alleghany; Anson; Ashe; Avery; Beaufort; Bertie; Bladen; Brunswick; Buncombe; Burke; Cabarrus; Caldwell; Camden; Carteret; Caswell; Catawba; Chatham; Cherokee; Chowan; Clay; Cleveland; Columbus; Craven; Cumberland; Currituck; Dare; Davidson; Davie; Duplin; Durham; Edgecombe; Forsyth; Franklin; Gaston; Gates; Graham; Granville; Greene; Guilford; Halifax; Harnett; Haywood; Henderson; Hertford; Hoke; Hyde; Iredell; Jackson; Johnston; Jones; Lee; Lenoir; Lincoln; Macon; Madison; Martin; McDowell; Mecklenburg; Mitchell; Montgomery; Moore; Nash; New Hanover; Northampton; Onslow; Orange; Pamlico; Pasquotank; Pender; Perquimans; Person; Pitt; Polk; Randolph; Richmond; Robeson; Rockingham; Rowan; Rutherford; Sampson; Scotland; Stanly; Stokes; Surry; Swain; Transylvania; Tyrrell; Union; Vance; Wake; Warren; Washington; Watauga; Wayne; Wilkes; Wilson; Yadkin; Yancey."],<br />
BBOX[33.83,-84.33,36.59,-75.38]],<br />
ID["EPSG",3358]]<br />
</source><br />
<br />
=== Listing of existing maps ===<br />
<br />
List available vector maps:<br />
<source lang="rsplus"><br />
execGRASS("g.list", parameters = list(type = "vector"))<br />
</source><br />
<br />
List selected vector maps (wildcard):<br />
<source lang="rsplus"><br />
execGRASS("g.list", parameters = list(type = "vector", pattern = "precip*"))<br />
precip<br />
precip_30ynormals<br />
precip_30ynormals_3d<br />
</source><br />
<br />
Save selected vector maps into R vector:<br />
<source lang="rsplus"><br />
my_vmaps <- execGRASS("g.list", parameters = list(type = "vector", pattern = "precip*"))<br />
attributes(my_vmaps)<br />
attributes(my_vmaps)$resOut<br />
[1] "precip" "precip_30ynormals" "precip_30ynormals_3d"<br />
</source><br />
<br />
List available raster maps:<br />
<source lang="rsplus"><br />
execGRASS("g.list", parameters = list(type = "raster"))<br />
</source><br />
<br />
List selected raster maps (wildcard):<br />
<source lang="rsplus"><br />
execGRASS("g.list", parameters = list(type = "raster", pattern = "lsat7_2002*"))<br />
lsat7_2002_10<br />
lsat7_2002_20<br />
lsat7_2002_30<br />
lsat7_2002_40<br />
lsat7_2002_50<br />
lsat7_2002_61<br />
lsat7_2002_62<br />
lsat7_2002_70<br />
lsat7_2002_80<br />
</source><br />
<br />
=== Reading data from GRASS ===<br />
<br />
==== Example 1: raster maps ====<br />
<br />
Manual page: [https://search.r-project.org/CRAN/refmans/rgrass/html/readRAST.html read_RAST()]<br />
<br />
Read two GRASS raster maps, "geology_30m" and "elevation", from the North Carolina sample data location into the R current session as a new object "ncdata". This object is a SpatRaster layer from terra package:<br />
<source lang="rsplus"><br />
ncdata <- read_RAST(c("geology_30m", "elevation"))<br />
</source><br />
<br />
We can verify the new R object:<br />
<source lang="rsplus"><br />
ncdata<br />
class : SpatRaster <br />
dimensions : 450, 500, 2 (nrow, ncol, nlyr)<br />
resolution : 30, 30 (x, y)<br />
extent : 630000, 645000, 215000, 228500 (xmin, xmax, ymin, ymax)<br />
coord. ref. : +proj=lcc +lat_0=33.75 +lon_0=-79 +lat_1=36.1666666666667 +lat_2=34.3333333333333 +x_0=609601.22 +y_0=0 +ellps=GRS80 +units=m +no_defs <br />
sources : file1da12a752d65.grd <br />
file1da12112d9ea4.grd <br />
names : geology_30m, elevation <br />
min values : 217, 55.92321 <br />
max values : 948, 156.25197<br />
</source><br />
<br />
Now, let's plot one of the raster layers within the SpatRaster object. We'll load terra library to have all functionality available:<br />
<source lang="rsplus"><br />
library(terra)<br />
plot(ncdata$elevation, main="North Carolina elevation")<br />
</source><br />
<br />
[[Image:ncdata.png|center]]<br />
<br />
In addition, we can show what is going on inside the objects read into R:<br />
<source lang="rsplus"><br />
summary(ncdata)<br />
geology_30m elevation <br />
Min. :217.0 Min. : 56.01 <br />
1st Qu.:217.0 1st Qu.: 94.77 <br />
Median :270.0 Median :108.86 <br />
Mean :311.2 Mean :110.36 <br />
3rd Qu.:270.0 3rd Qu.:126.80 <br />
Max. :948.0 Max. :156.07 <br />
</source><br />
<br />
==== Example 2: single raster map ====<br />
<br />
Here an example to transfer a single raster map from GRASS GIS to R:<br />
<br />
<source lang="rsplus"><br />
library(rgrass)<br />
library(terra)<br />
execGRASS("g.region", raster = "elevation", flags = "p")<br />
ncdata <- read_RAST("elevation")<br />
summary(ncdata)<br />
plot(ncdata)<br />
</source><br />
<br />
==== Example 3: vector maps ====<br />
<br />
Here an example to transfer a single vector map from GRASS GIS to R. In this case, vector maps from GRASS will be converted into SpatVector objects from the terra package in R:<br />
<br />
<source lang="rsplus"><br />
# needed prerequisite<br />
library(rgrass)<br />
library(terra)<br />
execGRASS("v.info", map="schools_wake", layer="1")<br />
vInfo("schools_wake")<br />
myschools <- read_VECT("schools_wake")<br />
print(summary(myschools))<br />
plot(myschools)<br />
</source><br />
<br />
=== Example 4: Summarizing data ===<br />
<br />
<!--- this does not coincide now using the function freq in terra, so removing<br />
We can create a table of cell counts:<br />
<source lang="rsplus"><br />
table(ncdata$geology_30m)<br />
</source><br />
{| class="wikitable" border="1"<br />
!CZfg_217 <br />
!CZlg_262 <br />
!CZig_270 <br />
!CZbg_405 <br />
!CZve_583 <br />
!CZam_720 <br />
!CZg_766 <br />
!CZam_862 <br />
!CZbg_910 <br />
!Km_921 <br />
!CZbg_945 <br />
!CZam_946 <br />
!CZam_948<br />
|-<br />
|70381<br />
|19287<br />
|66861 <br />
|24561 <br />
|2089 <br />
|467 <br />
|691 <br />
|6017 <br />
|4351<br />
|1211 <br />
|1 <br />
|398 <br />
|85<br />
|}<br />
<br />
And compare with the equivalent GRASS module:<br />
<source lang="rsplus"><br />
execGRASS("r.stats", flags=c("c", "l"), parameters=list(input="geology_30m"), ignore.stderr=TRUE)<br />
</source><br />
<pre><br />
217 CZfg 70381<br />
262 CZlg 19287<br />
270 CZig 66861<br />
405 CZbg 24561<br />
583 CZve 2089<br />
720 CZam 467<br />
766 CZg 691<br />
862 CZam 6017<br />
910 CZbg 4351<br />
921 Km 1211<br />
945 CZbg 1<br />
946 CZam 398<br />
948 CZam 85<br />
</pre><br />
---><br />
<br />
Create a box plot of geologic types at different elevations:<br />
<source lang="rsplus"><br />
boxplot(ncdata$elevation ~ ncdata$geology_30m, medlwd = 1)<br />
</source><br />
<br />
[[Image:boxplot_geo.png|center]]<br />
<br />
=== Example 5: Querying maps ===<br />
<br />
Sometimes you may want to query GRASS GIS maps from your R session.<br />
<br />
As an example, here the transfer of raster pixel values at the position of vector points:<br />
<br />
<source lang="rsplus"><br />
# set the computational region first to the raster map:<br />
execGRASS("g.region", raster = "elev_state_500m", flags = "p")<br />
<br />
# query raster map at vector points, transfer result into R<br />
goutput <- execGRASS("r.what", map="elev_state_500m", points="geodetic_pts", separator=",", intern=TRUE)<br />
str(goutput)<br />
chr [1:29939] "571530.81289275,265739.968425953,,187.8082200648" ...<br />
<br />
# parse it<br />
con <- textConnection(goutput)<br />
go1 <- read.csv(con, header=FALSE)<br />
str(go1)<br />
'data.frame': 29939 obs. of 4 variables:<br />
$ V1: num 571531 571359 571976 572391 573011 ...<br />
$ V2: num 265740 265987 267049 267513 269615 ...<br />
$ V3: logi NA NA NA NA NA NA ...<br />
$ V4: Factor w/ 22738 levels "-0.0048115728",..: 6859 6642 6749 6411 6356 6904 7506 7224 6908 7167 ...<br />
summary(go1)<br />
V1 V2 V3 V4 <br />
Min. :121862 Min. : 7991 Mode:logical 0 : 723 <br />
1st Qu.:462706 1st Qu.:162508 NA's:29939 * : 293 <br />
Median :610328 Median :204502 0.3048 : 47 <br />
Mean :588514 Mean :200038 0.6096 : 44 <br />
3rd Qu.:717610 3rd Qu.:247633 1.524 : 42 <br />
Max. :946743 Max. :327186 0.9144 : 23 <br />
(Other):28767 <br />
</source><br />
<br />
=== Exporting data back to GRASS ===<br />
<br />
Finally, a SpatialGridDataFrame object is written back to a GRASS raster map:<br />
<br />
First prepare some data: (square root of elevation)<br />
<source lang="rsplus"><br />
ncdata$sqdem <- sqrt(ncdata$elevation)<br />
</source><br />
<br />
Export data from ''R'' back into a GRASS raster map:<br />
<source lang="rsplus"><br />
writeRAST(ncdata, "sqdemNC", zcol="sqdem", ignore.stderr=TRUE)<br />
</source><br />
<br />
Check that it imported into GRASS ok:<br />
<source lang="rsplus"><br />
execGRASS("r.info", parameters=list(map="sqdemNC"))<br />
</source><br />
<br />
<pre><br />
+----------------------------------------------------------------------------+<br />
| Map: sqdemNC Date: Sun Jul 19 13:06:34 2015 |<br />
| Mapset: PERMANENT Login of Creator: veroandreo |<br />
| Location: nc_spm_08_grass7 |<br />
| DataBase: /home/veroandreo/grassdata |<br />
| Title: ( sqdemNC ) |<br />
| Timestamp: none |<br />
|----------------------------------------------------------------------------|<br />
| |<br />
| Type of Map: raster Number of Categories: 0 |<br />
| Data Type: DCELL |<br />
| Rows: 491 |<br />
| Columns: 400 |<br />
| Total Cells: 196400 |<br />
| Projection: Lambert Conformal Conic |<br />
| N: 228500 S: 215000.0002 Res: 27.49490794 |<br />
| E: 645000 W: 630000 Res: 37.5 |<br />
| Range of data: min = 7.47818253045085 max = 12.5000787351036 |<br />
| |<br />
| Data Description: |<br />
| generated by r.in.bin |<br />
| |<br />
| Comments: |<br />
| |<br />
+----------------------------------------------------------------------------+<br />
</pre><br />
<br />
=== Using RStudio in a GRASS GIS session ===<br />
<br />
If you are most used to run R through RStudio, but still want to have all GRASS data available for performing<br />
any analyses without loosing the possibility of still using GRASS command line, you can run:<br />
<br />
<source lang="bash"><br />
GRASS> rstudio &<br />
</source><br />
<br />
or, if you already are working on a certain RStudio project:<br />
<br />
<source lang="bash"><br />
GRASS> rstudio /path/to/project/folder/ &<br />
</source><br />
<br />
Then, you load rgrass library in your RStudio project<br />
<source lang="rsplus"><br />
library(rgrass)<br />
</source><br />
<br />
and you are ready to go.<br />
<br />
[[File:Grass7_rstudio.png|thumb|500px|center|RStudio used in GRASS GIS session]]<br />
<br />
== GRASS within R ==<br />
<br />
Using '''GRASS GIS within a R session''', i.e. you connect to a GRASS GIS location/mapset from within R (or RStudio).<br />
<br />
=== Startup ===<br />
<br />
In the first place, find out the path to the GRASS GIS library. This can be easily done with the following command (still outside of R; or through a system() call inside of R):<br />
<br />
<source lang="bash"><br />
# OSGeo4W, Linux, Mac OSX users:<br />
grass --config path<br />
</source><br />
<br />
It may report something like:<br />
<source lang="bash"><br />
# OSGeo4W users:<br />
C:\OSGeo4W64\apps\grass\grass<br />
<br />
# Linux, Mac OSX users:<br />
/usr/local/grass<br />
</source><br />
<br />
To call GRASS GIS functionality from R, start R and use the initGRASS() function to define the GRASS settings. If GRASS GIS was <br />
installed through OSGeo4W, first start the OSGeo4W Shell. Note that it may start in C: or a directory where the user does not have<br />
writing permission. Before calling R or RStudio, first change to a directory where you are sure you have writing permission.<br />
<br />
<source lang="rsplus"><br />
## MS-Windows users (example for an OSGeo4W 64bit installation)<br />
# change to a directory with writing permission<br />
C:\>d:<br />
D:\>cd temp<br />
D:\temp>cd testR<br />
<br />
# start R within this directory:<br />
D:\temp\testR>R<br />
<br />
# to start RStudio from OSGeo4W Shell, run: "C:/Program Files/RStudio/bin/rstudio.exe"<br />
<br />
# load rgrass package<br />
library(rgrass)<br />
<br />
# initialisation of GRASS in the North Carolina sample dataset<br />
initGRASS(gisBase = "C:/OSGeo4W64/apps/grass/grass",<br />
gisDbase = "C:/Users/marissa/grassdata/",<br />
location = "nc_spm_08_grass7", <br />
mapset = "user1", <br />
SG="elevation")<br />
</source><br />
<br />
Linux and Mac OSX users just need to start R or RStudio the usual way, load the rgrass package and initialize GRASS GIS with initGRASS() as shown below:<br />
<br />
<source lang="rsplus"><br />
# load rgrass package<br />
library(rgrass)<br />
# initialisation of GRASS in the North Carolina sample dataset<br />
initGRASS(gisBase = "/usr/local/grass", <br />
home = tempdir(), <br />
gisDbase = "/home/veroandreo/grassdata/",<br />
location = "nc_spm_08_grass7", <br />
mapset = "user1", <br />
SG="elevation")<br />
</source><br />
<br />
Note: the optional SG parameter is a 'SpatialGrid' object to define the ‘DEFAULT_WIND’ of the temporary location.<br />
<br />
<source lang="rsplus"><br />
# set computational region to default (optional)<br />
system("g.region -dp")<br />
# verify metadata<br />
gmeta()<br />
<br />
# get two raster maps into R space<br />
ncdata <- read_RAST(c("geology_30m", "elevation"), cat=c(TRUE, FALSE))<br />
<br />
# calculate object summaries<br />
summary(ncdata$geology_30m)<br />
CZfg_217 CZlg_262 CZig_270 CZbg_405 CZve_583 CZam_720 CZg_766 CZam_862 <br />
292 78 277 102 8 1 2 25 <br />
CZbg_910 Km_921 CZam_946 NA's <br />
18 5 2 1009790 <br />
</source><br />
<br />
== R in GRASS in batch mode ==<br />
<br />
Run the following script with<br />
<br />
<source lang="bash"><br />
R CMD BATCH batch.R<br />
</source><br />
<br />
<source lang="rsplus"><br />
library(rgrass)<br />
# initialisation of GRASS in the North Carolina sample dataset (example with a compiled version)<br />
initGRASS(gisBase = "/home/veroandreo/software/grass/dist.x86_64-pc-linux-gnu", <br />
home = tempdir(), <br />
gisDbase = "/home/veroandreo/grassdata/",<br />
location = "nc_spm_08_grass7", mapset = "user1", SG="elevation",<br />
override = TRUE)<br />
# set region to default<br />
system("g.region -dp")<br />
# verify<br />
gmeta()<br />
# read data into R<br />
ncdata <- read_RAST(c("geology_30m", "elevation"), cat=c(TRUE, FALSE))<br />
# summary of geology map<br />
summary(ncdata$geology_30m)<br />
proc.time()<br />
</source><br />
<br />
The result is (shorted here):<br />
<source lang="bash"><br />
cat batch.Rout<br />
</source> <br />
<br />
<source lang="rsplus"><br />
R version 4.0.2 (2020-06-22) -- "Taking Off Again"<br />
Copyright (C) 2020 The R Foundation for Statistical Computing<br />
Platform: x86_64-redhat-linux-gnu (64-bit)<br />
...<br />
> library(rgrass)<br />
Loading required package: XML<br />
GRASS GIS interface loaded with GRASS version: (GRASS not running)<br />
> # initialisation and the use of north carolina dataset<br />
> initGRASS(gisBase = "/home/veroandreo/software/grass/dist.x86_64-pc-linux-gnu", home = tempdir(), <br />
+ gisDbase = "/home/veroandreo/grassdata/",<br />
+ location = "nc_spm_08_grass7", mapset = "user1", SG="elevation",<br />
+ override = TRUE)<br />
gisdbase /home/veroandreo/grassdata/ <br />
location nc_spm_08_grass7 <br />
mapset user1 <br />
rows 13500 <br />
columns 15000 <br />
north 228500 <br />
south 215000 <br />
west 630000 <br />
east 645000 <br />
nsres 1 <br />
ewres 1 <br />
projection +proj=lcc +lat_1=36.16666666666666 +lat_2=34.33333333333334<br />
+lat_0=33.75 +lon_0=-79 +x_0=609601.22 +y_0=0 +no_defs +a=6378137<br />
+rf=298.257222101 +towgs84=0.000,0.000,0.000 +type=crs +to_meter=1 <br />
<br />
> system("g.region -dp")<br />
projection: 99 (Lambert Conformal Conic)<br />
zone: 0<br />
datum: nad83<br />
ellipsoid: a=6378137 es=0.006694380022900787<br />
north: 320000<br />
south: 10000<br />
west: 120000<br />
east: 935000<br />
nsres: 500<br />
ewres: 500<br />
rows: 620<br />
cols: 1630<br />
cells: 1010600<br />
> gmeta()<br />
gisdbase /home/veroandreo/grassdata/ <br />
location nc_spm_08_grass7 <br />
mapset user1 <br />
rows 620 <br />
columns 1630 <br />
north 320000 <br />
south 10000 <br />
...<br />
> ncdata <- read_RAST(c("geology_30m", "elevation"), cat=c(TRUE, FALSE))<br />
...<br />
> summary(ncdata$geology_30m)<br />
CZfg_217 CZlg_262 CZig_270 CZbg_405 CZve_583 CZam_720 CZg_766 CZam_862 <br />
292 78 277 102 8 1 2 25 <br />
CZbg_910 Km_921 CZam_946 NA's <br />
18 5 2 1009790 <br />
> proc.time()<br />
user system elapsed <br />
8.061 2.016 10.048<br />
</source><br />
<br />
== Troubleshooting ==<br />
<br />
=== Running out of disk space ===<br />
<br />
Linux: A common issue is that /tmp/ is used for temporary files albeit being often a small partition. To change that to a larger directory, you may '''add''' to your <tt>$HOME/.bashrc</tt> the entry:<br />
<br />
<source lang="bash"><br />
# change TMP directory of R (note: of course also another directory than suggested here is fine)<br />
mkdir -p $HOME/tmp<br />
export TMP=$HOME/tmp<br />
</source><br />
<br />
The drawback of this approach is that on modern Linux systems the /tmp/ is a fast RAM disk (based on tempfs) while HOME directories are often on slower spinning disks (unless you have a SSD drive). At least you no longer run out of disk space easily.<br />
<br />
[[Category:FAQ]]<br />
[[Category:Linking to other languages]]<br />
[[Category:R]]<br />
[[Category:Statistics]]</div>Veroandreohttps://grasswiki.osgeo.org/w/index.php?title=R_statistics/rgrass&diff=26887R statistics/rgrass2023-04-21T12:50:44Z<p>Veroandreo: /* Example 1: raster maps */ update commands</p>
<hr />
<div>== Installation ==<br />
<br />
See [[R_statistics/Installation]]<br />
<br />
== Terminology ==<br />
<br />
See "Overview" in [[R_statistics]]<br />
<br />
== R within GRASS ==<br />
<br />
In this example, we will use '''R within a GRASS GIS session''', i.e. start R (or RStudio) from the GRASS GIS terminal or command line interface.<br />
<br />
=== Startup ===<br />
<br />
* First start a GRASS GIS session. Then, at the GRASS command line start ''R'' (for an 'rstudio' session, see below)<br />
: ''In this example we will use the [https://grass.osgeo.org/download/data/#NorthCarolinaDataset North Carolina sample dataset].''<br />
<br />
Reset the region settings to the defaults<br />
<source lang="bash"><br />
GRASS (nc_spm_08_grass7):~ > g.region -d<br />
</source><br />
<br />
Launch R from the GRASS prompt<br />
<source lang="bash"><br />
GRASS (nc_spm_08_grass7):~ > R<br />
</source><br />
<br />
Load the ''rgrass'' library:<br />
<source lang="rsplus"><br />
library(rgrass)<br />
</source><br />
<br />
Get the GRASS environment (mapset, region, map projection, etc.); you can display the metadata for your location by printing G:<br />
<source lang="rsplus"><br />
gmeta()<br />
gisdbase /home/mneteler/grassdata <br />
location nc_spm_08_grass7 <br />
mapset user1 <br />
rows 620 <br />
columns 1630 <br />
north 320000 <br />
south 10000 <br />
west 120000 <br />
east 935000 <br />
nsres 500 <br />
ewres 500 <br />
projection:<br />
PROJCRS["NAD83(HARN) / North Carolina",<br />
BASEGEOGCRS["NAD83(HARN)",<br />
DATUM["NAD83 (High Accuracy Reference Network)",<br />
ELLIPSOID["GRS 1980",6378137,298.257222101,<br />
LENGTHUNIT["metre",1]]],<br />
PRIMEM["Greenwich",0,<br />
ANGLEUNIT["degree",0.0174532925199433]],<br />
ID["EPSG",4152]],<br />
CONVERSION["SPCS83 North Carolina zone (meters)",<br />
METHOD["Lambert Conic Conformal (2SP)",<br />
ID["EPSG",9802]],<br />
PARAMETER["Latitude of false origin",33.75,<br />
ANGLEUNIT["degree",0.0174532925199433],<br />
ID["EPSG",8821]],<br />
PARAMETER["Longitude of false origin",-79,<br />
ANGLEUNIT["degree",0.0174532925199433],<br />
ID["EPSG",8822]],<br />
PARAMETER["Latitude of 1st standard parallel",36.1666666666667,<br />
ANGLEUNIT["degree",0.0174532925199433],<br />
ID["EPSG",8823]],<br />
PARAMETER["Latitude of 2nd standard parallel",34.3333333333333,<br />
ANGLEUNIT["degree",0.0174532925199433],<br />
ID["EPSG",8824]],<br />
PARAMETER["Easting at false origin",609601.22,<br />
LENGTHUNIT["metre",1],<br />
ID["EPSG",8826]],<br />
PARAMETER["Northing at false origin",0,<br />
LENGTHUNIT["metre",1],<br />
ID["EPSG",8827]]],<br />
CS[Cartesian,2],<br />
AXIS["easting (X)",east,<br />
ORDER[1],<br />
LENGTHUNIT["metre",1]],<br />
AXIS["northing (Y)",north,<br />
ORDER[2],<br />
LENGTHUNIT["metre",1]],<br />
USAGE[<br />
SCOPE["Engineering survey, topographic mapping."],<br />
AREA["United States (USA) - North Carolina - counties of Alamance; Alexander; Alleghany; Anson; Ashe; Avery; Beaufort; Bertie; Bladen; Brunswick; Buncombe; Burke; Cabarrus; Caldwell; Camden; Carteret; Caswell; Catawba; Chatham; Cherokee; Chowan; Clay; Cleveland; Columbus; Craven; Cumberland; Currituck; Dare; Davidson; Davie; Duplin; Durham; Edgecombe; Forsyth; Franklin; Gaston; Gates; Graham; Granville; Greene; Guilford; Halifax; Harnett; Haywood; Henderson; Hertford; Hoke; Hyde; Iredell; Jackson; Johnston; Jones; Lee; Lenoir; Lincoln; Macon; Madison; Martin; McDowell; Mecklenburg; Mitchell; Montgomery; Moore; Nash; New Hanover; Northampton; Onslow; Orange; Pamlico; Pasquotank; Pender; Perquimans; Person; Pitt; Polk; Randolph; Richmond; Robeson; Rockingham; Rowan; Rutherford; Sampson; Scotland; Stanly; Stokes; Surry; Swain; Transylvania; Tyrrell; Union; Vance; Wake; Warren; Washington; Watauga; Wayne; Wilkes; Wilson; Yadkin; Yancey."],<br />
BBOX[33.83,-84.33,36.59,-75.38]],<br />
ID["EPSG",3358]]<br />
</source><br />
<br />
=== Listing of existing maps ===<br />
<br />
List available vector maps:<br />
<source lang="rsplus"><br />
execGRASS("g.list", parameters = list(type = "vector"))<br />
</source><br />
<br />
List selected vector maps (wildcard):<br />
<source lang="rsplus"><br />
execGRASS("g.list", parameters = list(type = "vector", pattern = "precip*"))<br />
precip<br />
precip_30ynormals<br />
precip_30ynormals_3d<br />
</source><br />
<br />
Save selected vector maps into R vector:<br />
<source lang="rsplus"><br />
my_vmaps <- execGRASS("g.list", parameters = list(type = "vector", pattern = "precip*"))<br />
attributes(my_vmaps)<br />
attributes(my_vmaps)$resOut<br />
[1] "precip" "precip_30ynormals" "precip_30ynormals_3d"<br />
</source><br />
<br />
List available raster maps:<br />
<source lang="rsplus"><br />
execGRASS("g.list", parameters = list(type = "raster"))<br />
</source><br />
<br />
List selected raster maps (wildcard):<br />
<source lang="rsplus"><br />
execGRASS("g.list", parameters = list(type = "raster", pattern = "lsat7_2002*"))<br />
lsat7_2002_10<br />
lsat7_2002_20<br />
lsat7_2002_30<br />
lsat7_2002_40<br />
lsat7_2002_50<br />
lsat7_2002_61<br />
lsat7_2002_62<br />
lsat7_2002_70<br />
lsat7_2002_80<br />
</source><br />
<br />
=== Reading in data from GRASS ===<br />
<br />
==== Example 1: raster maps ====<br />
<br />
Manual page: [https://search.r-project.org/CRAN/refmans/rgrass/html/readRAST.html read_RAST()]<br />
<br />
Read two GRASS raster maps, "geology_30m" and "elevation", from the North Carolina sample data location into the R current session as a new object "ncdata". This object is a SpatRaster layer from terra package:<br />
<source lang="rsplus"><br />
ncdata <- read_RAST(c("geology_30m", "elevation"))<br />
</source><br />
<br />
We can verify the new R object:<br />
<source lang="rsplus"><br />
ncdata<br />
class : SpatRaster <br />
dimensions : 450, 500, 2 (nrow, ncol, nlyr)<br />
resolution : 30, 30 (x, y)<br />
extent : 630000, 645000, 215000, 228500 (xmin, xmax, ymin, ymax)<br />
coord. ref. : +proj=lcc +lat_0=33.75 +lon_0=-79 +lat_1=36.1666666666667 +lat_2=34.3333333333333 +x_0=609601.22 +y_0=0 +ellps=GRS80 +units=m +no_defs <br />
sources : file1da12a752d65.grd <br />
file1da12112d9ea4.grd <br />
names : geology_30m, elevation <br />
min values : 217, 55.92321 <br />
max values : 948, 156.25197<br />
</source><br />
<br />
Now, let's plot one of the raster layers within the SpatRaster object. We'll load terra library to have all functionality available:<br />
<source lang="rsplus"><br />
library(terra)<br />
plot(ncdata$elevation, main="North Carolina elevation")<br />
</source><br />
<br />
[[Image:ncdata.png|center]]<br />
<br />
In addition, we can show what is going on inside the objects read into R:<br />
<source lang="rsplus"><br />
summary(ncdata)<br />
geology_30m elevation <br />
Min. :217.0 Min. : 56.01 <br />
1st Qu.:217.0 1st Qu.: 94.77 <br />
Median :270.0 Median :108.86 <br />
Mean :311.2 Mean :110.36 <br />
3rd Qu.:270.0 3rd Qu.:126.80 <br />
Max. :948.0 Max. :156.07 <br />
</source><br />
<br />
==== Example 2: single raster map ====<br />
<br />
Here an example for a single raster map transfer from GRASS GIS to R:<br />
<br />
<source lang="rsplus"><br />
library(rgrass)<br />
execGRASS("g.region", raster = "elevation", flags = "p")<br />
ncdata <- read_RAST("elevation")<br />
terra::summary(ncdata)<br />
terra::plot(ncdata)<br />
</source><br />
<br />
==== Example 3: vector maps ====<br />
<br />
Here an example for a single vector map transfer from GRASS GIS to R. In this case, vector maps from GRASS will be converted into SpatVector objects from the terra package in R:<br />
<br />
<source lang="rsplus"><br />
# needed prerequisite<br />
library(rgrass)<br />
<br />
execGRASS("v.info", map="schools_wake", layer="1")<br />
vInfo("schools_wake")<br />
myschools <- read_VECT("schools_wake")<br />
print(terra::summary(myschools))<br />
terra::plot(myschools)<br />
</source><br />
<br />
=== Example 4: Summarizing data ===<br />
<br />
<!--- this does not coincide now using the function freq in terra, so removing<br />
We can create a table of cell counts:<br />
<source lang="rsplus"><br />
table(ncdata$geology_30m)<br />
</source><br />
{| class="wikitable" border="1"<br />
!CZfg_217 <br />
!CZlg_262 <br />
!CZig_270 <br />
!CZbg_405 <br />
!CZve_583 <br />
!CZam_720 <br />
!CZg_766 <br />
!CZam_862 <br />
!CZbg_910 <br />
!Km_921 <br />
!CZbg_945 <br />
!CZam_946 <br />
!CZam_948<br />
|-<br />
|70381<br />
|19287<br />
|66861 <br />
|24561 <br />
|2089 <br />
|467 <br />
|691 <br />
|6017 <br />
|4351<br />
|1211 <br />
|1 <br />
|398 <br />
|85<br />
|}<br />
<br />
And compare with the equivalent GRASS module:<br />
<source lang="rsplus"><br />
execGRASS("r.stats", flags=c("c", "l"), parameters=list(input="geology_30m"), ignore.stderr=TRUE)<br />
</source><br />
<pre><br />
217 CZfg 70381<br />
262 CZlg 19287<br />
270 CZig 66861<br />
405 CZbg 24561<br />
583 CZve 2089<br />
720 CZam 467<br />
766 CZg 691<br />
862 CZam 6017<br />
910 CZbg 4351<br />
921 Km 1211<br />
945 CZbg 1<br />
946 CZam 398<br />
948 CZam 85<br />
</pre><br />
---><br />
<br />
Create a box plot of geologic types at different elevations:<br />
<source lang="rsplus"><br />
boxplot(ncdata$elevation ~ ncdata$geology_30m, medlwd = 1)<br />
</source><br />
<br />
[[Image:boxplot_geo.png|center]]<br />
<br />
=== Example 5: Querying maps ===<br />
<br />
Sometimes you may want to query GRASS GIS maps from your R session.<br />
<br />
As an example, here the transfer of raster pixel values at the position of vector points:<br />
<br />
<source lang="rsplus"><br />
# set the computational region first to the raster map:<br />
execGRASS("g.region", raster = "elev_state_500m", flags = "p")<br />
<br />
# query raster map at vector points, transfer result into R<br />
goutput <- execGRASS("r.what", map="elev_state_500m", points="geodetic_pts", separator=",", intern=TRUE)<br />
str(goutput)<br />
chr [1:29939] "571530.81289275,265739.968425953,,187.8082200648" ...<br />
<br />
# parse it<br />
con <- textConnection(goutput)<br />
go1 <- read.csv(con, header=FALSE)<br />
str(go1)<br />
'data.frame': 29939 obs. of 4 variables:<br />
$ V1: num 571531 571359 571976 572391 573011 ...<br />
$ V2: num 265740 265987 267049 267513 269615 ...<br />
$ V3: logi NA NA NA NA NA NA ...<br />
$ V4: Factor w/ 22738 levels "-0.0048115728",..: 6859 6642 6749 6411 6356 6904 7506 7224 6908 7167 ...<br />
summary(go1)<br />
V1 V2 V3 V4 <br />
Min. :121862 Min. : 7991 Mode:logical 0 : 723 <br />
1st Qu.:462706 1st Qu.:162508 NA's:29939 * : 293 <br />
Median :610328 Median :204502 0.3048 : 47 <br />
Mean :588514 Mean :200038 0.6096 : 44 <br />
3rd Qu.:717610 3rd Qu.:247633 1.524 : 42 <br />
Max. :946743 Max. :327186 0.9144 : 23 <br />
(Other):28767 <br />
</source><br />
<br />
=== Exporting data back to GRASS ===<br />
<br />
Finally, a SpatialGridDataFrame object is written back to a GRASS raster map:<br />
<br />
First prepare some data: (square root of elevation)<br />
<source lang="rsplus"><br />
ncdata$sqdem <- sqrt(ncdata$elevation)<br />
</source><br />
<br />
Export data from ''R'' back into a GRASS raster map:<br />
<source lang="rsplus"><br />
writeRAST(ncdata, "sqdemNC", zcol="sqdem", ignore.stderr=TRUE)<br />
</source><br />
<br />
Check that it imported into GRASS ok:<br />
<source lang="rsplus"><br />
execGRASS("r.info", parameters=list(map="sqdemNC"))<br />
</source><br />
<br />
<pre><br />
+----------------------------------------------------------------------------+<br />
| Map: sqdemNC Date: Sun Jul 19 13:06:34 2015 |<br />
| Mapset: PERMANENT Login of Creator: veroandreo |<br />
| Location: nc_spm_08_grass7 |<br />
| DataBase: /home/veroandreo/grassdata |<br />
| Title: ( sqdemNC ) |<br />
| Timestamp: none |<br />
|----------------------------------------------------------------------------|<br />
| |<br />
| Type of Map: raster Number of Categories: 0 |<br />
| Data Type: DCELL |<br />
| Rows: 491 |<br />
| Columns: 400 |<br />
| Total Cells: 196400 |<br />
| Projection: Lambert Conformal Conic |<br />
| N: 228500 S: 215000.0002 Res: 27.49490794 |<br />
| E: 645000 W: 630000 Res: 37.5 |<br />
| Range of data: min = 7.47818253045085 max = 12.5000787351036 |<br />
| |<br />
| Data Description: |<br />
| generated by r.in.bin |<br />
| |<br />
| Comments: |<br />
| |<br />
+----------------------------------------------------------------------------+<br />
</pre><br />
<br />
=== Using RStudio in a GRASS GIS session ===<br />
<br />
If you are most used to run R through RStudio, but still want to have all GRASS data available for performing<br />
any analyses without loosing the possibility of still using GRASS command line, you can run:<br />
<br />
<source lang="bash"><br />
GRASS> rstudio &<br />
</source><br />
<br />
or, if you already are working on a certain RStudio project:<br />
<br />
<source lang="bash"><br />
GRASS> rstudio /path/to/project/folder/ &<br />
</source><br />
<br />
Then, you load rgrass library in your RStudio project<br />
<source lang="rsplus"><br />
library(rgrass)<br />
</source><br />
<br />
and you are ready to go.<br />
<br />
[[File:Grass7_rstudio.png|thumb|500px|center|RStudio used in GRASS GIS session]]<br />
<br />
== GRASS within R ==<br />
<br />
Using '''GRASS GIS within a R session''', i.e. you connect to a GRASS GIS location/mapset from within R (or RStudio).<br />
<br />
=== Startup ===<br />
<br />
In the first place, find out the path to the GRASS GIS library. This can be easily done with the following command (still outside of R; or through a system() call inside of R):<br />
<br />
<source lang="bash"><br />
# OSGeo4W, Linux, Mac OSX users:<br />
grass --config path<br />
</source><br />
<br />
It may report something like:<br />
<source lang="bash"><br />
# OSGeo4W users:<br />
C:\OSGeo4W64\apps\grass\grass<br />
<br />
# Linux, Mac OSX users:<br />
/usr/local/grass<br />
</source><br />
<br />
To call GRASS GIS functionality from R, start R and use the initGRASS() function to define the GRASS settings. If GRASS GIS was <br />
installed through OSGeo4W, first start the OSGeo4W Shell. Note that it may start in C: or a directory where the user does not have<br />
writing permission. Before calling R or RStudio, first change to a directory where you are sure you have writing permission.<br />
<br />
<source lang="rsplus"><br />
## MS-Windows users (example for an OSGeo4W 64bit installation)<br />
# change to a directory with writing permission<br />
C:\>d:<br />
D:\>cd temp<br />
D:\temp>cd testR<br />
<br />
# start R within this directory:<br />
D:\temp\testR>R<br />
<br />
# to start RStudio from OSGeo4W Shell, run: "C:/Program Files/RStudio/bin/rstudio.exe"<br />
<br />
# load rgrass package<br />
library(rgrass)<br />
<br />
# initialisation of GRASS in the North Carolina sample dataset<br />
initGRASS(gisBase = "C:/OSGeo4W64/apps/grass/grass",<br />
gisDbase = "C:/Users/marissa/grassdata/",<br />
location = "nc_spm_08_grass7", <br />
mapset = "user1", <br />
SG="elevation")<br />
</source><br />
<br />
Linux and Mac OSX users just need to start R or RStudio the usual way, load the rgrass package and initialize GRASS GIS with initGRASS() as shown below:<br />
<br />
<source lang="rsplus"><br />
# load rgrass package<br />
library(rgrass)<br />
# initialisation of GRASS in the North Carolina sample dataset<br />
initGRASS(gisBase = "/usr/local/grass", <br />
home = tempdir(), <br />
gisDbase = "/home/veroandreo/grassdata/",<br />
location = "nc_spm_08_grass7", <br />
mapset = "user1", <br />
SG="elevation")<br />
</source><br />
<br />
Note: the optional SG parameter is a 'SpatialGrid' object to define the ‘DEFAULT_WIND’ of the temporary location.<br />
<br />
<source lang="rsplus"><br />
# set computational region to default (optional)<br />
system("g.region -dp")<br />
# verify metadata<br />
gmeta()<br />
<br />
# get two raster maps into R space<br />
ncdata <- read_RAST(c("geology_30m", "elevation"), cat=c(TRUE, FALSE))<br />
<br />
# calculate object summaries<br />
summary(ncdata$geology_30m)<br />
CZfg_217 CZlg_262 CZig_270 CZbg_405 CZve_583 CZam_720 CZg_766 CZam_862 <br />
292 78 277 102 8 1 2 25 <br />
CZbg_910 Km_921 CZam_946 NA's <br />
18 5 2 1009790 <br />
</source><br />
<br />
== R in GRASS in batch mode ==<br />
<br />
Run the following script with<br />
<br />
<source lang="bash"><br />
R CMD BATCH batch.R<br />
</source><br />
<br />
<source lang="rsplus"><br />
library(rgrass)<br />
# initialisation of GRASS in the North Carolina sample dataset (example with a compiled version)<br />
initGRASS(gisBase = "/home/veroandreo/software/grass/dist.x86_64-pc-linux-gnu", <br />
home = tempdir(), <br />
gisDbase = "/home/veroandreo/grassdata/",<br />
location = "nc_spm_08_grass7", mapset = "user1", SG="elevation",<br />
override = TRUE)<br />
# set region to default<br />
system("g.region -dp")<br />
# verify<br />
gmeta()<br />
# read data into R<br />
ncdata <- read_RAST(c("geology_30m", "elevation"), cat=c(TRUE, FALSE))<br />
# summary of geology map<br />
summary(ncdata$geology_30m)<br />
proc.time()<br />
</source><br />
<br />
The result is (shorted here):<br />
<source lang="bash"><br />
cat batch.Rout<br />
</source> <br />
<br />
<source lang="rsplus"><br />
R version 4.0.2 (2020-06-22) -- "Taking Off Again"<br />
Copyright (C) 2020 The R Foundation for Statistical Computing<br />
Platform: x86_64-redhat-linux-gnu (64-bit)<br />
...<br />
> library(rgrass)<br />
Loading required package: XML<br />
GRASS GIS interface loaded with GRASS version: (GRASS not running)<br />
> # initialisation and the use of north carolina dataset<br />
> initGRASS(gisBase = "/home/veroandreo/software/grass/dist.x86_64-pc-linux-gnu", home = tempdir(), <br />
+ gisDbase = "/home/veroandreo/grassdata/",<br />
+ location = "nc_spm_08_grass7", mapset = "user1", SG="elevation",<br />
+ override = TRUE)<br />
gisdbase /home/veroandreo/grassdata/ <br />
location nc_spm_08_grass7 <br />
mapset user1 <br />
rows 13500 <br />
columns 15000 <br />
north 228500 <br />
south 215000 <br />
west 630000 <br />
east 645000 <br />
nsres 1 <br />
ewres 1 <br />
projection +proj=lcc +lat_1=36.16666666666666 +lat_2=34.33333333333334<br />
+lat_0=33.75 +lon_0=-79 +x_0=609601.22 +y_0=0 +no_defs +a=6378137<br />
+rf=298.257222101 +towgs84=0.000,0.000,0.000 +type=crs +to_meter=1 <br />
<br />
> system("g.region -dp")<br />
projection: 99 (Lambert Conformal Conic)<br />
zone: 0<br />
datum: nad83<br />
ellipsoid: a=6378137 es=0.006694380022900787<br />
north: 320000<br />
south: 10000<br />
west: 120000<br />
east: 935000<br />
nsres: 500<br />
ewres: 500<br />
rows: 620<br />
cols: 1630<br />
cells: 1010600<br />
> gmeta()<br />
gisdbase /home/veroandreo/grassdata/ <br />
location nc_spm_08_grass7 <br />
mapset user1 <br />
rows 620 <br />
columns 1630 <br />
north 320000 <br />
south 10000 <br />
...<br />
> ncdata <- read_RAST(c("geology_30m", "elevation"), cat=c(TRUE, FALSE))<br />
...<br />
> summary(ncdata$geology_30m)<br />
CZfg_217 CZlg_262 CZig_270 CZbg_405 CZve_583 CZam_720 CZg_766 CZam_862 <br />
292 78 277 102 8 1 2 25 <br />
CZbg_910 Km_921 CZam_946 NA's <br />
18 5 2 1009790 <br />
> proc.time()<br />
user system elapsed <br />
8.061 2.016 10.048<br />
</source><br />
<br />
== Troubleshooting ==<br />
<br />
=== Running out of disk space ===<br />
<br />
Linux: A common issue is that /tmp/ is used for temporary files albeit being often a small partition. To change that to a larger directory, you may '''add''' to your <tt>$HOME/.bashrc</tt> the entry:<br />
<br />
<source lang="bash"><br />
# change TMP directory of R (note: of course also another directory than suggested here is fine)<br />
mkdir -p $HOME/tmp<br />
export TMP=$HOME/tmp<br />
</source><br />
<br />
The drawback of this approach is that on modern Linux systems the /tmp/ is a fast RAM disk (based on tempfs) while HOME directories are often on slower spinning disks (unless you have a SSD drive). At least you no longer run out of disk space easily.<br />
<br />
[[Category:FAQ]]<br />
[[Category:Linking to other languages]]<br />
[[Category:R]]<br />
[[Category:Statistics]]</div>Veroandreohttps://grasswiki.osgeo.org/w/index.php?title=R_statistics/rgrass&diff=26886R statistics/rgrass2023-04-19T20:55:23Z<p>Veroandreo: update examples to terra - wip</p>
<hr />
<div>== Installation ==<br />
<br />
See [[R_statistics/Installation]]<br />
<br />
== Terminology ==<br />
<br />
See "Overview" in [[R_statistics]]<br />
<br />
== R within GRASS ==<br />
<br />
In this example, we will use '''R within a GRASS GIS session''', i.e. start R (or RStudio) from the GRASS GIS terminal or command line interface.<br />
<br />
=== Startup ===<br />
<br />
* First start a GRASS GIS session. Then, at the GRASS command line start ''R'' (for an 'rstudio' session, see below)<br />
: ''In this example we will use the [https://grass.osgeo.org/download/data/#NorthCarolinaDataset North Carolina sample dataset].''<br />
<br />
Reset the region settings to the defaults<br />
<source lang="bash"><br />
GRASS (nc_spm_08_grass7):~ > g.region -d<br />
</source><br />
<br />
Launch R from the GRASS prompt<br />
<source lang="bash"><br />
GRASS (nc_spm_08_grass7):~ > R<br />
</source><br />
<br />
Load the ''rgrass'' library:<br />
<source lang="rsplus"><br />
library(rgrass)<br />
</source><br />
<br />
Get the GRASS environment (mapset, region, map projection, etc.); you can display the metadata for your location by printing G:<br />
<source lang="rsplus"><br />
gmeta()<br />
gisdbase /home/mneteler/grassdata <br />
location nc_spm_08_grass7 <br />
mapset user1 <br />
rows 620 <br />
columns 1630 <br />
north 320000 <br />
south 10000 <br />
west 120000 <br />
east 935000 <br />
nsres 500 <br />
ewres 500 <br />
projection:<br />
PROJCRS["NAD83(HARN) / North Carolina",<br />
BASEGEOGCRS["NAD83(HARN)",<br />
DATUM["NAD83 (High Accuracy Reference Network)",<br />
ELLIPSOID["GRS 1980",6378137,298.257222101,<br />
LENGTHUNIT["metre",1]]],<br />
PRIMEM["Greenwich",0,<br />
ANGLEUNIT["degree",0.0174532925199433]],<br />
ID["EPSG",4152]],<br />
CONVERSION["SPCS83 North Carolina zone (meters)",<br />
METHOD["Lambert Conic Conformal (2SP)",<br />
ID["EPSG",9802]],<br />
PARAMETER["Latitude of false origin",33.75,<br />
ANGLEUNIT["degree",0.0174532925199433],<br />
ID["EPSG",8821]],<br />
PARAMETER["Longitude of false origin",-79,<br />
ANGLEUNIT["degree",0.0174532925199433],<br />
ID["EPSG",8822]],<br />
PARAMETER["Latitude of 1st standard parallel",36.1666666666667,<br />
ANGLEUNIT["degree",0.0174532925199433],<br />
ID["EPSG",8823]],<br />
PARAMETER["Latitude of 2nd standard parallel",34.3333333333333,<br />
ANGLEUNIT["degree",0.0174532925199433],<br />
ID["EPSG",8824]],<br />
PARAMETER["Easting at false origin",609601.22,<br />
LENGTHUNIT["metre",1],<br />
ID["EPSG",8826]],<br />
PARAMETER["Northing at false origin",0,<br />
LENGTHUNIT["metre",1],<br />
ID["EPSG",8827]]],<br />
CS[Cartesian,2],<br />
AXIS["easting (X)",east,<br />
ORDER[1],<br />
LENGTHUNIT["metre",1]],<br />
AXIS["northing (Y)",north,<br />
ORDER[2],<br />
LENGTHUNIT["metre",1]],<br />
USAGE[<br />
SCOPE["Engineering survey, topographic mapping."],<br />
AREA["United States (USA) - North Carolina - counties of Alamance; Alexander; Alleghany; Anson; Ashe; Avery; Beaufort; Bertie; Bladen; Brunswick; Buncombe; Burke; Cabarrus; Caldwell; Camden; Carteret; Caswell; Catawba; Chatham; Cherokee; Chowan; Clay; Cleveland; Columbus; Craven; Cumberland; Currituck; Dare; Davidson; Davie; Duplin; Durham; Edgecombe; Forsyth; Franklin; Gaston; Gates; Graham; Granville; Greene; Guilford; Halifax; Harnett; Haywood; Henderson; Hertford; Hoke; Hyde; Iredell; Jackson; Johnston; Jones; Lee; Lenoir; Lincoln; Macon; Madison; Martin; McDowell; Mecklenburg; Mitchell; Montgomery; Moore; Nash; New Hanover; Northampton; Onslow; Orange; Pamlico; Pasquotank; Pender; Perquimans; Person; Pitt; Polk; Randolph; Richmond; Robeson; Rockingham; Rowan; Rutherford; Sampson; Scotland; Stanly; Stokes; Surry; Swain; Transylvania; Tyrrell; Union; Vance; Wake; Warren; Washington; Watauga; Wayne; Wilkes; Wilson; Yadkin; Yancey."],<br />
BBOX[33.83,-84.33,36.59,-75.38]],<br />
ID["EPSG",3358]]<br />
</source><br />
<br />
=== Listing of existing maps ===<br />
<br />
List available vector maps:<br />
<source lang="rsplus"><br />
execGRASS("g.list", parameters = list(type = "vector"))<br />
</source><br />
<br />
List selected vector maps (wildcard):<br />
<source lang="rsplus"><br />
execGRASS("g.list", parameters = list(type = "vector", pattern = "precip*"))<br />
precip<br />
precip_30ynormals<br />
precip_30ynormals_3d<br />
</source><br />
<br />
Save selected vector maps into R vector:<br />
<source lang="rsplus"><br />
my_vmaps <- execGRASS("g.list", parameters = list(type = "vector", pattern = "precip*"))<br />
attributes(my_vmaps)<br />
attributes(my_vmaps)$resOut<br />
[1] "precip" "precip_30ynormals" "precip_30ynormals_3d"<br />
</source><br />
<br />
List available raster maps:<br />
<source lang="rsplus"><br />
execGRASS("g.list", parameters = list(type = "raster"))<br />
</source><br />
<br />
List selected raster maps (wildcard):<br />
<source lang="rsplus"><br />
execGRASS("g.list", parameters = list(type = "raster", pattern = "lsat7_2002*"))<br />
lsat7_2002_10<br />
lsat7_2002_20<br />
lsat7_2002_30<br />
lsat7_2002_40<br />
lsat7_2002_50<br />
lsat7_2002_61<br />
lsat7_2002_62<br />
lsat7_2002_70<br />
lsat7_2002_80<br />
</source><br />
<br />
=== Reading in data from GRASS ===<br />
<br />
==== Example 1: raster maps ====<br />
<br />
Manual page: [https://search.r-project.org/CRAN/refmans/rgrass/html/readRAST.html read_RAST()]<br />
<br />
Read in two GRASS raster maps, "geology_30m" and "elevation", from the North Carolina sample data location into the R current session as a new object "ncdata". This object is a SpatRaster layer from terra package:<br />
<source lang="rsplus"><br />
ncdata <- read_RAST(c("geology_30m", "elevation"))<br />
</source><br />
<br />
We can verify the new R object:<br />
<source lang="rsplus"><br />
ncdata<br />
class : SpatRaster <br />
dimensions : 450, 500, 2 (nrow, ncol, nlyr)<br />
resolution : 30, 30 (x, y)<br />
extent : 630000, 645000, 215000, 228500 (xmin, xmax, ymin, ymax)<br />
coord. ref. : +proj=lcc +lat_0=33.75 +lon_0=-79 +lat_1=36.1666666666667 +lat_2=34.3333333333333 +x_0=609601.22 +y_0=0 +ellps=GRS80 +units=m +no_defs <br />
sources : file1da12a752d65.grd <br />
file1da12112d9ea4.grd <br />
names : geology_30m, elevation <br />
min values : 217, 55.92321 <br />
max values : 948, 156.25197<br />
</source><br />
<br />
Now, let's plot one of the raster layers within the SpatRaster object. Note that we use the terra package plot function:<br />
<source lang="rsplus"><br />
terra::plot(ncdata$elevation)<br />
</source><br />
<br />
Add a title to the plot:<br />
<source lang="rsplus"><br />
title("North Carolina elevation")<br />
</source><br />
<br />
[[Image:ncdata.png|center]]<br />
<br />
In addition, we can show what is going on inside the objects read into R:<br />
<source lang="rsplus"><br />
terra::summary(ncdata)<br />
geology_30m elevation <br />
Min. :217.0 Min. : 56.01 <br />
1st Qu.:217.0 1st Qu.: 94.77 <br />
Median :270.0 Median :108.86 <br />
Mean :311.2 Mean :110.36 <br />
3rd Qu.:270.0 3rd Qu.:126.80 <br />
Max. :948.0 Max. :156.07 <br />
</source><br />
<br />
==== Example 2: single raster map ====<br />
<br />
Here an example for a single raster map transfer from GRASS GIS to R:<br />
<br />
<source lang="rsplus"><br />
library(rgrass)<br />
execGRASS("g.region", raster = "elevation", flags = "p")<br />
ncdata <- read_RAST("elevation")<br />
terra::summary(ncdata)<br />
terra::plot(ncdata)<br />
</source><br />
<br />
==== Example 3: vector maps ====<br />
<br />
Here an example for a single vector map transfer from GRASS GIS to R. In this case, vector maps from GRASS will be converted into SpatVector objects from the terra package in R:<br />
<br />
<source lang="rsplus"><br />
# needed prerequisite<br />
library(rgrass)<br />
<br />
execGRASS("v.info", map="schools_wake", layer="1")<br />
vInfo("schools_wake")<br />
myschools <- read_VECT("schools_wake")<br />
print(terra::summary(myschools))<br />
terra::plot(myschools)<br />
</source><br />
<br />
=== Example 4: Summarizing data ===<br />
<br />
<!--- this does not coincide now using the function freq in terra, so removing<br />
We can create a table of cell counts:<br />
<source lang="rsplus"><br />
table(ncdata$geology_30m)<br />
</source><br />
{| class="wikitable" border="1"<br />
!CZfg_217 <br />
!CZlg_262 <br />
!CZig_270 <br />
!CZbg_405 <br />
!CZve_583 <br />
!CZam_720 <br />
!CZg_766 <br />
!CZam_862 <br />
!CZbg_910 <br />
!Km_921 <br />
!CZbg_945 <br />
!CZam_946 <br />
!CZam_948<br />
|-<br />
|70381<br />
|19287<br />
|66861 <br />
|24561 <br />
|2089 <br />
|467 <br />
|691 <br />
|6017 <br />
|4351<br />
|1211 <br />
|1 <br />
|398 <br />
|85<br />
|}<br />
<br />
And compare with the equivalent GRASS module:<br />
<source lang="rsplus"><br />
execGRASS("r.stats", flags=c("c", "l"), parameters=list(input="geology_30m"), ignore.stderr=TRUE)<br />
</source><br />
<pre><br />
217 CZfg 70381<br />
262 CZlg 19287<br />
270 CZig 66861<br />
405 CZbg 24561<br />
583 CZve 2089<br />
720 CZam 467<br />
766 CZg 691<br />
862 CZam 6017<br />
910 CZbg 4351<br />
921 Km 1211<br />
945 CZbg 1<br />
946 CZam 398<br />
948 CZam 85<br />
</pre><br />
---><br />
<br />
Create a box plot of geologic types at different elevations:<br />
<source lang="rsplus"><br />
boxplot(ncdata$elevation ~ ncdata$geology_30m, medlwd = 1)<br />
</source><br />
<br />
[[Image:boxplot_geo.png|center]]<br />
<br />
=== Example 5: Querying maps ===<br />
<br />
Sometimes you may want to query GRASS GIS maps from your R session.<br />
<br />
As an example, here the transfer of raster pixel values at the position of vector points:<br />
<br />
<source lang="rsplus"><br />
# set the computational region first to the raster map:<br />
execGRASS("g.region", raster = "elev_state_500m", flags = "p")<br />
<br />
# query raster map at vector points, transfer result into R<br />
goutput <- execGRASS("r.what", map="elev_state_500m", points="geodetic_pts", separator=",", intern=TRUE)<br />
str(goutput)<br />
chr [1:29939] "571530.81289275,265739.968425953,,187.8082200648" ...<br />
<br />
# parse it<br />
con <- textConnection(goutput)<br />
go1 <- read.csv(con, header=FALSE)<br />
str(go1)<br />
'data.frame': 29939 obs. of 4 variables:<br />
$ V1: num 571531 571359 571976 572391 573011 ...<br />
$ V2: num 265740 265987 267049 267513 269615 ...<br />
$ V3: logi NA NA NA NA NA NA ...<br />
$ V4: Factor w/ 22738 levels "-0.0048115728",..: 6859 6642 6749 6411 6356 6904 7506 7224 6908 7167 ...<br />
summary(go1)<br />
V1 V2 V3 V4 <br />
Min. :121862 Min. : 7991 Mode:logical 0 : 723 <br />
1st Qu.:462706 1st Qu.:162508 NA's:29939 * : 293 <br />
Median :610328 Median :204502 0.3048 : 47 <br />
Mean :588514 Mean :200038 0.6096 : 44 <br />
3rd Qu.:717610 3rd Qu.:247633 1.524 : 42 <br />
Max. :946743 Max. :327186 0.9144 : 23 <br />
(Other):28767 <br />
</source><br />
<br />
=== Exporting data back to GRASS ===<br />
<br />
Finally, a SpatialGridDataFrame object is written back to a GRASS raster map:<br />
<br />
First prepare some data: (square root of elevation)<br />
<source lang="rsplus"><br />
ncdata$sqdem <- sqrt(ncdata$elevation)<br />
</source><br />
<br />
Export data from ''R'' back into a GRASS raster map:<br />
<source lang="rsplus"><br />
writeRAST(ncdata, "sqdemNC", zcol="sqdem", ignore.stderr=TRUE)<br />
</source><br />
<br />
Check that it imported into GRASS ok:<br />
<source lang="rsplus"><br />
execGRASS("r.info", parameters=list(map="sqdemNC"))<br />
</source><br />
<br />
<pre><br />
+----------------------------------------------------------------------------+<br />
| Map: sqdemNC Date: Sun Jul 19 13:06:34 2015 |<br />
| Mapset: PERMANENT Login of Creator: veroandreo |<br />
| Location: nc_spm_08_grass7 |<br />
| DataBase: /home/veroandreo/grassdata |<br />
| Title: ( sqdemNC ) |<br />
| Timestamp: none |<br />
|----------------------------------------------------------------------------|<br />
| |<br />
| Type of Map: raster Number of Categories: 0 |<br />
| Data Type: DCELL |<br />
| Rows: 491 |<br />
| Columns: 400 |<br />
| Total Cells: 196400 |<br />
| Projection: Lambert Conformal Conic |<br />
| N: 228500 S: 215000.0002 Res: 27.49490794 |<br />
| E: 645000 W: 630000 Res: 37.5 |<br />
| Range of data: min = 7.47818253045085 max = 12.5000787351036 |<br />
| |<br />
| Data Description: |<br />
| generated by r.in.bin |<br />
| |<br />
| Comments: |<br />
| |<br />
+----------------------------------------------------------------------------+<br />
</pre><br />
<br />
=== Using RStudio in a GRASS GIS session ===<br />
<br />
If you are most used to run R through RStudio, but still want to have all GRASS data available for performing<br />
any analyses without loosing the possibility of still using GRASS command line, you can run:<br />
<br />
<source lang="bash"><br />
GRASS> rstudio &<br />
</source><br />
<br />
or, if you already are working on a certain RStudio project:<br />
<br />
<source lang="bash"><br />
GRASS> rstudio /path/to/project/folder/ &<br />
</source><br />
<br />
Then, you load rgrass library in your RStudio project<br />
<source lang="rsplus"><br />
library(rgrass)<br />
</source><br />
<br />
and you are ready to go.<br />
<br />
[[File:Grass7_rstudio.png|thumb|500px|center|RStudio used in GRASS GIS session]]<br />
<br />
== GRASS within R ==<br />
<br />
Using '''GRASS GIS within a R session''', i.e. you connect to a GRASS GIS location/mapset from within R (or RStudio).<br />
<br />
=== Startup ===<br />
<br />
In the first place, find out the path to the GRASS GIS library. This can be easily done with the following command (still outside of R; or through a system() call inside of R):<br />
<br />
<source lang="bash"><br />
# OSGeo4W, Linux, Mac OSX users:<br />
grass --config path<br />
</source><br />
<br />
It may report something like:<br />
<source lang="bash"><br />
# OSGeo4W users:<br />
C:\OSGeo4W64\apps\grass\grass<br />
<br />
# Linux, Mac OSX users:<br />
/usr/local/grass<br />
</source><br />
<br />
To call GRASS GIS functionality from R, start R and use the initGRASS() function to define the GRASS settings. If GRASS GIS was <br />
installed through OSGeo4W, first start the OSGeo4W Shell. Note that it may start in C: or a directory where the user does not have<br />
writing permission. Before calling R or RStudio, first change to a directory where you are sure you have writing permission.<br />
<br />
<source lang="rsplus"><br />
## MS-Windows users (example for an OSGeo4W 64bit installation)<br />
# change to a directory with writing permission<br />
C:\>d:<br />
D:\>cd temp<br />
D:\temp>cd testR<br />
<br />
# start R within this directory:<br />
D:\temp\testR>R<br />
<br />
# to start RStudio from OSGeo4W Shell, run: "C:/Program Files/RStudio/bin/rstudio.exe"<br />
<br />
# load rgrass package<br />
library(rgrass)<br />
<br />
# initialisation of GRASS in the North Carolina sample dataset<br />
initGRASS(gisBase = "C:/OSGeo4W64/apps/grass/grass",<br />
gisDbase = "C:/Users/marissa/grassdata/",<br />
location = "nc_spm_08_grass7", <br />
mapset = "user1", <br />
SG="elevation")<br />
</source><br />
<br />
Linux and Mac OSX users just need to start R or RStudio the usual way, load the rgrass package and initialize GRASS GIS with initGRASS() as shown below:<br />
<br />
<source lang="rsplus"><br />
# load rgrass package<br />
library(rgrass)<br />
# initialisation of GRASS in the North Carolina sample dataset<br />
initGRASS(gisBase = "/usr/local/grass", <br />
home = tempdir(), <br />
gisDbase = "/home/veroandreo/grassdata/",<br />
location = "nc_spm_08_grass7", <br />
mapset = "user1", <br />
SG="elevation")<br />
</source><br />
<br />
Note: the optional SG parameter is a 'SpatialGrid' object to define the ‘DEFAULT_WIND’ of the temporary location.<br />
<br />
<source lang="rsplus"><br />
# set computational region to default (optional)<br />
system("g.region -dp")<br />
# verify metadata<br />
gmeta()<br />
<br />
# get two raster maps into R space<br />
ncdata <- read_RAST(c("geology_30m", "elevation"), cat=c(TRUE, FALSE))<br />
<br />
# calculate object summaries<br />
summary(ncdata$geology_30m)<br />
CZfg_217 CZlg_262 CZig_270 CZbg_405 CZve_583 CZam_720 CZg_766 CZam_862 <br />
292 78 277 102 8 1 2 25 <br />
CZbg_910 Km_921 CZam_946 NA's <br />
18 5 2 1009790 <br />
</source><br />
<br />
== R in GRASS in batch mode ==<br />
<br />
Run the following script with<br />
<br />
<source lang="bash"><br />
R CMD BATCH batch.R<br />
</source><br />
<br />
<source lang="rsplus"><br />
library(rgrass)<br />
# initialisation of GRASS in the North Carolina sample dataset (example with a compiled version)<br />
initGRASS(gisBase = "/home/veroandreo/software/grass/dist.x86_64-pc-linux-gnu", <br />
home = tempdir(), <br />
gisDbase = "/home/veroandreo/grassdata/",<br />
location = "nc_spm_08_grass7", mapset = "user1", SG="elevation",<br />
override = TRUE)<br />
# set region to default<br />
system("g.region -dp")<br />
# verify<br />
gmeta()<br />
# read data into R<br />
ncdata <- read_RAST(c("geology_30m", "elevation"), cat=c(TRUE, FALSE))<br />
# summary of geology map<br />
summary(ncdata$geology_30m)<br />
proc.time()<br />
</source><br />
<br />
The result is (shorted here):<br />
<source lang="bash"><br />
cat batch.Rout<br />
</source> <br />
<br />
<source lang="rsplus"><br />
R version 4.0.2 (2020-06-22) -- "Taking Off Again"<br />
Copyright (C) 2020 The R Foundation for Statistical Computing<br />
Platform: x86_64-redhat-linux-gnu (64-bit)<br />
...<br />
> library(rgrass)<br />
Loading required package: XML<br />
GRASS GIS interface loaded with GRASS version: (GRASS not running)<br />
> # initialisation and the use of north carolina dataset<br />
> initGRASS(gisBase = "/home/veroandreo/software/grass/dist.x86_64-pc-linux-gnu", home = tempdir(), <br />
+ gisDbase = "/home/veroandreo/grassdata/",<br />
+ location = "nc_spm_08_grass7", mapset = "user1", SG="elevation",<br />
+ override = TRUE)<br />
gisdbase /home/veroandreo/grassdata/ <br />
location nc_spm_08_grass7 <br />
mapset user1 <br />
rows 13500 <br />
columns 15000 <br />
north 228500 <br />
south 215000 <br />
west 630000 <br />
east 645000 <br />
nsres 1 <br />
ewres 1 <br />
projection +proj=lcc +lat_1=36.16666666666666 +lat_2=34.33333333333334<br />
+lat_0=33.75 +lon_0=-79 +x_0=609601.22 +y_0=0 +no_defs +a=6378137<br />
+rf=298.257222101 +towgs84=0.000,0.000,0.000 +type=crs +to_meter=1 <br />
<br />
> system("g.region -dp")<br />
projection: 99 (Lambert Conformal Conic)<br />
zone: 0<br />
datum: nad83<br />
ellipsoid: a=6378137 es=0.006694380022900787<br />
north: 320000<br />
south: 10000<br />
west: 120000<br />
east: 935000<br />
nsres: 500<br />
ewres: 500<br />
rows: 620<br />
cols: 1630<br />
cells: 1010600<br />
> gmeta()<br />
gisdbase /home/veroandreo/grassdata/ <br />
location nc_spm_08_grass7 <br />
mapset user1 <br />
rows 620 <br />
columns 1630 <br />
north 320000 <br />
south 10000 <br />
...<br />
> ncdata <- read_RAST(c("geology_30m", "elevation"), cat=c(TRUE, FALSE))<br />
...<br />
> summary(ncdata$geology_30m)<br />
CZfg_217 CZlg_262 CZig_270 CZbg_405 CZve_583 CZam_720 CZg_766 CZam_862 <br />
292 78 277 102 8 1 2 25 <br />
CZbg_910 Km_921 CZam_946 NA's <br />
18 5 2 1009790 <br />
> proc.time()<br />
user system elapsed <br />
8.061 2.016 10.048<br />
</source><br />
<br />
== Troubleshooting ==<br />
<br />
=== Running out of disk space ===<br />
<br />
Linux: A common issue is that /tmp/ is used for temporary files albeit being often a small partition. To change that to a larger directory, you may '''add''' to your <tt>$HOME/.bashrc</tt> the entry:<br />
<br />
<source lang="bash"><br />
# change TMP directory of R (note: of course also another directory than suggested here is fine)<br />
mkdir -p $HOME/tmp<br />
export TMP=$HOME/tmp<br />
</source><br />
<br />
The drawback of this approach is that on modern Linux systems the /tmp/ is a fast RAM disk (based on tempfs) while HOME directories are often on slower spinning disks (unless you have a SSD drive). At least you no longer run out of disk space easily.<br />
<br />
[[Category:FAQ]]<br />
[[Category:Linking to other languages]]<br />
[[Category:R]]<br />
[[Category:Statistics]]</div>Veroandreohttps://grasswiki.osgeo.org/w/index.php?title=File:Ncdata.png&diff=26885File:Ncdata.png2023-04-19T20:41:09Z<p>Veroandreo: New plot using terra library</p>
<hr />
<div>== Summary ==<br />
New plot using terra library</div>Veroandreohttps://grasswiki.osgeo.org/w/index.php?title=R_statistics/rgrass&diff=26883R statistics/rgrass2023-04-19T20:34:36Z<p>Veroandreo: function updates and clean-up</p>
<hr />
<div>== Installation ==<br />
<br />
See [[R_statistics/Installation]]<br />
<br />
== Terminology ==<br />
<br />
See "Overview" in [[R_statistics]]<br />
<br />
== R within GRASS ==<br />
<br />
In this example, we will use '''R within a GRASS GIS session''', i.e. start R (or RStudio) from the GRASS GIS terminal or command line interface.<br />
<br />
=== Startup ===<br />
<br />
* First start a GRASS GIS session. Then, at the GRASS command line start ''R'' (for an 'rstudio' session, see below)<br />
: ''In this example we will use the [https://grass.osgeo.org/download/data/#NorthCarolinaDataset North Carolina sample dataset].''<br />
<br />
Reset the region settings to the defaults<br />
<source lang="bash"><br />
GRASS (nc_spm_08_grass7):~ > g.region -d<br />
</source><br />
<br />
Launch R from the GRASS prompt<br />
<source lang="bash"><br />
GRASS (nc_spm_08_grass7):~ > R<br />
</source><br />
<br />
Load the ''rgrass'' library:<br />
<source lang="rsplus"><br />
library(rgrass)<br />
</source><br />
<br />
Get the GRASS environment (mapset, region, map projection, etc.); you can display the metadata for your location by printing G:<br />
<source lang="rsplus"><br />
gmeta()<br />
gisdbase /home/mneteler/grassdata <br />
location nc_spm_08_grass7 <br />
mapset user1 <br />
rows 620 <br />
columns 1630 <br />
north 320000 <br />
south 10000 <br />
west 120000 <br />
east 935000 <br />
nsres 500 <br />
ewres 500 <br />
projection:<br />
PROJCRS["NAD83(HARN) / North Carolina",<br />
BASEGEOGCRS["NAD83(HARN)",<br />
DATUM["NAD83 (High Accuracy Reference Network)",<br />
ELLIPSOID["GRS 1980",6378137,298.257222101,<br />
LENGTHUNIT["metre",1]]],<br />
PRIMEM["Greenwich",0,<br />
ANGLEUNIT["degree",0.0174532925199433]],<br />
ID["EPSG",4152]],<br />
CONVERSION["SPCS83 North Carolina zone (meters)",<br />
METHOD["Lambert Conic Conformal (2SP)",<br />
ID["EPSG",9802]],<br />
PARAMETER["Latitude of false origin",33.75,<br />
ANGLEUNIT["degree",0.0174532925199433],<br />
ID["EPSG",8821]],<br />
PARAMETER["Longitude of false origin",-79,<br />
ANGLEUNIT["degree",0.0174532925199433],<br />
ID["EPSG",8822]],<br />
PARAMETER["Latitude of 1st standard parallel",36.1666666666667,<br />
ANGLEUNIT["degree",0.0174532925199433],<br />
ID["EPSG",8823]],<br />
PARAMETER["Latitude of 2nd standard parallel",34.3333333333333,<br />
ANGLEUNIT["degree",0.0174532925199433],<br />
ID["EPSG",8824]],<br />
PARAMETER["Easting at false origin",609601.22,<br />
LENGTHUNIT["metre",1],<br />
ID["EPSG",8826]],<br />
PARAMETER["Northing at false origin",0,<br />
LENGTHUNIT["metre",1],<br />
ID["EPSG",8827]]],<br />
CS[Cartesian,2],<br />
AXIS["easting (X)",east,<br />
ORDER[1],<br />
LENGTHUNIT["metre",1]],<br />
AXIS["northing (Y)",north,<br />
ORDER[2],<br />
LENGTHUNIT["metre",1]],<br />
USAGE[<br />
SCOPE["Engineering survey, topographic mapping."],<br />
AREA["United States (USA) - North Carolina - counties of Alamance; Alexander; Alleghany; Anson; Ashe; Avery; Beaufort; Bertie; Bladen; Brunswick; Buncombe; Burke; Cabarrus; Caldwell; Camden; Carteret; Caswell; Catawba; Chatham; Cherokee; Chowan; Clay; Cleveland; Columbus; Craven; Cumberland; Currituck; Dare; Davidson; Davie; Duplin; Durham; Edgecombe; Forsyth; Franklin; Gaston; Gates; Graham; Granville; Greene; Guilford; Halifax; Harnett; Haywood; Henderson; Hertford; Hoke; Hyde; Iredell; Jackson; Johnston; Jones; Lee; Lenoir; Lincoln; Macon; Madison; Martin; McDowell; Mecklenburg; Mitchell; Montgomery; Moore; Nash; New Hanover; Northampton; Onslow; Orange; Pamlico; Pasquotank; Pender; Perquimans; Person; Pitt; Polk; Randolph; Richmond; Robeson; Rockingham; Rowan; Rutherford; Sampson; Scotland; Stanly; Stokes; Surry; Swain; Transylvania; Tyrrell; Union; Vance; Wake; Warren; Washington; Watauga; Wayne; Wilkes; Wilson; Yadkin; Yancey."],<br />
BBOX[33.83,-84.33,36.59,-75.38]],<br />
ID["EPSG",3358]]<br />
</source><br />
<br />
=== Listing of existing maps ===<br />
<br />
List available vector maps:<br />
<source lang="rsplus"><br />
execGRASS("g.list", parameters = list(type = "vector"))<br />
</source><br />
<br />
List selected vector maps (wildcard):<br />
<source lang="rsplus"><br />
execGRASS("g.list", parameters = list(type = "vector", pattern = "precip*"))<br />
precip<br />
precip_30ynormals<br />
precip_30ynormals_3d<br />
</source><br />
<br />
Save selected vector maps into R vector:<br />
<source lang="rsplus"><br />
my_vmaps <- execGRASS("g.list", parameters = list(type = "vector", pattern = "precip*"))<br />
attributes(my_vmaps)<br />
attributes(my_vmaps)$resOut<br />
[1] "precip" "precip_30ynormals" "precip_30ynormals_3d"<br />
</source><br />
<br />
List available raster maps:<br />
<source lang="rsplus"><br />
execGRASS("g.list", parameters = list(type = "raster"))<br />
</source><br />
<br />
List selected raster maps (wildcard):<br />
<source lang="rsplus"><br />
execGRASS("g.list", parameters = list(type = "raster", pattern = "lsat7_2002*"))<br />
lsat7_2002_10<br />
lsat7_2002_20<br />
lsat7_2002_30<br />
lsat7_2002_40<br />
lsat7_2002_50<br />
lsat7_2002_61<br />
lsat7_2002_62<br />
lsat7_2002_70<br />
lsat7_2002_80<br />
</source><br />
<br />
=== Reading in data from GRASS ===<br />
<br />
==== Example 1: raster maps ====<br />
<br />
Manual page: [https://search.r-project.org/CRAN/refmans/rgrass/html/readRAST.html read_RAST()]<br />
<br />
Read in two GRASS raster maps, "geology_30m" and "elevation", from the North Carolina sample data location into the R current session as a new object "ncdata". This object is a SpatRaster layer from terra package:<br />
<source lang="rsplus"><br />
ncdata <- read_RAST(c("geology_30m", "elevation"))<br />
</source><br />
<br />
We can verify the new R object:<br />
<source lang="rsplus"><br />
ncdata<br />
class : SpatRaster <br />
dimensions : 475, 527, 2 (nrow, ncol, nlyr)<br />
resolution : 28.5, 28.5 (x, y)<br />
extent : 629992.5, 645012, 214975.5, 228513 (xmin, xmax, ymin, ymax)<br />
coord. ref. : +proj=lcc +lat_0=33.75 +lon_0=-79 +lat_1=36.1666666666667 +lat_2=34.3333333333333 +x_0=609601.22 +y_0=0 +ellps=GRS80 +units=m +no_defs <br />
sources : file1da127d162fb1.grd <br />
file1da126d0e750a.grd <br />
names : geology_30m, elevation <br />
min values : 217, 55.88855 <br />
max values : 948, 156.22725 <br />
</source><br />
<br />
Now, let's plot one of the raster layers within the SpatRaster object. Note that we use the terra package plot function:<br />
<source lang="rsplus"><br />
terra::plot(ncdata$elevation)<br />
</source><br />
<br />
Add a title to the plot:<br />
<source lang="rsplus"><br />
title("North Carolina elevation")<br />
</source><br />
<br />
[[Image:ncdata.png|center]]<br />
<br />
In addition, we can show what is going on inside the objects read into R:<br />
<source lang="rsplus"><br />
terra::summary(ncdata)<br />
geology_30m elevation <br />
Min. :217.0 Min. : 56.01 <br />
1st Qu.:217.0 1st Qu.: 94.77 <br />
Median :270.0 Median :108.91 <br />
Mean :311.2 Mean :110.38 <br />
3rd Qu.:270.0 3rd Qu.:126.80 <br />
Max. :948.0 Max. :156.23 <br />
NA's :334 NA's :334 <br />
</source><br />
<br />
==== Example 2: single raster map ====<br />
<br />
Here an example for a single raster map transfer from GRASS GIS to R:<br />
<br />
<source lang="rsplus"><br />
library(rgrass)<br />
execGRASS("g.region", raster = "elevation", flags = "p")<br />
ncdata <- read_RAST("elevation")<br />
terra::summary(ncdata)<br />
terra::plot(ncdata)<br />
</source><br />
<br />
==== Example 3: vector maps ====<br />
<br />
Here an example for a single vector map transfer from GRASS GIS to R. In this case, vector maps from GRASS will be converted into SpatVector objects from the terra package in R:<br />
<br />
<source lang="rsplus"><br />
# needed prerequisite<br />
library(rgrass)<br />
<br />
execGRASS("v.info", map="schools_wake", layer="1")<br />
vInfo("schools_wake")<br />
myschools <- read_VECT("schools_wake")<br />
print(terra::summary(myschools))<br />
terra::plot(myschools)<br />
</source><br />
<br />
=== Example 4: Summarizing data ===<br />
<br />
We can create a table of cell counts:<br />
<source lang="rsplus"><br />
table(ncdata$geology_30m)<br />
</source><br />
{| class="wikitable" border="1"<br />
!CZfg_217 <br />
!CZlg_262 <br />
!CZig_270 <br />
!CZbg_405 <br />
!CZve_583 <br />
!CZam_720 <br />
!CZg_766 <br />
!CZam_862 <br />
!CZbg_910 <br />
!Km_921 <br />
!CZbg_945 <br />
!CZam_946 <br />
!CZam_948<br />
|-<br />
|70381<br />
|19287<br />
|66861 <br />
|24561 <br />
|2089 <br />
|467 <br />
|691 <br />
|6017 <br />
|4351<br />
|1211 <br />
|1 <br />
|398 <br />
|85<br />
|}<br />
<br />
And compare with the equivalent GRASS module:<br />
<source lang="rsplus"><br />
execGRASS("r.stats", flags=c("c", "l"), parameters=list(input="geology_30m"), ignore.stderr=TRUE)<br />
</source><br />
<pre><br />
217 CZfg 70381<br />
262 CZlg 19287<br />
270 CZig 66861<br />
405 CZbg 24561<br />
583 CZve 2089<br />
720 CZam 467<br />
766 CZg 691<br />
862 CZam 6017<br />
910 CZbg 4351<br />
921 Km 1211<br />
945 CZbg 1<br />
946 CZam 398<br />
948 CZam 85<br />
</pre><br />
<br />
Create a box plot of geologic types at different elevations:<br />
<source lang="rsplus"><br />
boxplot(ncdata$elevation ~ ncdata$geology_30m, medlwd = 1)<br />
</source><br />
<br />
[[Image:boxplot_geo.png|center]]<br />
<br />
=== Example 5: Querying maps ===<br />
<br />
Sometimes you may want to query GRASS GIS maps from your R session.<br />
<br />
As an example, here the transfer of raster pixel values at the position of vector points:<br />
<br />
<source lang="rsplus"><br />
# set the computational region first to the raster map:<br />
execGRASS("g.region", raster = "elev_state_500m", flags = "p")<br />
<br />
# query raster map at vector points, transfer result into R<br />
goutput <- execGRASS("r.what", map="elev_state_500m", points="geodetic_pts", separator=",", intern=TRUE)<br />
str(goutput)<br />
chr [1:29939] "571530.81289275,265739.968425953,,187.8082200648" ...<br />
<br />
# parse it<br />
con <- textConnection(goutput)<br />
go1 <- read.csv(con, header=FALSE)<br />
str(go1)<br />
'data.frame': 29939 obs. of 4 variables:<br />
$ V1: num 571531 571359 571976 572391 573011 ...<br />
$ V2: num 265740 265987 267049 267513 269615 ...<br />
$ V3: logi NA NA NA NA NA NA ...<br />
$ V4: Factor w/ 22738 levels "-0.0048115728",..: 6859 6642 6749 6411 6356 6904 7506 7224 6908 7167 ...<br />
summary(go1)<br />
V1 V2 V3 V4 <br />
Min. :121862 Min. : 7991 Mode:logical 0 : 723 <br />
1st Qu.:462706 1st Qu.:162508 NA's:29939 * : 293 <br />
Median :610328 Median :204502 0.3048 : 47 <br />
Mean :588514 Mean :200038 0.6096 : 44 <br />
3rd Qu.:717610 3rd Qu.:247633 1.524 : 42 <br />
Max. :946743 Max. :327186 0.9144 : 23 <br />
(Other):28767 <br />
</source><br />
<br />
=== Exporting data back to GRASS ===<br />
<br />
Finally, a SpatialGridDataFrame object is written back to a GRASS raster map:<br />
<br />
First prepare some data: (square root of elevation)<br />
<source lang="rsplus"><br />
ncdata$sqdem <- sqrt(ncdata$elevation)<br />
</source><br />
<br />
Export data from ''R'' back into a GRASS raster map:<br />
<source lang="rsplus"><br />
writeRAST(ncdata, "sqdemNC", zcol="sqdem", ignore.stderr=TRUE)<br />
</source><br />
<br />
Check that it imported into GRASS ok:<br />
<source lang="rsplus"><br />
execGRASS("r.info", parameters=list(map="sqdemNC"))<br />
</source><br />
<br />
<pre><br />
+----------------------------------------------------------------------------+<br />
| Map: sqdemNC Date: Sun Jul 19 13:06:34 2015 |<br />
| Mapset: PERMANENT Login of Creator: veroandreo |<br />
| Location: nc_spm_08_grass7 |<br />
| DataBase: /home/veroandreo/grassdata |<br />
| Title: ( sqdemNC ) |<br />
| Timestamp: none |<br />
|----------------------------------------------------------------------------|<br />
| |<br />
| Type of Map: raster Number of Categories: 0 |<br />
| Data Type: DCELL |<br />
| Rows: 491 |<br />
| Columns: 400 |<br />
| Total Cells: 196400 |<br />
| Projection: Lambert Conformal Conic |<br />
| N: 228500 S: 215000.0002 Res: 27.49490794 |<br />
| E: 645000 W: 630000 Res: 37.5 |<br />
| Range of data: min = 7.47818253045085 max = 12.5000787351036 |<br />
| |<br />
| Data Description: |<br />
| generated by r.in.bin |<br />
| |<br />
| Comments: |<br />
| |<br />
+----------------------------------------------------------------------------+<br />
</pre><br />
<br />
=== Using RStudio in a GRASS GIS session ===<br />
<br />
If you are most used to run R through RStudio, but still want to have all GRASS data available for performing<br />
any analyses without loosing the possibility of still using GRASS command line, you can run:<br />
<br />
<source lang="bash"><br />
GRASS> rstudio &<br />
</source><br />
<br />
or, if you already are working on a certain RStudio project:<br />
<br />
<source lang="bash"><br />
GRASS> rstudio /path/to/project/folder/ &<br />
</source><br />
<br />
Then, you load rgrass library in your RStudio project<br />
<source lang="rsplus"><br />
library(rgrass)<br />
</source><br />
<br />
and you are ready to go.<br />
<br />
[[File:Grass7_rstudio.png|thumb|500px|center|RStudio used in GRASS GIS session]]<br />
<br />
== GRASS within R ==<br />
<br />
Using '''GRASS GIS within a R session''', i.e. you connect to a GRASS GIS location/mapset from within R (or RStudio).<br />
<br />
=== Startup ===<br />
<br />
In the first place, find out the path to the GRASS GIS library. This can be easily done with the following command (still outside of R; or through a system() call inside of R):<br />
<br />
<source lang="bash"><br />
# OSGeo4W, Linux, Mac OSX users:<br />
grass --config path<br />
</source><br />
<br />
It may report something like:<br />
<source lang="bash"><br />
# OSGeo4W users:<br />
C:\OSGeo4W64\apps\grass\grass<br />
<br />
# Linux, Mac OSX users:<br />
/usr/local/grass<br />
</source><br />
<br />
To call GRASS GIS functionality from R, start R and use the initGRASS() function to define the GRASS settings. If GRASS GIS was <br />
installed through OSGeo4W, first start the OSGeo4W Shell. Note that it may start in C: or a directory where the user does not have<br />
writing permission. Before calling R or RStudio, first change to a directory where you are sure you have writing permission.<br />
<br />
<source lang="rsplus"><br />
## MS-Windows users (example for an OSGeo4W 64bit installation)<br />
# change to a directory with writing permission<br />
C:\>d:<br />
D:\>cd temp<br />
D:\temp>cd testR<br />
<br />
# start R within this directory:<br />
D:\temp\testR>R<br />
<br />
# to start RStudio from OSGeo4W Shell, run: "C:/Program Files/RStudio/bin/rstudio.exe"<br />
<br />
# load rgrass package<br />
library(rgrass)<br />
<br />
# initialisation of GRASS in the North Carolina sample dataset<br />
initGRASS(gisBase = "C:/OSGeo4W64/apps/grass/grass",<br />
gisDbase = "C:/Users/marissa/grassdata/",<br />
location = "nc_spm_08_grass7", <br />
mapset = "user1", <br />
SG="elevation")<br />
</source><br />
<br />
Linux and Mac OSX users just need to start R or RStudio the usual way, load the rgrass package and initialize GRASS GIS with initGRASS() as shown below:<br />
<br />
<source lang="rsplus"><br />
# load rgrass package<br />
library(rgrass)<br />
# initialisation of GRASS in the North Carolina sample dataset<br />
initGRASS(gisBase = "/usr/local/grass", <br />
home = tempdir(), <br />
gisDbase = "/home/veroandreo/grassdata/",<br />
location = "nc_spm_08_grass7", <br />
mapset = "user1", <br />
SG="elevation")<br />
</source><br />
<br />
Note: the optional SG parameter is a 'SpatialGrid' object to define the ‘DEFAULT_WIND’ of the temporary location.<br />
<br />
<source lang="rsplus"><br />
# set computational region to default (optional)<br />
system("g.region -dp")<br />
# verify metadata<br />
gmeta()<br />
<br />
# get two raster maps into R space<br />
ncdata <- read_RAST(c("geology_30m", "elevation"), cat=c(TRUE, FALSE))<br />
<br />
# calculate object summaries<br />
summary(ncdata$geology_30m)<br />
CZfg_217 CZlg_262 CZig_270 CZbg_405 CZve_583 CZam_720 CZg_766 CZam_862 <br />
292 78 277 102 8 1 2 25 <br />
CZbg_910 Km_921 CZam_946 NA's <br />
18 5 2 1009790 <br />
</source><br />
<br />
== R in GRASS in batch mode ==<br />
<br />
Run the following script with<br />
<br />
<source lang="bash"><br />
R CMD BATCH batch.R<br />
</source><br />
<br />
<source lang="rsplus"><br />
library(rgrass)<br />
# initialisation of GRASS in the North Carolina sample dataset (example with a compiled version)<br />
initGRASS(gisBase = "/home/veroandreo/software/grass/dist.x86_64-pc-linux-gnu", <br />
home = tempdir(), <br />
gisDbase = "/home/veroandreo/grassdata/",<br />
location = "nc_spm_08_grass7", mapset = "user1", SG="elevation",<br />
override = TRUE)<br />
# set region to default<br />
system("g.region -dp")<br />
# verify<br />
gmeta()<br />
# read data into R<br />
ncdata <- read_RAST(c("geology_30m", "elevation"), cat=c(TRUE, FALSE))<br />
# summary of geology map<br />
summary(ncdata$geology_30m)<br />
proc.time()<br />
</source><br />
<br />
The result is (shorted here):<br />
<source lang="bash"><br />
cat batch.Rout<br />
</source> <br />
<br />
<source lang="rsplus"><br />
R version 4.0.2 (2020-06-22) -- "Taking Off Again"<br />
Copyright (C) 2020 The R Foundation for Statistical Computing<br />
Platform: x86_64-redhat-linux-gnu (64-bit)<br />
...<br />
> library(rgrass)<br />
Loading required package: XML<br />
GRASS GIS interface loaded with GRASS version: (GRASS not running)<br />
> # initialisation and the use of north carolina dataset<br />
> initGRASS(gisBase = "/home/veroandreo/software/grass/dist.x86_64-pc-linux-gnu", home = tempdir(), <br />
+ gisDbase = "/home/veroandreo/grassdata/",<br />
+ location = "nc_spm_08_grass7", mapset = "user1", SG="elevation",<br />
+ override = TRUE)<br />
gisdbase /home/veroandreo/grassdata/ <br />
location nc_spm_08_grass7 <br />
mapset user1 <br />
rows 13500 <br />
columns 15000 <br />
north 228500 <br />
south 215000 <br />
west 630000 <br />
east 645000 <br />
nsres 1 <br />
ewres 1 <br />
projection +proj=lcc +lat_1=36.16666666666666 +lat_2=34.33333333333334<br />
+lat_0=33.75 +lon_0=-79 +x_0=609601.22 +y_0=0 +no_defs +a=6378137<br />
+rf=298.257222101 +towgs84=0.000,0.000,0.000 +type=crs +to_meter=1 <br />
<br />
> system("g.region -dp")<br />
projection: 99 (Lambert Conformal Conic)<br />
zone: 0<br />
datum: nad83<br />
ellipsoid: a=6378137 es=0.006694380022900787<br />
north: 320000<br />
south: 10000<br />
west: 120000<br />
east: 935000<br />
nsres: 500<br />
ewres: 500<br />
rows: 620<br />
cols: 1630<br />
cells: 1010600<br />
> gmeta()<br />
gisdbase /home/veroandreo/grassdata/ <br />
location nc_spm_08_grass7 <br />
mapset user1 <br />
rows 620 <br />
columns 1630 <br />
north 320000 <br />
south 10000 <br />
...<br />
> ncdata <- read_RAST(c("geology_30m", "elevation"), cat=c(TRUE, FALSE))<br />
...<br />
> summary(ncdata$geology_30m)<br />
CZfg_217 CZlg_262 CZig_270 CZbg_405 CZve_583 CZam_720 CZg_766 CZam_862 <br />
292 78 277 102 8 1 2 25 <br />
CZbg_910 Km_921 CZam_946 NA's <br />
18 5 2 1009790 <br />
> proc.time()<br />
user system elapsed <br />
8.061 2.016 10.048<br />
</source><br />
<br />
== Troubleshooting ==<br />
<br />
=== Running out of disk space ===<br />
<br />
Linux: A common issue is that /tmp/ is used for temporary files albeit being often a small partition. To change that to a larger directory, you may '''add''' to your <tt>$HOME/.bashrc</tt> the entry:<br />
<br />
<source lang="bash"><br />
# change TMP directory of R (note: of course also another directory than suggested here is fine)<br />
mkdir -p $HOME/tmp<br />
export TMP=$HOME/tmp<br />
</source><br />
<br />
The drawback of this approach is that on modern Linux systems the /tmp/ is a fast RAM disk (based on tempfs) while HOME directories are often on slower spinning disks (unless you have a SSD drive). At least you no longer run out of disk space easily.<br />
<br />
[[Category:FAQ]]<br />
[[Category:Linking to other languages]]<br />
[[Category:R]]<br />
[[Category:Statistics]]</div>Veroandreohttps://grasswiki.osgeo.org/w/index.php?title=R_statistics&diff=26882R statistics2023-04-19T19:58:20Z<p>Veroandreo: </p>
<hr />
<div>{{toc|right}}<br />
<br />
=== Overview ===<br />
<br />
High quality statistical analyses in GRASS GIS are possible thanks to an interface to one of the most powerful statistical analysis packages around: '''''R''''' ([http://www.r-project.org/ https://www.r-project.org]). This R ←→ GRASS GIS interface is provided by the [https://cran.r-project.org/package=rgrass rgrass] ''R'' package. The possibility to directly interact with R strongly increases the statistical and geospatial analysis capabilities of GRASS GIS. See [https://cran.r-project.org/web/views/Spatial.html CRAN Task View: Analysis of Spatial Data] for an overview of the R packages and functions that can be used for reading, visualizing, and analyzing spatial data. <br />
<br />
R can be used in combination with GRASS GIS in different ways:<br />
<br />
* ''Running R 'on top of' GRASS'': which involves transferring GRASS data to R to run statistical functions on the imported data, and possibly write the results back to GRASS. GRASS raster and vector data can be imported in R using the [https://search.r-project.org/CRAN/refmans/rgrass/html/readVECT.html read_VECT()] and [https://search.r-project.org/CRAN/refmans/rgrass/html/readRAST.html read_RAST()] functions provided by [http://cran.r-project.org/web/packages/rgrass/ rgrass]. Similarly, results can be written back using the [https://search.r-project.org/CRAN/refmans/rgrass/html/readRAST.html write_RAST()] and [https://search.r-project.org/CRAN/refmans/rgrass/html/readVECT.html write_VECT()] functions. When we read GRASS maps into R, they become R objects stored in memory, more specifically terra objects, i.e., SpatRaster and SpatVector objects that can then be coerced to other types of R spatial objects.<br />
* ''Using R as a scripting language in GRASS'': GRASS functions can be run from R using the [https://search.r-project.org/CRAN/refmans/rgrass/html/execGRASS.html execGRASS()] function in the ''rgrass'' package. R scripting tools, such as powerful string-processing tools, can be used to 'glue' different functions and tools together.<br />
* ''Using GRASS GIS as a geospatial library in R'': GRASS GIS can be used to extend the geospatial capabilities of R by: (1) offering an extensive and robust set of geospatial tools, and (2) providing a way to work with very large (larger-than-memory) spatial data sets. See Using 'GRASS GIS functionality within an R session' below for more information.<br />
<br />
In practice, one will often combine different approaches, with scripts running GRASS functions, reading resulting maps into R for further analysis, modeling and visualization, and creating new layers in R that are imported back into GRASS.<br />
<br />
=== Current State ===<br />
<br />
R Windows binary packages distributed by the Comprehensive R Archive Network (CRAN) using OSGeo software (chiefly PROJ, GDAL and GEOS) use custom built binaries compatible with the build train used by R and are static linked; at present both 32-bit and 64-bit binaries are deployed. CRAN packages for macOS are also static linked to custom built binaries, again using the build train used by R. Static linkage is used to avoid having to deploy a package manager for external software on which R packages depend, since CRAN as a package manager already supports over 15000 packages with three binary versions (devel, release, old release) for Windows and macOS.<br />
<br />
=== Installation ===<br />
<br />
==== Installation of R core software ====<br />
<br />
(see also [[R statistics/Installation]])<br />
<br />
''Note: the ...-devel packages are needed if you want to install extra packages incl. '''rgrass''' on your computer.''<br />
<br />
Fedora:<br />
sudo dnf install R<br />
# further packages needed in order to locally compile "rgrass"<br />
sudo dnf install proj-devel proj-data gdal-devel sqlite-devel xml2 libxml2-devel udunits2-devel<br />
<br />
Ubuntu:<br />
sudo apt-get install r-base<br />
# further packages needed in order to locally compile "rgrass"<br />
sudo apt-get install proj-bin proj-data libproj-dev libgdal-dev libsqlite3-dev libxml2-dev r-base-dev<br />
<br />
==== Installation of the rgrass package ====<br />
To install the R package '''rgrass''' on newer versions of R, you simply start R and install the package directly with:<br />
<br />
<source lang="rsplus"><br />
install.packages("rgrass", dependencies = TRUE)<br />
</source><br />
<br />
This will install '''''rgrass''''' and all its dependencies. To use the package, you first need to load it:<br />
<br />
<source lang="rsplus"><br />
library(rgrass)<br />
</source><br />
<br />
If you are using Rstudio, you can install the rgrass package in the usual way (tool → packages). For further instructions and for troubleshooting, see [[R_statistics/Installation]].<br />
<br />
=== How to use ===<br />
<br />
==== Using R within a GRASS GIS session ====<br />
<br />
If you are primarily a GIS user who wants to run e.g., some statistical tests not available in GRASS, you probably want to run R from within a GRASS GIS session. To do so, first start GRASS GIS and then start R (or RStudio) from the GRASS GIS command line. For more information and examples, see [[R_statistics/rgrass]]. <br />
<br />
==== Using GRASS GIS functionality within an R session ====<br />
<br />
If you are primarily an R user who wants to take advantage of the geospatial functions in GRASS, you probably want to use GRASS GIS within an R session. To connect to a GRASS GIS database from within R (or Rstudio), see the instructions on [[R_statistics/rgrass]]. If you are a first time GRASS GIS user, you may want to check out the information for [https://grass.osgeo.org/learn/newcomers/ first time users].<br />
<br />
=== Examples ===<br />
<br />
* [https://grasswiki.osgeo.org/wiki/Temporal_data_processing/GRASS_R_raster_time_series_processing Temporal data processing wiki]; a tutorial about time series processing with GRASS GIS and R.<br />
* A short guide on how to [https://tutorials.ecodiv.earth/toc/from_grass_to_r.html get a GRASS function output in R].<br />
* [https://tutorials.ecodiv.earth/toc/grass-import-glcf.html Importing GLCF MODIS woody plant cover] in a GRASS GIS database using an R script.<br />
* [https://tutorials.ecodiv.earth/toc/grass-r-gbif.html Use R to obtain gbif data] and import it in a GRASS GIS database.<br />
* [https://veroandreo.github.io/grass_ncsu_2023/studio_index.html Using Satellite Data for Species Distribution Modeling with GRASS GIS and R]: Workshop at NCSU, April 2023. <br />
<br />
=== Getting help ===<br />
<br />
==== Manual pages ====<br />
If you are in R and have loaded the rgrass package, you can get help by typing:<br />
<br />
<source lang="rsplus"><br />
?rgrass<br />
</source><br />
<br />
Similarly, to get help for a specific function, e.g., for the function ''read_RAST()'', you type:<br />
<br />
<source lang="rsplus"><br />
?read_RAST<br />
</source><br />
<br />
You can also start the ''R'' help page in your browser:<br />
<br />
<source lang="rsplus"><br />
help.start()<br />
</source><br />
<br />
Now, to get the information about the package, select the '''Packages''' entry and then '''rgrass'''. <br />
<br />
==== Support from the community ====<br />
<br />
Primary support for ''R'' + GRASS and the ''rgrass'' package is through the [https://lists.osgeo.org/mailman/listinfo/grass-stats grass-stats] mailing list.<br />
<br />
=== Useful links ===<br />
<br />
==== R ====<br />
<br />
* [https://r-spatial.org/ R][https://r-spatial.org/ r-spatial main web page]<br />
* [https://cran.r-project.org/web/views/Spatial.html CRAN Task View: Analysis of Spatial Data]<br />
* [https://cengel.github.io/rspatial/2_spDataTypes.nb.html Introduction to Spatial Data Types in R]<br />
* [https://blog.dominodatalab.com/applied-spatial-data-science-with-r/ Applied Spatial Data Science with R] (blog post with examples)<br />
* [https://rsbivand.github.io/rgrass/articles/coerce.html Coercion between object formats] (rgrass vignette)<br />
* [https://rsbivand.github.io/rgrass/articles/use.html Use of GRASS interface] (rgrass vignette)<br />
* [https://rsbivand.github.io/foss4g_2022/modernizing_220822.html Modernizing the R-GRASS interface: confronting barn-raised OSGeo libraries and the evolving R.*spatial package ecosystem] (Workshop at FOSS4G 2022, Florence)<br />
<br />
==== Related ====<br />
<br />
* [https://rpy2.bitbucket.io/ Python interface to the R Programming Language]: can be used to run R in GRASS Python scripts.<br />
<br />
==== Articles & books ====<br />
<br />
* Neural Networks with GRASS and R [https://dx.doi.org/10.1016/j.ecolmodel.2006.03.015 DOI: 10.1016/j.ecolmodel.2006.03.015]<br />
* [http://www.asdar-book.org/ Applied Spatial Data Analysis with R]. Roger S. Bivand, Edzer Pebesma and V. Gómez-Rubio. UseR! Series, Springer. 2nd ed. 2013, xviii+405 pp., Softcover. ISBN: 978-1-4614-7617-7<br />
* [https://www.grassbook.org/ GRASS Book], see last chapter<br />
* [https://www.osgeo.org/journal OSGeo Journal] vol. 1 May 2007 (R. Bivand. Using the R— GRASS interface. ''OSGeo Journal'', 1:31-33, May 2007. ISSN 1614-8746).<br />
* [https://grass.osgeo.org/newsletter/grassnews3.html GRASS News vol.3], June 2005 (R. Bivand. Interfacing GRASS 6 and R. ''GRASS Newsletter'', 3:11-16, June 2005. ISSN 1614-8746)<br />
<br />
==== Older (but still useful) links ====<br />
<br />
* [https://web.archive.org/web/20090623093535/http://grass.osgeo.org/statsgrass/grass_geostats.html Using GRASS GIS 6 and R]<br />
* [http://grassold.osgeo.org/statsgrass/r_and_dbms.html Connecting R to RDBMS]<br />
* R. Bivand, 2007: [http://spatial.nhh.no/R/etc/FBK07 Interfacing R and OSGeo projects: status and perspectives]: Presentation with slides and scripts.<br />
* M. Neteler and M. Metz, 2011: ''Introduction to GRASS GIS''. GEOSTAT 2011 Landau. [http://geostat-course.org/Topic_NetelerMetz_2011 Download workshop material] (includes a R session)<br />
<br />
[[Category:Installation]]<br />
[[Category:FAQ]]<br />
[[Category:Linking to other languages]]<br />
[[Category:R]]<br />
[[Category:Statistics]]</div>Veroandreohttps://grasswiki.osgeo.org/w/index.php?title=R_statistics&diff=26879R statistics2023-04-19T19:11:26Z<p>Veroandreo: fix function names, add relevant links and general clean-up</p>
<hr />
<div>{{toc|right}}<br />
<br />
=== Overview ===<br />
<br />
High quality statistical analyses in GRASS GIS are possible thanks to an interface to one of the most powerful statistical analysis packages around: '''''R''''' ([http://www.r-project.org/ https://www.r-project.org]). This R ←→ GRASS GIS interface is provided by the [https://cran.r-project.org/package=rgrass rgrass] ''R'' package. The possibility to directly interact with R strongly increases the statistical and geospatial analysis capabilities of GRASS GIS. See [https://cran.r-project.org/web/views/Spatial.html CRAN Task View: Analysis of Spatial Data] for an overview of the R packages and functions that can be used for reading, visualizing, and analyzing spatial data. <br />
<br />
R can be used in combination with GRASS GIS in different ways:<br />
<br />
* ''Running R 'on top of' GRASS'': which involves transferring GRASS data to R to run statistical functions on the imported data, and possibly write the results back to GRASS. GRASS raster and vector data can be imported in R using the [https://search.r-project.org/CRAN/refmans/rgrass/html/readVECT.html read_VECT()] and [https://search.r-project.org/CRAN/refmans/rgrass/html/readRAST.html read_RAST()] functions provided by [http://cran.r-project.org/web/packages/rgrass/ rgrass]. Similarly, results can be written back using the [https://search.r-project.org/CRAN/refmans/rgrass/html/readRAST.html write_RAST()] and [https://search.r-project.org/CRAN/refmans/rgrass/html/readVECT.html write_VECT()] functions. When we read GRASS maps into R, they become R objects stored in memory, more specifically terra objects, i.e., SpatRaster and SpatVector objects that can then be coerced to other types of R spatial objects.<br />
* ''Using R as a scripting language in GRASS'': GRASS functions can be run from R using the [https://search.r-project.org/CRAN/refmans/rgrass/html/execGRASS.html execGRASS()] function in the ''rgrass'' package. R scripting tools, such as powerful string-processing tools, can be used to 'glue' different functions and tools together.<br />
* ''Using GRASS GIS as a geospatial library in R'': GRASS GIS can be used to extend the geospatial capabilities of R by: (1) offering an extensive and robust set of geospatial tools, and (2) providing a way to work with very large (larger-than-memory) spatial data sets. See Using 'GRASS GIS functionality within an R session' below for more information.<br />
<br />
In practice, one will often combine different approaches, with scripts running GRASS functions, reading resulting maps into R for further analysis, modeling and visualization, and creating new layers in R that are imported back into GRASS.<br />
<br />
=== Current State ===<br />
<br />
R Windows binary packages distributed by the Comprehensive R Archive Network (CRAN) using OSGeo software (chiefly PROJ, GDAL and GEOS) use custom built binaries compatible with the build train used by R and are static linked; at present both 32-bit and 64-bit binaries are deployed. CRAN packages for macOS are also static linked to custom built binaries, again using the build train used by R. Static linkage is used to avoid having to deploy a package manager for external software on which R packages depend, since CRAN as a package manager already supports over 15000 packages with three binary versions (devel, release, old release) for Windows and macOS.<br />
<br />
=== Installation ===<br />
<br />
==== Installation of R core software ====<br />
<br />
(see also [[R statistics/Installation]])<br />
<br />
''Note: the ...-devel packages are needed if you want to install extra packages incl. '''rgrass''' on your computer.''<br />
<br />
Fedora:<br />
sudo dnf install R<br />
# further packages needed in order to locally compile "rgrass"<br />
sudo dnf install proj-devel proj-data gdal-devel sqlite-devel xml2 libxml2-devel udunits2-devel<br />
<br />
Ubuntu:<br />
sudo apt-get install r-base<br />
# further packages needed in order to locally compile "rgrass"<br />
sudo apt-get install proj-bin proj-data libproj-dev libgdal-dev libsqlite3-dev libxml2-dev r-base-dev<br />
<br />
==== Installation of the rgrass package ====<br />
To install the R package '''rgrass''' on newer versions of R, you simply start R and install the package directly with:<br />
<br />
<source lang="rsplus"><br />
install.packages("rgrass", dependencies = TRUE)<br />
</source><br />
<br />
This will install '''''rgrass''''' and all its dependencies. To use the package, you first need to load it:<br />
<br />
<source lang="rsplus"><br />
library("rgrass")<br />
</source><br />
<br />
If you are using Rstudio, you can install the rgrass package in the usual way (tool → packages). For further instructions and for troubleshooting, see [[R_statistics/Installation]].<br />
<br />
=== How to use ===<br />
<br />
==== Using R within a GRASS GIS session ====<br />
<br />
If you are primarily a GIS user who wants to run e.g., some statistical tests not available in GRASS, you probably want to run R from within a GRASS GIS session. To do so, first start GRASS GIS and then start R (or RStudio) from the GRASS GIS command line. For more information and examples, see [[R_statistics/rgrass]]. <br />
<br />
==== Using GRASS GIS functionality within an R session ====<br />
<br />
If you are primarily an R user who wants to take advantage of the geospatial functions in GRASS, you probably want to use GRASS GIS within an R session. To connect to a GRASS GIS database from within R (or Rstudio), see the instructions on [[R_statistics/rgrass]]. If you are a first time GRASS GIS user, you may want to check out the information for [https://grass.osgeo.org/learn/newcomers/ first time users].<br />
<br />
=== Examples ===<br />
<br />
* [https://grasswiki.osgeo.org/wiki/Temporal_data_processing/GRASS_R_raster_time_series_processing Temporal data processing wiki]; a tutorial about time series processing with GRASS GIS and R.<br />
* A short guide on how to [https://tutorials.ecodiv.earth/toc/from_grass_to_r.html get a GRASS function output in R].<br />
* [https://tutorials.ecodiv.earth/toc/grass-import-glcf.html Importing GLCF MODIS woody plant cover] in a GRASS GIS database using an R script.<br />
* [https://tutorials.ecodiv.earth/toc/grass-r-gbif.html Use R to obtain gbif data] and import it in a GRASS GIS database.<br />
* [https://veroandreo.github.io/grass_ncsu_2023/studio_index.html Using Satellite Data for Species Distribution Modeling with GRASS GIS and R]: Workshop at NCSU, April 2023. <br />
<br />
=== Getting help ===<br />
<br />
==== Manual pages ====<br />
If you are in R and have loaded the rgrass package, you can get help by typing:<br />
<br />
<source lang="rsplus"><br />
?rgrass<br />
</source><br />
<br />
Similarly, to get help for a specific function, e.g., for the function ''read_RAST()'', you type:<br />
<br />
<source lang="rsplus"><br />
?read_RAST<br />
</source><br />
<br />
You can also start the ''R'' help page in your browser:<br />
<br />
<source lang="rsplus"><br />
help.start()<br />
</source><br />
<br />
Now, to get the information about the package, select the '''Packages''' entry and then '''rgrass'''. <br />
<br />
==== Support from the community ====<br />
<br />
Primary support for ''R'' + GRASS and the ''rgrass'' package is through the [https://lists.osgeo.org/mailman/listinfo/grass-stats grass-stats] mailing list.<br />
<br />
=== Useful links ===<br />
<br />
==== R ====<br />
<br />
* [https://r-spatial.org/ R][https://r-spatial.org/ r-spatial main web page]<br />
* [https://cran.r-project.org/web/views/Spatial.html CRAN Task View: Analysis of Spatial Data]<br />
* [https://cengel.github.io/rspatial/2_spDataTypes.nb.html Introduction to Spatial Data Types in R]<br />
* [https://blog.dominodatalab.com/applied-spatial-data-science-with-r/ Applied Spatial Data Science with R] (blog post with examples)<br />
* [https://rsbivand.github.io/rgrass/articles/coerce.html Coercion between object formats] (rgrass vignette)<br />
* [https://rsbivand.github.io/rgrass/articles/use.html Use of GRASS interface] (rgrass vignette)<br />
* [https://rsbivand.github.io/foss4g_2022/modernizing_220822.html Modernizing the R-GRASS interface: confronting barn-raised OSGeo libraries and the evolving R.*spatial package ecosystem] (Workshop at FOSS4G 2022, Florence)<br />
<br />
==== Related ====<br />
<br />
* [https://rpy2.bitbucket.io/ Python interface to the R Programming Language]: can be used to run R in GRASS Python scripts.<br />
<br />
==== Articles & books ====<br />
<br />
* Neural Networks with GRASS and R [https://dx.doi.org/10.1016/j.ecolmodel.2006.03.015 DOI: 10.1016/j.ecolmodel.2006.03.015]<br />
* [http://www.asdar-book.org/ Applied Spatial Data Analysis with R]. Roger S. Bivand, Edzer Pebesma and V. Gómez-Rubio. UseR! Series, Springer. 2nd ed. 2013, xviii+405 pp., Softcover. ISBN: 978-1-4614-7617-7<br />
* [https://www.grassbook.org/ GRASS Book], see last chapter<br />
* [https://www.osgeo.org/journal OSGeo Journal] vol. 1 May 2007 (R. Bivand. Using the R— GRASS interface. ''OSGeo Journal'', 1:31-33, May 2007. ISSN 1614-8746).<br />
* [https://grass.osgeo.org/newsletter/grassnews3.html GRASS News vol.3], June 2005 (R. Bivand. Interfacing GRASS 6 and R. ''GRASS Newsletter'', 3:11-16, June 2005. ISSN 1614-8746)<br />
<br />
==== Older (but still useful) links ====<br />
<br />
* [https://web.archive.org/web/20090623093535/http://grass.osgeo.org/statsgrass/grass_geostats.html Using GRASS GIS 6 and R]<br />
* [http://grassold.osgeo.org/statsgrass/r_and_dbms.html Connecting R to RDBMS]<br />
* R. Bivand, 2007: [http://spatial.nhh.no/R/etc/FBK07 Interfacing R and OSGeo projects: status and perspectives]: Presentation with slides and scripts.<br />
* M. Neteler and M. Metz, 2011: ''Introduction to GRASS GIS''. GEOSTAT 2011 Landau. [http://geostat-course.org/Topic_NetelerMetz_2011 Download workshop material] (includes a R session)<br />
<br />
[[Category:Installation]]<br />
[[Category:FAQ]]<br />
[[Category:Linking to other languages]]<br />
[[Category:R]]<br />
[[Category:Statistics]]</div>Veroandreohttps://grasswiki.osgeo.org/w/index.php?title=R_statistics&diff=26878R statistics2023-04-19T18:55:53Z<p>Veroandreo: fix function names and clean-up</p>
<hr />
<div>{{toc|right}}<br />
<br />
=== Overview ===<br />
<br />
High quality statistical analyses in GRASS GIS are possible thanks to an interface to one of the most powerful statistical analysis packages around: '''''R''''' ([http://www.r-project.org/ https://www.r-project.org]). This R ←→ GRASS GIS interface is provided by the [https://cran.r-project.org/package=rgrass rgrass] ''R'' package. The possibility to directly interact with R strongly increases the statistical and geospatial analysis capabilities of GRASS GIS. See [https://cran.r-project.org/web/views/Spatial.html CRAN Task View: Analysis of Spatial Data] for an overview of the R packages and functions that can be used for reading, visualizing, and analyzing spatial data. <br />
<br />
R can be used in combination with GRASS GIS in different ways:<br />
<br />
* ''Running R 'on top of' GRASS'': which involves transferring GRASS data to R to run statistical functions on the imported data, and possibly write the results back to GRASS. GRASS raster and vector data can be imported in R using the [https://search.r-project.org/CRAN/refmans/rgrass/html/read_VECT.html read_VECT()] and [https://search.r-project.org/CRAN/refmans/rgrass/html/read_RAST.html read_RAST()] functions provided by [http://cran.r-project.org/web/packages/rgrass/ rgrass]. Similarly, results can be written back using the [https://search.r-project.org/CRAN/refmans/rgrass/html/read_RAST.html write_RAST()] and [https://search.r-project.org/CRAN/refmans/rgrass/html/read_VECT.html write_VECT()] functions. When we read GRASS maps into R, they become R objects stored in memory, more specifically terra objects, i.e., SpatRaster and SpatVector objects that can then be coerced to other types of R spatial objects.<br />
* ''Using R as a scripting language in GRASS''. GRASS functions can be run from R using the [https://search.r-project.org/CRAN/refmans/rgrass/html/execGRASS.html execGRASS()] function in the ''rgrass'' package. R scripting tools, such as powerful string-processing tools, can be used to 'glue' different functions and tools together.<br />
* ''Using GRASS GIS as a geospatial library in R''. GRASS GIS can be used to extend the geospatial capabilities of R by: (1) offering an extensive and robust set of geospatial tools, and (2) providing a way to work with very large (larger-than-memory) spatial data sets. See Using 'GRASS GIS functionality within an R session' below for more information.<br />
<br />
In practice, one will often combine different approaches, with scripts running GRASS functions, reading resulting maps into R for further analysis, modeling and visualization, and creating new layers in R that are imported back into GRASS.<br />
<br />
=== Current State ===<br />
<br />
R Windows binary packages distributed by the Comprehensive R Archive Network (CRAN) using OSGeo software (chiefly PROJ, GDAL and GEOS) use custom built binaries compatible with the build train used by R and are static linked; at present both 32-bit and 64-bit binaries are deployed. CRAN packages for macOS are also static linked to custom built binaries, again using the build train used by R. Static linkage is used to avoid having to deploy a package manager for external software on which R packages depend, since CRAN as a package manager already supports over 15000 packages with three binary versions (devel, release, old release) for Windows and macOS.<br />
<br />
=== Installation ===<br />
<br />
==== Installation of R core software ====<br />
<br />
(see also [[R statistics/Installation]])<br />
<br />
''Note: the ...-devel packages are needed if you want to install extra packages incl. '''rgrass''' on your computer.''<br />
<br />
Fedora:<br />
sudo dnf install R<br />
# further packages needed in order to locally compile "rgrass"<br />
sudo dnf install proj-devel proj-data gdal-devel sqlite-devel xml2 libxml2-devel udunits2-devel<br />
<br />
Ubuntu:<br />
sudo apt-get install r-base<br />
# further packages needed in order to locally compile "rgrass"<br />
sudo apt-get install proj-bin proj-data libproj-dev libgdal-dev libsqlite3-dev libxml2-dev r-base-dev<br />
<br />
==== Installation of the rgrass package ====<br />
To install the R package '''rgrass''' on newer versions of R, you simply start R and install the package directly with:<br />
<br />
<source lang="rsplus"><br />
install.packages("rgrass", dependencies = TRUE)<br />
</source><br />
<br />
This will install '''''rgrass''''' and all its dependencies. To use the package, you first need to load it:<br />
<br />
<source lang="rsplus"><br />
library("rgrass")<br />
</source><br />
<br />
If you are using Rstudio, you can install the rgrass package in the usual way (tool → packages). For further instructions and for troubleshooting, see [[R_statistics/Installation]].<br />
<br />
=== How to use ===<br />
<br />
You can use R with GRASS GIS in two different ways: (1) run R within a GRASS GIS session, and (2) run GRASS GIS within an R session.<br />
<br />
==== Using R within a GRASS GIS session ====<br />
<br />
If you are primarily a GIS user who wants to run e.g., some statistical tests not available in GRASS, you probably want to run R from within a GRASS GIS session. To do so, first start GRASS GIS and then start R (or RStudio) from the GRASS GIS command line. For more information and examples, see [[R_statistics/rgrass]]. <br />
<br />
==== Using GRASS GIS functionality within an R session ====<br />
<br />
If you are primarily an R user who wants to take advantage of the advanced geospatial functions in GRASS, you probably want to use GRASS GIS within an R session. To connect to a GRASS GIS database from within R (or Rstudio), see the instructions on [[R_statistics/rgrass]]. If you are a first time GRASS GIS user, you may want to check out the information for [https://grass.osgeo.org/learn/newcomers/ first time users].<br />
<br />
=== Examples ===<br />
<br />
* [https://grasswiki.osgeo.org/wiki/Temporal_data_processing/GRASS_R_raster_time_series_processing Temporal data processing wiki]; a tutorial about time series processing with GRASS GIS and R.<br />
* A short guide on how to [https://tutorials.ecodiv.earth/toc/from_grass_to_r.html get a GRASS function output in R].<br />
* [https://tutorials.ecodiv.earth/toc/grass-import-glcf.html Importing GLCF MODIS woody plant cover] in a GRASS GIS database using an R script.<br />
* [https://tutorials.ecodiv.earth/toc/grass-r-gbif.html Use R to obtain gbif data] and import it in a GRASS GIS database.<br />
* [https://veroandreo.github.io/grass_ncsu_2023/studio_index.html Using Satellite Data for Species Distribution Modeling with GRASS GIS and R]: Workshop at NCSU, April 2023. <br />
<br />
=== Getting help ===<br />
<br />
==== Manual pages ====<br />
If you are in R and have loaded the rgrass package, you can get the help page of ''rgrass'' by typing:<br />
<br />
<source lang="rsplus"><br />
?rgrass<br />
</source><br />
<br />
Similarly, to get help for a specific function, e.g., for the function ''readRAST()'', you type:<br />
<br />
<source lang="rsplus"><br />
?readRAST<br />
</source><br />
<br />
You can also start the ''R'' help page in your browser:<br />
<br />
<source lang="rsplus"><br />
help.start()<br />
</source><br />
<br />
Now, to get the information about the package, select the '''Packages''' entry and then '''rgrass'''. <br />
<br />
==== Support from the community ====<br />
<br />
Primary support for ''R'' + GRASS and the ''rgrass'' package is through the [https://lists.osgeo.org/mailman/listinfo/grass-stats grass-stats] mailing list.<br />
<br />
=== Useful links ===<br />
<br />
==== R ====<br />
<br />
* [https://r-spatial.org/ R][https://r-spatial.org/ -spatial main web page]<br />
* [https://cran.r-project.org/web/views/Spatial.html CRAN Task View: Analysis of Spatial Data]<br />
* [https://cengel.github.io/rspatial/2_spDataTypes.nb.html Introduction to Spatial Data Types in R]<br />
* [https://github.com/edzer/sp R Classes and Methods for Spatial Data] - <code>sp</code> package<br />
* [https://github.com/r-spatial/sf Simple Features for R] - <code>sf</code> package.<br />
* [https://blog.dominodatalab.com/applied-spatial-data-science-with-r/ Applied Spatial Data Science with R] (blog post with examples)<br />
<br />
==== Related ====<br />
<br />
* [https://rpy2.bitbucket.io/ Python interface to the R Programming Language]: can be used to run R in GRASS Python scripts.<br />
<br />
==== Articles & books ====<br />
<br />
* Neural Networks with GRASS and R [https://dx.doi.org/10.1016/j.ecolmodel.2006.03.015 DOI: 10.1016/j.ecolmodel.2006.03.015]<br />
* [http://www.asdar-book.org/ Applied Spatial Data Analysis with R]. Roger S. Bivand, Edzer Pebesma and V. Gómez-Rubio. UseR! Series, Springer. 2nd ed. 2013, xviii+405 pp., Softcover. ISBN: 978-1-4614-7617-7<br />
* [https://www.grassbook.org/ GRASS Book], see last chapter<br />
* [https://www.osgeo.org/journal OSGeo Journal] vol. 1 May 2007 (R. Bivand. Using the R— GRASS interface. ''OSGeo Journal'', 1:31-33, May 2007. ISSN 1614-8746).<br />
* [https://grass.osgeo.org/newsletter/grassnews3.html GRASS News vol.3], June 2005 (R. Bivand. Interfacing GRASS 6 and R. ''GRASS Newsletter'', 3:11-16, June 2005. ISSN 1614-8746)<br />
<br />
==== Older (but still useful) links ====<br />
<br />
* [https://web.archive.org/web/20090623093535/http://grass.osgeo.org/statsgrass/grass_geostats.html Using GRASS GIS 6 and R]<br />
* [http://grassold.osgeo.org/statsgrass/r_and_dbms.html Connecting R to RDBMS]<br />
* R. Bivand, 2007: [http://spatial.nhh.no/R/etc/FBK07 Interfacing R and OSGeo projects: status and perspectives]: Presentation with slides and scripts.<br />
* M. Neteler and M. Metz, 2011: ''Introduction to GRASS GIS''. GEOSTAT 2011 Landau. [http://geostat-course.org/Topic_NetelerMetz_2011 Download workshop material] (includes a R session)<br />
<br />
[[Category:Installation]]<br />
[[Category:FAQ]]<br />
[[Category:Linking to other languages]]<br />
[[Category:R]]<br />
[[Category:Statistics]]</div>Veroandreohttps://grasswiki.osgeo.org/w/index.php?title=R_statistics/Installation&diff=26877R statistics/Installation2023-04-19T18:37:45Z<p>Veroandreo: /* Mac OSX */ change location name</p>
<hr />
<div>First of all you need to install '''''R''''' in your system.<br />
<br />
R and many of its packages are pre-built and distributed through the CRAN network of mirrors. In addition many Linux distributions pre-package R and a number of the most popular libraries.<br />
<br />
=== Status of rgrass package ===<br />
<br />
See the overview here: https://cran.r-project.org/web/packages/rgrass/index.html<br />
<br />
=== Installation ===<br />
<br />
==== Linux ====<br />
<br />
===== Debian and Ubuntu =====<br />
<br />
''R'' and a number of pre-build cran packages are already present in the main repositories. Start with:<br />
<br />
# apt-get install r-base r-cran-vr r-cran-rodbc r-cran-xml<br />
<br />
Once those are installed start "<tt>R</tt>" at the command prompt and install the <tt>rgrass</tt> library:<br />
<br />
install.packages("rgrass", dependencies = TRUE)<br />
<br />
* [https://cran.r-project.org/bin/linux/debian/ Debian] and [https://cran.r-project.org/bin/linux/ubuntu/ Ubuntu] specific help is also available from the R-project website.<br />
<br />
===== RPM based =====<br />
<br />
* '''RedHat, Fedora, openSuse, ...''' and similar distros: <br />
<br />
# sudo dnf install R<br />
<br />
This R RPM is a meta-package. It has no content but ensures that the following components are installed: R-core, R-core-devel, R-java, R-java-devel, libRmath, libRmath-devel. Once those are installed, start "<tt>R</tt>" and install the <tt>rgrass</tt> library:<br />
<br />
<source lang="bash"><br />
install.packages("rgrass", dependencies = TRUE)<br />
</source><br />
<br />
==== Mac OSX ====<br />
<br />
Start an R session and try:<br />
<br />
<source lang="bash"><br />
install.packages("rgrass", type="source", dependencies = TRUE)<br />
</source><br />
<br />
'''Startup of GRASS from within R:'''<br />
<br />
First you need to find the path to the GRASS binaries: Control-click on the GRASS.app and you'll get a popup menu; select "Show Package Contents" - this opens you to the directory structure. Go to Contents->MacOS which would be "GISBASE"; So, in my case, the "gisBase" parameter is "/HD/Applications/Grass-8.2.app/Contents/MacOS". If you Command-click at the top of the window on the folder icon beside "MacOS" (from the line above this one), you can see the full path.<br />
<br />
Now we can run GRASS from within a R session:<br />
<br />
<source lang="bash"><br />
library(rgrass)<br />
initGRASS(gisBase ='/Applications/GRASS/GRASS-8.2.app/Contents/MacOS', <br />
location = 'nc_spm_08_grass7', <br />
mapset = 'user1', <br />
gisDbase = '/Users/Lars/Documents/Biologi/grassdata', <br />
override = TRUE)<br />
</source><br />
<br />
===== Troubleshooting =====<br />
<br />
If you get an error message when trying to call GRASS from R containing this line: dyld: Library not loaded: /usr/local/lib/libintl.8.dylib you need to establish a link from /Applications/Grass/GRASS-8.2.app/Contents/MacOS/lib/libintl.8.dylib to /usr/local/lib. This can be done through Terminal with the command:<br />
<br />
<source lang="bash"><br />
sudo ln -s /Applications/Grass/GRASS-8.2.app/Contents/MacOS/lib/libintl.8.dylib /usr/local/lib/<br />
</source><br />
<br />
'''Note''': The path to the GRASS-x.x.app and the version number in libintl.X.dylib must reflect your own configuration.<br />
<br />
==== MS Windows ====<br />
<br />
===== Installation =====<br />
Run:<br />
install.packages("rgrass", dependencies = TRUE)<br />
<br />
or install Task View 'Spatial' - Analysis of Spatial Data<br />
install.packages("ctv")<br />
library(ctv)<br />
install.views("Spatial")<br />
<br />
===== Usage =====<br />
<br />
In winGRASS ([https://grass.osgeo.org/download/windows/#standalone-installers standalone installer] and [https://grass.osgeo.org/download/windows/#OSGeo4W OSGeo4W]) the installation path of R and RStudio are dynamically loaded into PATH.<br />
<br />
* Start winGRASS, bring the winGRASS-windows console in front and type ''R'' for opening an R session (command line mode) inside a GRASS session.<br />
* Start winGRASS, bring the winGRASS-windows console in front and type ''RGui'' for opening an R session (GUI mode) inside a GRASS session.<br />
<br />
[[Category:Installation]]<br />
[[Category:FAQ]]<br />
[[Category:Linking to other languages]]<br />
[[Category:R]]<br />
[[Category:Statistics]]</div>Veroandreohttps://grasswiki.osgeo.org/w/index.php?title=R_statistics/Installation&diff=26876R statistics/Installation2023-04-19T18:33:37Z<p>Veroandreo: nest OSs within Installation section</p>
<hr />
<div>First of all you need to install '''''R''''' in your system.<br />
<br />
R and many of its packages are pre-built and distributed through the CRAN network of mirrors. In addition many Linux distributions pre-package R and a number of the most popular libraries.<br />
<br />
=== Status of rgrass package ===<br />
<br />
See the overview here: https://cran.r-project.org/web/packages/rgrass/index.html<br />
<br />
=== Installation ===<br />
<br />
==== Linux ====<br />
<br />
===== Debian and Ubuntu =====<br />
<br />
''R'' and a number of pre-build cran packages are already present in the main repositories. Start with:<br />
<br />
# apt-get install r-base r-cran-vr r-cran-rodbc r-cran-xml<br />
<br />
Once those are installed start "<tt>R</tt>" at the command prompt and install the <tt>rgrass</tt> library:<br />
<br />
install.packages("rgrass", dependencies = TRUE)<br />
<br />
* [https://cran.r-project.org/bin/linux/debian/ Debian] and [https://cran.r-project.org/bin/linux/ubuntu/ Ubuntu] specific help is also available from the R-project website.<br />
<br />
===== RPM based =====<br />
<br />
* '''RedHat, Fedora, openSuse, ...''' and similar distros: <br />
<br />
# sudo dnf install R<br />
<br />
This R RPM is a meta-package. It has no content but ensures that the following components are installed: R-core, R-core-devel, R-java, R-java-devel, libRmath, libRmath-devel. Once those are installed, start "<tt>R</tt>" and install the <tt>rgrass</tt> library:<br />
<br />
<source lang="bash"><br />
install.packages("rgrass", dependencies = TRUE)<br />
</source><br />
<br />
==== Mac OSX ====<br />
<br />
Start an R session and try:<br />
<br />
<source lang="bash"><br />
install.packages("rgrass", type="source", dependencies = TRUE)<br />
</source><br />
<br />
'''Startup of GRASS from within R:'''<br />
<br />
First you need to find the path to the GRASS binaries: Control-click on the GRASS.app and you'll get a popup menu; select "Show Package Contents" - this opens you to the directory structure. Go to Contents->MacOS which would be "GISBASE"; So, in my case, the "gisBase" parameter is "/HD/Applications/Grass-8.2.app/Contents/MacOS". If you Command-click at the top of the window on the folder icon beside "MacOS" (from the line above this one), you can see the full path.<br />
<br />
Now we can run GRASS from within a R session:<br />
<br />
<source lang="bash"><br />
library(rgrass)<br />
initGRASS(gisBase ='/Applications/GRASS/GRASS-8.2.app/Contents/MacOS', <br />
location = 'geostat2012_ll', mapset = 'user1', <br />
gisDbase = '/Users/Lars/Documents/Biologi/grassdata', override = TRUE)<br />
</source><br />
<br />
===== Troubleshooting =====<br />
<br />
If you get an error message when trying to call GRASS from R containing this line: dyld: Library not loaded: /usr/local/lib/libintl.8.dylib you need to establish a link from /Applications/Grass/GRASS-8.2.app/Contents/MacOS/lib/libintl.8.dylib to /usr/local/lib. This can be done through Terminal with the command:<br />
<br />
<source lang="bash"><br />
sudo ln -s /Applications/Grass/GRASS-8.2.app/Contents/MacOS/lib/libintl.8.dylib /usr/local/lib/<br />
</source><br />
<br />
'''Note''': The path to the GRASS-x.x.app and the version number in libintl.X.dylib must reflect your own configuration.<br />
<br />
==== MS Windows ====<br />
<br />
===== Installation =====<br />
Run:<br />
install.packages("rgrass", dependencies = TRUE)<br />
<br />
or install Task View 'Spatial' - Analysis of Spatial Data<br />
install.packages("ctv")<br />
library(ctv)<br />
install.views("Spatial")<br />
<br />
===== Usage =====<br />
<br />
In winGRASS ([https://grass.osgeo.org/download/windows/#standalone-installers standalone installer] and [https://grass.osgeo.org/download/windows/#OSGeo4W OSGeo4W]) the installation path of R and RStudio are dynamically loaded into PATH.<br />
<br />
* Start winGRASS, bring the winGRASS-windows console in front and type ''R'' for opening an R session (command line mode) inside a GRASS session.<br />
* Start winGRASS, bring the winGRASS-windows console in front and type ''RGui'' for opening an R session (GUI mode) inside a GRASS session.<br />
<br />
[[Category:Installation]]<br />
[[Category:FAQ]]<br />
[[Category:Linking to other languages]]<br />
[[Category:R]]<br />
[[Category:Statistics]]</div>Veroandreohttps://grasswiki.osgeo.org/w/index.php?title=R_statistics/Installation&diff=26875R statistics/Installation2023-04-19T18:31:54Z<p>Veroandreo: /* Mac OSX */ clean-up 3</p>
<hr />
<div>First of all you need to install '''''R''''' in your system.<br />
<br />
R and many of its packages are pre-built and distributed through the CRAN network of mirrors. In addition many Linux distributions pre-package R and a number of the most popular libraries.<br />
<br />
=== Status of rgrass package ===<br />
<br />
See the overview here: https://cran.r-project.org/web/packages/rgrass/index.html<br />
<br />
==== Linux ====<br />
<br />
===== Debian and Ubuntu =====<br />
<br />
''R'' and a number of pre-build cran packages are already present in the main repositories. Start with:<br />
<br />
# apt-get install r-base r-cran-vr r-cran-rodbc r-cran-xml<br />
<br />
Once those are installed start "<tt>R</tt>" at the command prompt and install the <tt>rgrass</tt> library:<br />
<br />
install.packages("rgrass", dependencies = TRUE)<br />
<br />
* [https://cran.r-project.org/bin/linux/debian/ Debian] and [https://cran.r-project.org/bin/linux/ubuntu/ Ubuntu] specific help is also available from the R-project website.<br />
<br />
===== RPM based =====<br />
<br />
* '''RedHat, Fedora, openSuse, ...''' and similar distros: <br />
<br />
# sudo dnf install R<br />
<br />
This R RPM is a meta-package. It has no content but ensures that the following components are installed: R-core, R-core-devel, R-java, R-java-devel, libRmath, libRmath-devel. Once those are installed, start "<tt>R</tt>" and install the <tt>rgrass</tt> library:<br />
<br />
<source lang="bash"><br />
install.packages("rgrass", dependencies = TRUE)<br />
</source><br />
<br />
==== Mac OSX ====<br />
<br />
Start an R session and try:<br />
<br />
<source lang="bash"><br />
install.packages("rgrass", type="source", dependencies = TRUE)<br />
</source><br />
<br />
'''Startup of GRASS from within R:'''<br />
<br />
First you need to find the path to the GRASS binaries: Control-click on the GRASS.app and you'll get a popup menu; select "Show Package Contents" - this opens you to the directory structure. Go to Contents->MacOS which would be "GISBASE"; So, in my case, the "gisBase" parameter is "/HD/Applications/Grass-8.2.app/Contents/MacOS". If you Command-click at the top of the window on the folder icon beside "MacOS" (from the line above this one), you can see the full path.<br />
<br />
Now we can run GRASS from within a R session:<br />
<br />
<source lang="bash"><br />
library(rgrass)<br />
initGRASS(gisBase ='/Applications/GRASS/GRASS-8.2.app/Contents/MacOS', <br />
location = 'geostat2012_ll', mapset = 'user1', <br />
gisDbase = '/Users/Lars/Documents/Biologi/grassdata', override = TRUE)<br />
</source><br />
<br />
===== Troubleshooting =====<br />
<br />
If you get an error message when trying to call GRASS from R containing this line: dyld: Library not loaded: /usr/local/lib/libintl.8.dylib you need to establish a link from /Applications/Grass/GRASS-8.2.app/Contents/MacOS/lib/libintl.8.dylib to /usr/local/lib. This can be done through Terminal with the command:<br />
<br />
<source lang="bash"><br />
sudo ln -s /Applications/Grass/GRASS-8.2.app/Contents/MacOS/lib/libintl.8.dylib /usr/local/lib/<br />
</source><br />
<br />
'''Note''': The path to the GRASS-x.x.app and the version number in libintl.X.dylib must reflect your own configuration.<br />
<br />
==== MS Windows ====<br />
<br />
===== Installation =====<br />
Run:<br />
install.packages("rgrass", dependencies = TRUE)<br />
<br />
or install Task View 'Spatial' - Analysis of Spatial Data<br />
install.packages("ctv")<br />
library(ctv)<br />
install.views("Spatial")<br />
<br />
===== Usage =====<br />
<br />
In winGRASS ([https://grass.osgeo.org/download/windows/#standalone-installers standalone installer] and [https://grass.osgeo.org/download/windows/#OSGeo4W OSGeo4W]) the installation path of R and RStudio are dynamically loaded into PATH.<br />
<br />
* Start winGRASS, bring the winGRASS-windows console in front and type ''R'' for opening an R session (command line mode) inside a GRASS session.<br />
* Start winGRASS, bring the winGRASS-windows console in front and type ''RGui'' for opening an R session (GUI mode) inside a GRASS session.<br />
<br />
[[Category:Installation]]<br />
[[Category:FAQ]]<br />
[[Category:Linking to other languages]]<br />
[[Category:R]]<br />
[[Category:Statistics]]</div>Veroandreohttps://grasswiki.osgeo.org/w/index.php?title=R_statistics/Installation&diff=26874R statistics/Installation2023-04-19T18:30:38Z<p>Veroandreo: clean-up 2</p>
<hr />
<div>First of all you need to install '''''R''''' in your system.<br />
<br />
R and many of its packages are pre-built and distributed through the CRAN network of mirrors. In addition many Linux distributions pre-package R and a number of the most popular libraries.<br />
<br />
=== Status of rgrass package ===<br />
<br />
See the overview here: https://cran.r-project.org/web/packages/rgrass/index.html<br />
<br />
==== Linux ====<br />
<br />
===== Debian and Ubuntu =====<br />
<br />
''R'' and a number of pre-build cran packages are already present in the main repositories. Start with:<br />
<br />
# apt-get install r-base r-cran-vr r-cran-rodbc r-cran-xml<br />
<br />
Once those are installed start "<tt>R</tt>" at the command prompt and install the <tt>rgrass</tt> library:<br />
<br />
install.packages("rgrass", dependencies = TRUE)<br />
<br />
* [https://cran.r-project.org/bin/linux/debian/ Debian] and [https://cran.r-project.org/bin/linux/ubuntu/ Ubuntu] specific help is also available from the R-project website.<br />
<br />
===== RPM based =====<br />
<br />
* '''RedHat, Fedora, openSuse, ...''' and similar distros: <br />
<br />
# sudo dnf install R<br />
<br />
This R RPM is a meta-package. It has no content but ensures that the following components are installed: R-core, R-core-devel, R-java, R-java-devel, libRmath, libRmath-devel. Once those are installed, start "<tt>R</tt>" and install the <tt>rgrass</tt> library:<br />
<br />
<source lang="bash"><br />
install.packages("rgrass", dependencies = TRUE)<br />
</source><br />
<br />
==== Mac OSX ====<br />
<br />
Start an R session, then<br />
<br />
* for install.packages() you might have to rely on building packages from source code. try:<br />
<source lang="bash"><br />
R<br />
<br />
install.packages("rgrass", type="source", dependencies = TRUE)<br />
</source><br />
<br />
'''Startup of GRASS from within R:'''<br />
<br />
First you need to find the path to the GRASS binaries: Control-click on the GRASS.app and you'll get a popup menu; select "Show Package Contents" - this opens you to the directory structure. Go to Contents->MacOS which would be "GISBASE"; So, in my case, the "gisBase" parameter is "/HD/Applications/Grass-8.2.app/Contents/MacOS". If you Command-click at the top of the window on the folder icon beside "MacOS" (from the line above this one), you can see the full path.<br />
<br />
Now we can run GRASS from within a R session:<br />
<br />
<source lang="bash"><br />
library(rgrass)<br />
initGRASS(gisBase ='/Applications/GRASS/GRASS-8.2.app/Contents/MacOS', <br />
location = 'geostat2012_ll', mapset = 'user1', <br />
gisDbase = '/Users/Lars/Documents/Biologi/grassdata', override = TRUE)<br />
</source><br />
<br />
===== Troubleshooting =====<br />
<br />
If you get an error message when trying to call GRASS from R containing this line: dyld: Library not loaded: /usr/local/lib/libintl.8.dylib you need to establish a link from /Applications/Grass/GRASS-8.2.app/Contents/MacOS/lib/libintl.8.dylib to /usr/local/lib. This can be done through Terminal with the command:<br />
<br />
<source lang="bash"><br />
sudo ln -s /Applications/Grass/GRASS-8.2.app/Contents/MacOS/lib/libintl.8.dylib /usr/local/lib/<br />
</source><br />
<br />
'''Note''': The path to the GRASS-x.x.app and the version number in libintl.X.dylib must reflect your own configuration.<br />
<br />
==== MS Windows ====<br />
<br />
===== Installation =====<br />
Run:<br />
install.packages("rgrass", dependencies = TRUE)<br />
<br />
or install Task View 'Spatial' - Analysis of Spatial Data<br />
install.packages("ctv")<br />
library(ctv)<br />
install.views("Spatial")<br />
<br />
===== Usage =====<br />
<br />
In winGRASS ([https://grass.osgeo.org/download/windows/#standalone-installers standalone installer] and [https://grass.osgeo.org/download/windows/#OSGeo4W OSGeo4W]) the installation path of R and RStudio are dynamically loaded into PATH.<br />
<br />
* Start winGRASS, bring the winGRASS-windows console in front and type ''R'' for opening an R session (command line mode) inside a GRASS session.<br />
* Start winGRASS, bring the winGRASS-windows console in front and type ''RGui'' for opening an R session (GUI mode) inside a GRASS session.<br />
<br />
[[Category:Installation]]<br />
[[Category:FAQ]]<br />
[[Category:Linking to other languages]]<br />
[[Category:R]]<br />
[[Category:Statistics]]</div>Veroandreohttps://grasswiki.osgeo.org/w/index.php?title=R_statistics/Installation&diff=26872R statistics/Installation2023-04-19T15:53:14Z<p>Veroandreo: clean-up no needed stuff</p>
<hr />
<div>First of all you need to install '''''R''''' in your system.<br />
<br />
R and many of its packages are pre-built and distributed through the CRAN network of mirrors. In addition many Linux distributions pre-package R and a number of the most popular libraries.<br />
<br />
==== Status of "rgrass" packages ====<br />
<br />
See overview here: https://cran.r-project.org/web/packages/rgrass/index.html<br />
<br />
==== Source packages ====<br />
<br />
From the R console first pick a local mirror:<br />
chooseCRANmirror()<br />
<br />
you can then see which repos has been picked with<br />
options("repos")<br />
<br />
To permanently save the mirror site add it to <tt>~/.Rprofile</tt>. For example:<br />
options(repos=c(CRAN="<nowiki>http://cran.stat.auckland.ac.nz</nowiki>"))<br />
<br />
and then run <tt>install.packages()</tt> as in the Quick Start section above.<br />
<br />
For more information see http://cran.r-project.org/doc/manuals/R-admin.html<br />
<br />
==== Linux ====<br />
<br />
===== Debian and Ubuntu =====<br />
<br />
''R'' and a number of pre-build cran packages are already present in the main repositories. Start with:<br />
<br />
# apt-get install r-base r-cran-vr r-cran-rodbc r-cran-xml<br />
<br />
Once those are installed start "<tt>R</tt>" at the command prompt and install the <tt>rgrass</tt> library:<br />
<br />
install.packages("rgrass", dependencies = TRUE)<br />
<br />
* [https://cran.r-project.org/bin/linux/debian/ Debian] and [https://cran.r-project.org/bin/linux/ubuntu/ Ubuntu] specific help is also available from the R-project website.<br />
<br />
===== RPM based =====<br />
<br />
* '''RedHat, Fedora, openSuse, ...''' and similar distros: take the latest '''''R''''' RPM and install it<br />
<br />
''R'' and a number of pre-build cran packages are already present in the main repositories. Start with:<br />
<br />
# sudo dnf install R-core R-core-devel R-XML<br />
<br />
Once those are installed, start "<tt>R</tt>" at the command prompt and install the <tt>rgrass</tt> library:<br />
<br />
<source lang="bash"><br />
R<br />
<br />
install.packages("rgrass", dependencies = TRUE)<br />
</source><br />
<br />
'''Usage:''' You have the best user experience if you launch R or RStudio within a running GRASS GIS session (then R automatically recognizes the current settings of the [[Computational region]] and "sees" the GRASS maps).<br />
<br />
==== Mac OSX ====<br />
<br />
Start an R session, then<br />
<br />
* for install.packages() you might have to rely on building packages from source code. try:<br />
<source lang="bash"><br />
R<br />
<br />
install.packages("rgrass", type="source", dependencies = TRUE)<br />
</source><br />
<br />
'''Startup of GRASS from within R:'''<br />
<br />
First you need to find the path to the GRASS binaries: Control-click on the GRASS.app and you'll get a popup menu; select "Show Package Contents" - this opens you to the directory structure. Go to Contents->MacOS which would be "GISBASE"; So, in my case, the "gisBase" parameter is "/HD/Applications/Grass-8.2.app/Contents/MacOS". If you Command-click at the top of the window on the folder icon beside "MacOS" (from the line above this one), you can see the full path.<br />
<br />
Now we can run GRASS from within a R session:<br />
<br />
<source lang="bash"><br />
library(rgrass)<br />
initGRASS(gisBase ='/Applications/GRASS/GRASS-8.2.app/Contents/MacOS', <br />
location = 'geostat2012_ll', mapset = 'user1', <br />
gisDbase = '/Users/Lars/Documents/Biologi/grassdata', override = TRUE)<br />
</source><br />
<br />
===== Troubleshooting =====<br />
<br />
If you get an error message when trying to call GRASS from R containing this line: dyld: Library not loaded: /usr/local/lib/libintl.8.dylib you need to establish a link from /Applications/Grass/GRASS-8.2.app/Contents/MacOS/lib/libintl.8.dylib to /usr/local/lib. This can be done through Terminal with the command:<br />
<br />
<source lang="bash"><br />
sudo ln -s /Applications/Grass/GRASS-8.2.app/Contents/MacOS/lib/libintl.8.dylib /usr/local/lib/<br />
</source><br />
<br />
'''Note''': The path to the GRASS-x.x.app and the version number in libintl.X.dylib must reflect your own configuration.<br />
<br />
==== MS Windows ====<br />
<br />
===== Installation =====<br />
Run:<br />
install.packages("rgrass", dependencies = TRUE)<br />
<br />
or install Task View 'Spatial' - Analysis of Spatial Data<br />
install.packages("ctv")<br />
library("ctv")<br />
install.views("Spatial")<br />
<br />
===== Usage =====<br />
<br />
In winGRASS ([https://grass.osgeo.org/download/windows/#standalone-installers standalone installer] and [https://grass.osgeo.org/download/windows/#OSGeo4W OSGeo4W]) the installation path of R and RStudio are dynamically loaded into PATH.<br />
<br />
* Start winGRASS, bring the winGRASS-windows console in front and type ''R'' for opening a R-session (command line mode) inside a GRASS-session.<br />
* Start winGRASS, bring the winGRASS-windows console in front and type ''RGui'' for opening a R-session (GUI mode) inside a GRASS-session.<br />
<br />
[[Category:Installation]]<br />
[[Category:FAQ]]<br />
[[Category:Linking to other languages]]<br />
[[Category:R]]<br />
[[Category:Statistics]]</div>Veroandreo