[GH-2804] Raster tutorial: end-to-end running example with visuals#2954
Open
jiayuasu wants to merge 1 commit into
Open
[GH-2804] Raster tutorial: end-to-end running example with visuals#2954jiayuasu wants to merge 1 commit into
jiayuasu wants to merge 1 commit into
Conversation
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.
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 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) | ||
| ``` |
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 | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Did you read the Contributor Guide?
Is this PR related to a ticket?
[GH-XXX] my subject. Closes Raster tutorial: add end-to-end running example with visuals #2804What changes were proposed in this PR?
Rewrites
docs/tutorial/raster.md(and the Chinese mirrorraster.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:
rasterdata sourceRS_Width,RS_Height,RS_NumBands,RS_SRID,RS_GeoReference,RS_MetaData)RS_MapAlgebraRS_ZonalStatsover 5 irregular parcel polygonsRS_AsGeoTiff+ therasterwriterVisuals (13 total in the page)
New assets under
docs/image/raster-tutorial/: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 examplesReuses 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
SedonaRasterworkflows, UDFs, performance pointer) is kept below the walkthrough so the page still works as a lookup reference.Chinese mirror
docs/tutorial/raster.zh.mdis 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 indocs/api/sql/Spatial-Statistics/ST_*DistanceBandColumn.md).How was this patch tested?
mkdocs buildruns clean on bothraster.mdandraster.zh.md(no errors, no warnings on either file). All 38 relative links and 13 image paths resolve.markdownlint,blacken-docs,editorconfig-checker,trailing-whitespace,mixed-line-ending) all pass.Did this PR include necessary documentation updates?