Skip to content

[GH-2804] Raster tutorial: end-to-end running example with visuals#2954

Open
jiayuasu wants to merge 1 commit into
apache:masterfrom
jiayuasu:docs/raster-tutorial-running-example
Open

[GH-2804] Raster tutorial: end-to-end running example with visuals#2954
jiayuasu wants to merge 1 commit into
apache:masterfrom
jiayuasu:docs/raster-tutorial-running-example

Conversation

@jiayuasu
Copy link
Copy Markdown
Member

@jiayuasu jiayuasu commented May 15, 2026

Did you read the Contributor Guide?

Is this PR related to a ticket?

What changes were proposed in this PR?

Rewrites docs/tutorial/raster.md (and the Chinese mirror raster.zh.md) to follow a single dataset through the full raster pipeline, with a visual at every step — addressing the remaining ask from #2804 after the structural reorganization in #2802.

The walkthrough uses a synthesized 2-band GeoTIFF (red + NIR) — fully reproducible, no new test bytes committed — and carries it through eight steps:

  1. Create the scene (numpy + rasterio synthesis)
  2. Load with the raster data source
  3. Inspect metadata (RS_Width, RS_Height, RS_NumBands, RS_SRID, RS_GeoReference, RS_MetaData)
  4. Visualize the raw bands
  5. Process — NDVI via RS_MapAlgebra
  6. Visualize the NDVI result
  7. Aggregate to vector zones with RS_ZonalStats over 5 irregular parcel polygons
  8. Save to disk with RS_AsGeoTiff + the raster writer

Visuals (13 total in the page)

New assets under docs/image/raster-tutorial/:

  • 7 PNGs rendered from numpy + real test resources (FAA_UTM18N_NAD83.tif, raster/test1.tiff) — pipeline overview, raw red/NIR bands, NDVI result, zonal-stats panel, map-algebra detail, and two real-raster examples
  • 3 hand-authored SVG diagrams — tiling flow, NDVI map-algebra detail, two-step write pipeline

Reuses existing SVGs (Raster_Affine_Transformation, RS_WorldToRasterCoord, RS_ReprojectMatch, rasterized-image) in the reference sections.

Reference content preserved

All reference-shaped content from the old tutorial (non-GeoTIFF formats, every operator grouped by purpose, Python SedonaRaster workflows, UDFs, performance pointer) is kept below the walkthrough so the page still works as a lookup reference.

Chinese mirror

docs/tutorial/raster.zh.md is a full translation of the new structure. The four reference-section headers use explicit {#anchor} IDs (wrapped in {% raw %} because the mkdocs-macros plugin would otherwise parse {#...} as a Jinja comment — same idiom used in docs/api/sql/Spatial-Statistics/ST_*DistanceBandColumn.md).

How was this patch tested?

  • mkdocs build runs clean on both raster.md and raster.zh.md (no errors, no warnings on either file). All 38 relative links and 13 image paths resolve.
  • Pre-commit hooks (markdownlint, blacken-docs, editorconfig-checker, trailing-whitespace, mixed-line-ending) all pass.
  • Rendered pages spot-checked locally in a browser; pipeline visuals, tabs, admonitions, and intra-page anchors all render as expected in both languages.

Did this PR include necessary documentation updates?

  • Yes, I have updated the documentation. (This PR is a documentation update.)

Rewrite docs/tutorial/raster.md (and the Chinese mirror raster.zh.md)
to walk a single synthesized 2-band GeoTIFF through the full pipeline:
load → inspect → visualize → NDVI via RS_MapAlgebra → visualize →
zonal stats over 5 irregular parcel polygons → save.

Every walkthrough step has a visual. New assets under
docs/image/raster-tutorial/:
  * 7 PNGs rendered from numpy + real test resources
    (FAA_UTM18N_NAD83.tif, raster/test1.tiff)
  * 3 hand-authored SVG diagrams: tiling flow, NDVI map-algebra
    detail, two-step write pipeline
Reuses existing SVGs (Raster_Affine_Transformation,
RS_WorldToRasterCoord, RS_ReprojectMatch, rasterized-image) in the
reference sections.

The existing reference content (non-GeoTIFF formats, every operator
grouped by purpose, Python SedonaRaster workflows, UDFs, performance
pointer) is preserved below the walkthrough.

Chinese version uses {% raw %}{#anchor}{% endraw %} on the four
reference-section headers so intra-page links from the walkthrough
keep resolving (the macros plugin would otherwise parse {#...} as a
Jinja comment).

Follow-up to apache#2769 / apache#2802.
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 13 changed files in this pull request and generated 12 comments.

Comment thread docs/tutorial/raster.md
Comment on lines 52 to +56
val config = SedonaContext.builder()
.master("local[*]") // Delete this if run in cluster mode
.appName("readTestScala") // Change this to a proper name
.getOrCreate()
```
If you use SedonaViz together with SedonaSQL, please add the following line after `SedonaContext.builder()` to enable Sedona Kryo serializer:
```scala
.config("spark.kryo.registrator", classOf[SedonaVizKryoRegistrator].getName) // org.apache.sedona.viz.core.Serde.SedonaVizKryoRegistrator
.master("local[*]")
.appName("rasterTutorial")
.getOrCreate()
val sedona = SedonaContext.create(config)
Comment thread docs/tutorial/raster.md
Comment on lines +111 to +116
```python
import os
import numpy as np
import rasterio
from rasterio.transform import from_bounds

Comment thread docs/tutorial/raster.md
Comment on lines +158 to +161
```scala
val rasterDf = sedona.read.format("raster").load(s"$WORK/scene.tif")
rasterDf.createOrReplaceTempView("rasterDf")
rasterDf.show()
Comment thread docs/tutorial/raster.md
rasterDf.show();
```

```java
Comment thread docs/tutorial/raster.md
Comment on lines +204 to +213
```python
sedona.sql("""
SELECT RS_Width(rast) AS width,
RS_Height(rast) AS height,
RS_NumBands(rast) AS bands,
RS_SRID(rast) AS srid,
RS_GeoReference(rast) AS world_file
FROM rasterDf
""").show(truncate=False)
```
Comment on lines +111 to +116
```python
import os
import numpy as np
import rasterio
from rasterio.transform import from_bounds

Comment on lines +158 to +161
```scala
val rasterDf = sedona.read.format("raster").load(s"$WORK/scene.tif")
rasterDf.createOrReplaceTempView("rasterDf")
rasterDf.show()
rasterDf.show();
```

```java
Comment on lines +204 to +213
```python
sedona.sql("""
SELECT RS_Width(rast) AS width,
RS_Height(rast) AS height,
RS_NumBands(rast) AS bands,
RS_SRID(rast) AS srid,
RS_GeoReference(rast) AS world_file
FROM rasterDf
""").show(truncate=False)
```
更多栅格操作请参阅 [SedonaSQL 栅格算子](../api/sql/Raster-Functions.md#raster-operators)。
```scala
import org.apache.spark.sql.functions.expr

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Raster tutorial: add end-to-end running example with visuals

2 participants