jiayuasu commented on code in PR #3114:
URL: https://github.com/apache/sedona/pull/3114#discussion_r3609972006
##########
docs/api/sql/Raster-Operators/RS_AsRaster.md:
##########
@@ -26,7 +26,7 @@ Introduction: `RS_AsRaster` converts a vector geometry into a
raster dataset by
* `pixelType`: Defines data type of the output raster. This can be one of the
following, D (double), F (float), I (integer), S (short), US (unsigned short)
or B (byte).
* `allTouched` (Since: `v1.7.1`): Decides the pixel selection criteria. If set
to `true`, the function selects all pixels touched by the geometry, else,
selects only pixels whose centroids intersect the geometry. Defaults to `false`.
* `value`: The value to be used for assigning pixels covered by the geometry.
Defaults to using `1.0` if not provided.
-* `noDataValue`: Used for assigning the no data value of the resultant raster.
Defaults to `null` if not provided.
+* `noDataValue`: Used for assigning the no data value of the resultant raster;
pixels not covered by the geometry are set to this value. Defaults to `null` if
not provided, in which case uncovered pixels are `0` and the raster has no no
data value.
Review Comment:
One separate compatibility question: do we want omission to continue meaning
`null` here? I may be reading the PostGIS behavior too literally, but its
scalar overloads declare `nodataval DEFAULT 0`, and omission is observably
different from passing `NULL`.
This PostGIS query shows the distinction:
```sql
WITH g AS (
SELECT ST_GeomFromText(
'POLYGON ((0 0, 3 0, 3 3, 0 3, 0 0),
(1 1, 2 1, 2 2, 1 2, 1 1))'
) AS geom
),
r AS (
SELECT
ST_AsRaster(geom, 1.0, -1.0, '8BUI') AS omitted,
ST_AsRaster(
geom, 1.0, -1.0, '8BUI', 1.0, NULL::double precision
) AS explicit_null
FROM g
)
SELECT
ST_BandNoDataValue(omitted, 1),
ST_Value(omitted, 1, 2, 2, false),
ST_BandNoDataValue(explicit_null, 1),
ST_Value(explicit_null, 1, 2, 2, false)
FROM r;
```
I get `0 | 0 | NULL | 0`: both backgrounds contain zero, but only the
omitted case marks zero as nodata.
The comparable Sedona check is:
```sql
WITH inputs AS (
SELECT
ST_GeomFromWKT(
'POLYGON ((0 0, 3 0, 3 3, 0 3, 0 0),
(1 1, 2 1, 2 2, 1 2, 1 1))'
) AS geom,
RS_MakeEmptyRaster(
1, 'B', 3, 3, 0.0, 3.0, 1.0, -1.0, 0.0, 0.0, 0
) AS ref
),
r AS (
SELECT
RS_AsRaster(geom, ref, 'B') AS omitted,
RS_AsRaster(geom, ref, 'B', false, 1.0, 0.0) AS explicit_zero
FROM inputs
)
SELECT
RS_BandNoDataValue(omitted, 1),
RS_BandNoDataValue(explicit_zero, 1)
FROM r;
```
That gives `NULL | 0`. I can see a compatibility reason to preserve the
existing Sedona default, so this may be better handled separately. If matching
PostGIS defaults is the goal, though, the shorter overloads would need to pass
`0`, while explicit `NULL` could keep the current no-nodata behavior.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]