Skip to content

Commit

Permalink
docs: fix code snippet languages (#5095)
Browse files Browse the repository at this point in the history
  • Loading branch information
petrasovaa authored Feb 12, 2025
1 parent 6c2a040 commit b624fc2
Show file tree
Hide file tree
Showing 22 changed files with 44 additions and 40 deletions.
2 changes: 1 addition & 1 deletion display/displaydrivers.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ this variable. Currently only Python scrips are supported.

Lets start with simple example of Python script called *render.py*:

```sh
```python
#!/usr/bin/env python3

import os
Expand Down
6 changes: 3 additions & 3 deletions general/g.findfile/g.findfile.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,10 @@ more info.
Note: The Python tab in the *wxGUI* can be used for entering the
following code:

```sh
import grass.script as gcore
```python
import grass.script as gs

gcore.find_file('elevation', element = 'cell')
gs.find_file('elevation', element = 'cell')
```

## SEE ALSO
Expand Down
9 changes: 7 additions & 2 deletions general/g.parser/g.parser.md
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,9 @@ Example:

```sh
v.in.db driver=sqlite database=mysqlite.db table=pointsfile x=x y=y z=z key=idcol out=dtmpoints --json
```

```json
{
"module": "v.in.db",
"id": "v.in.db_1804289383",
Expand Down Expand Up @@ -348,7 +351,7 @@ Parameters:

### Example code for Python

```sh
```python
#!/usr/bin/env python3

# g.parser demo script for python programming
Expand Down Expand Up @@ -471,7 +474,7 @@ g.message message="Value of GIS_OPT_vect: '$GIS_OPT_vector'"

### Example code for Perl

```sh
```perl
#!/usr/bin/perl -w
use strict;

Expand Down Expand Up @@ -543,7 +546,9 @@ output is shown below:

```sh
v.what.rast --script
```

```python
#!/usr/bin/env python3
############################################################################
#
Expand Down
6 changes: 3 additions & 3 deletions general/g.version/g.version.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ printed by **-e** flag.
See also function `version()` from [Python Scripting
Library](https://grasswiki.osgeo.org/wiki/GRASS_Python_Scripting_Library).

```sh
import grass.script as gcore
```python
import grass.script as gs

print gcore.version()
print(gs.version())
```

## EXAMPLES
Expand Down
2 changes: 1 addition & 1 deletion lib/init/grass.md
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ grass /path/to/grassdata/test1/PERMANENT/ --exec python test.py

A very simple Python script ("test.py") may look like this:

```sh
```python
#!/usr/bin/env python3

# import GRASS Python bindings (see also pygrass)
Expand Down
2 changes: 1 addition & 1 deletion raster/r.category/r.category.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ r.category map=landclass96 cats=3,4 output_format=json

generates the following JSON output:

```sh
```json
[
{
"category": 3,
Expand Down
8 changes: 4 additions & 4 deletions raster/r.horizon/r.horizon.md
Original file line number Diff line number Diff line change
Expand Up @@ -188,14 +188,14 @@ r.horizon elevation=elevation direction=0 step=5 bufferzone=200 \
```

![](rhorizon_shaded_dem_point.png)
Test point near high way intersection (North Carolina sample dataset)
*Test point near high way intersection (North Carolina sample dataset)*

![](rhorizon_singlepoint_plot.png)
Horizon angles for test point (CCW from East)
*Horizon angles for test point (CCW from East)*

We can plot horizon in polar coordinates using Matplotlib in Python:

```sh
```python
import numpy as np
import matplotlib.pyplot as plt

Expand All @@ -212,7 +212,7 @@ plt.show()
```

![](rhorizon_polar_plot.png)
Horizon plot in polar coordinates.
*Horizon plot in polar coordinates.*

### Raster map mode

Expand Down
5 changes: 2 additions & 3 deletions raster/r.in.lidar/r.in.lidar.md
Original file line number Diff line number Diff line change
Expand Up @@ -430,8 +430,7 @@ r.in.lidar input="Serpent Mound Model LAS Data.laz" \
output=Serpent_Mound_Model_LAS_Data method=mean
```

![](r_in_lidar.png)

![](r_in_lidar.png)
*Figure: Elevation for the whole area of Serpent Mound dataset*

### Height above ground
Expand Down Expand Up @@ -492,7 +491,7 @@ r.in.lidar file=/home/user/data/filelist.txt output=mean_height_above_ground bas
In Python, the list of files can be created using the *glob* Python
module:

```sh
```python
import glob
import grass.script as gs

Expand Down
2 changes: 1 addition & 1 deletion raster/r.info/r.info.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ Finally, the output from *r.info* can be output in JSON by passing the
r.info slope format=json
```

```sh
```json
{
"north": 228500,
"south": 215000,
Expand Down
2 changes: 1 addition & 1 deletion raster/r.mask.status/r.mask.status.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ r.mask.status format=json

In Python, use:

```sh
```python
import grass.script as gs
gs.parse_command("r.mask.status", format="json")
```
Expand Down
2 changes: 1 addition & 1 deletion raster/r.object.geometry/r.object.geometry.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ JSON:
r.object.geometry input=zipcodes format=json
```

```sh
```json
[
{
"category": 1,
Expand Down
4 changes: 2 additions & 2 deletions raster/r.profile/r.profile.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ r.profile -g input=elevation coordinates=641712,226095,641546,224138,641546,2220

The output looks as follows:

```sh
```json
[
{
"easting": 641712,
Expand Down Expand Up @@ -192,7 +192,7 @@ The JSON output makes for ease of integration with popular python data
science libraries. For instance, here is an example of creating a
scatterplot of distance vs elevation with color coding.

```sh
```python
import grass.script as gs
import pandas as pd
import matplotlib.pyplot as plt
Expand Down
2 changes: 1 addition & 1 deletion raster/r.report/r.report.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ The output from *r.report* can be output in JSON by passing the
r.report -n -a map=towns,elevation units=miles,meters,kilometers,acres,hectares,cells,percent nsteps=2 format=json
```
```sh
```json
{
"location": "nc_spm_08_grass7",
"created": "2024-07-24T14:59:09+0530",
Expand Down
2 changes: 1 addition & 1 deletion raster/r.solute.transport/r.solute.transport.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ Use this small python script to create a working groundwater flow /
solute transport area and data. Make sure you are not in a lat/lon
projection.

```sh
```python
#!/usr/bin/env python3
# This is an example script how groundwater flow and solute transport are
# computed within GRASS GIS
Expand Down
2 changes: 1 addition & 1 deletion raster/r.sun/r.sun.md
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ d.rast.leg it172
We can compute the day of year from a specific date in Python:
```sh
```python
>>> import datetime
>>> datetime.datetime(2014, 6, 21).timetuple().tm_yday
172
Expand Down
2 changes: 1 addition & 1 deletion raster/r.univar/r.univar.md
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ r.univar -e elevation percentile=98 format=json

will output the results in JSON format:

```sh
```json
[
{
"n": 2025000,
Expand Down
2 changes: 1 addition & 1 deletion scripts/i.band.library/i.band.library.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ designed in order to support image collections in GRASS GIS.
Band reference information is stored in JSON files with a pre-defined
internal data structure. A minimalistic example is shown below.

```sh
```json
{
"Sentinel2": {
"description": "The Sentinel-2 A/B bands",
Expand Down
2 changes: 1 addition & 1 deletion temporal/t.rast.list/t.rast.list.md
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ dataset [t.vect.list](t.vect.list.md#using-method-option)

### Reading raster names in Python

```sh
```python
result = json.loads(
gs.read_command(
"t.rast.list", input="tempmean_monthly", format="json"
Expand Down
6 changes: 3 additions & 3 deletions vector/v.db.select/v.db.select.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ to parse this format when configured to the above specification.

Example with default settings:

```sh
```csv
cat,road_name,multilane,year,length
1,"NC-50","no",2001,4825.369405
2,"NC-50","no",2002,14392.589058
Expand Down Expand Up @@ -106,7 +106,7 @@ the SQL types. The definition of `is_number` may change in the future.

Example with added indentation:

```sh
```json
{
"info": {
"columns": [
Expand Down Expand Up @@ -319,7 +319,7 @@ The *json* package in the standard Python library can load a JSON string
obtained as output from the *v.db.select* module through the
*read_command* function:

```sh
```python
import json
import grass.script as gs

Expand Down
2 changes: 1 addition & 1 deletion vector/v.distance/v.distance.md
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ from_cat to_cat dist
v.distance -p from=busroute_a to=busstopsall upload=dist,to_attr to_column=routes format=json
```

```sh
```json
[
{
"from_cat": 1,
Expand Down
12 changes: 6 additions & 6 deletions vector/v.info/v.info.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ bottom=0.000000

### Output in JSON format

```sh
```json
{
"name": "geology",
"mapset": "PERMANENT",
Expand Down Expand Up @@ -187,17 +187,17 @@ more info.
Note: The Python tab in the *wxGUI* can be used for entering the
following code:

```sh
import grass.script as gcore
```python
import grass.script as gs

gcore.vector_columns('geology') # for `v.info -c`
gcore.vector_info_topo('geology') # for `v.info shell=topo`
gs.vector_columns('geology') # for `v.info -c`
gs.vector_info_topo('geology') # for `v.info shell=topo`
```

Here is an example of how the JSON output format can be used to
integrate Grass with other python libraries easily.

```sh
```python
import grass.script as gs
import pandas as pd

Expand Down
2 changes: 1 addition & 1 deletion vector/v.univar/v.univar.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ v.univar -e samples column=heights type=point format=json

will output the results in JSON format:

```sh
```json
{
"n": 1832,
"missing": 0,
Expand Down

0 comments on commit b624fc2

Please sign in to comment.