pratham76 commented on code in PR #55207: URL: https://github.com/apache/spark/pull/55207#discussion_r3050478338
########## docs/sql-ref-geospatial-types.md: ########## @@ -142,6 +142,92 @@ SELECT ST_Srid(ST_SetSrid(ST_GeomFromWKB(X'0101000000000000000000F03F00000000000 * **Fixed-SRID columns**: Every value in the column must have the same SRID as the column type. Inserting a value with a different SRID can raise an error (or you can use `ST_SetSrid` to set the value’s SRID to match the column). * **Mixed-SRID columns** (`GEOMETRY(ANY)` or `GEOGRAPHY(ANY)`): Values can have different SRIDs. Only valid SRIDs are allowed. * **Storage**: Parquet, Delta, and Iceberg store geometry/geography with a fixed SRID per column; mixed-SRID types are for in-memory/query use. When writing to these formats, a concrete (fixed) SRID is required. +### Supported SRIDs + +Spark includes a pre-built registry of standard Spatial Reference Identifiers (SRIDs) from the PROJ database, with overrides to support OGC standards. This registry enables validation and proper handling of coordinate systems for geospatial data. + +#### Commonly Used SRIDs + +| SRID | Name | Description | Typical Use Case | +|------|------|-------------|------------------| +| 4326 | WGS 84 | World Geodetic System 1984 (latitude/longitude) | GPS coordinates, global data (default for GEOGRAPHY) | +| 3857 | Web Mercator | Pseudo-Mercator projection used by web mapping services | Web maps (Google Maps, OpenStreetMap, Bing Maps) | +| 2154 | RGF93 / Lambert-93 | French national coordinate system | France-specific mapping and GIS | +| 32633 | WGS 84 / UTM zone 33N | Universal Transverse Mercator, zone 33 North | Central Europe (6°E to 12°E) | +| 32634 | WGS 84 / UTM zone 34N | Universal Transverse Mercator, zone 34 North | Eastern Europe (12°E to 18°E) | +| 32635 | WGS 84 / UTM zone 35N | Universal Transverse Mercator, zone 35 North | Eastern Europe/Western Asia (18°E to 24°E) | + +The registry includes many additional SRIDs for various UTM zones, national coordinate systems, and other projections. For a complete list, refer to the [EPSG Geodetic Parameter Dataset](https://epsg.org/). + +#### Using Different SRIDs + +**Creating tables with specific SRIDs:** + +```sql +-- Web Mercator projection (common for web mapping applications) +CREATE TABLE web_map_data ( + id BIGINT, + location GEOMETRY(3857) +); + +-- UTM zone 33N for Central Europe +CREATE TABLE europe_survey_data ( + id BIGINT, + measurement_point GEOMETRY(32633) +); + +-- French national grid +CREATE TABLE france_cadastre ( + id BIGINT, + parcel GEOMETRY(2154) +); +``` + +**Converting between SRIDs:** Review Comment: Thank you, noted, have removed the repeated section. ########## docs/sql-ref-geospatial-types.md: ########## @@ -142,6 +142,92 @@ SELECT ST_Srid(ST_SetSrid(ST_GeomFromWKB(X'0101000000000000000000F03F00000000000 * **Fixed-SRID columns**: Every value in the column must have the same SRID as the column type. Inserting a value with a different SRID can raise an error (or you can use `ST_SetSrid` to set the value’s SRID to match the column). * **Mixed-SRID columns** (`GEOMETRY(ANY)` or `GEOGRAPHY(ANY)`): Values can have different SRIDs. Only valid SRIDs are allowed. * **Storage**: Parquet, Delta, and Iceberg store geometry/geography with a fixed SRID per column; mixed-SRID types are for in-memory/query use. When writing to these formats, a concrete (fixed) SRID is required. +### Supported SRIDs + +Spark includes a pre-built registry of standard Spatial Reference Identifiers (SRIDs) from the PROJ database, with overrides to support OGC standards. This registry enables validation and proper handling of coordinate systems for geospatial data. + +#### Commonly Used SRIDs + +| SRID | Name | Description | Typical Use Case | +|------|------|-------------|------------------| +| 4326 | WGS 84 | World Geodetic System 1984 (latitude/longitude) | GPS coordinates, global data (default for GEOGRAPHY) | +| 3857 | Web Mercator | Pseudo-Mercator projection used by web mapping services | Web maps (Google Maps, OpenStreetMap, Bing Maps) | +| 2154 | RGF93 / Lambert-93 | French national coordinate system | France-specific mapping and GIS | +| 32633 | WGS 84 / UTM zone 33N | Universal Transverse Mercator, zone 33 North | Central Europe (6°E to 12°E) | +| 32634 | WGS 84 / UTM zone 34N | Universal Transverse Mercator, zone 34 North | Eastern Europe (12°E to 18°E) | +| 32635 | WGS 84 / UTM zone 35N | Universal Transverse Mercator, zone 35 North | Eastern Europe/Western Asia (18°E to 24°E) | + +The registry includes many additional SRIDs for various UTM zones, national coordinate systems, and other projections. For a complete list, refer to the [EPSG Geodetic Parameter Dataset](https://epsg.org/). + +#### Using Different SRIDs + +**Creating tables with specific SRIDs:** + +```sql +-- Web Mercator projection (common for web mapping applications) +CREATE TABLE web_map_data ( + id BIGINT, + location GEOMETRY(3857) +); + +-- UTM zone 33N for Central Europe +CREATE TABLE europe_survey_data ( + id BIGINT, + measurement_point GEOMETRY(32633) +); + +-- French national grid +CREATE TABLE france_cadastre ( + id BIGINT, + parcel GEOMETRY(2154) +); +``` + +**Converting between SRIDs:** + +```sql +-- Create a point in WGS 84 (SRID 4326) +SELECT ST_GeomFromWKB(X'0101000000000000000000F03F0000000000000040', 4326) AS point_wgs84; + +-- Change SRID to Web Mercator (note: this only changes the SRID metadata, not the coordinates) +SELECT ST_SetSrid( + ST_GeomFromWKB(X'0101000000000000000000F03F0000000000000040', 4326), + 3857 +) AS point_web_mercator; +``` + +**Important:** `ST_SetSrid` only changes the SRID metadata; it does not transform coordinates. For actual coordinate transformation between different coordinate systems, use appropriate transformation functions or external tools. + +#### SRID Validation + +When creating GEOMETRY or GEOGRAPHY values, Spark validates that the specified SRID exists in the pre-built registry. Using an unsupported or invalid SRID will result in an error. + +```sql +-- Valid: 4326 is in the registry +SELECT ST_GeomFromWKB(X'0101000000000000000000F03F0000000000000040', 4326); Review Comment: Thanks! incorporated ########## docs/sql-ref-geospatial-types.md: ########## @@ -142,6 +142,92 @@ SELECT ST_Srid(ST_SetSrid(ST_GeomFromWKB(X'0101000000000000000000F03F00000000000 * **Fixed-SRID columns**: Every value in the column must have the same SRID as the column type. Inserting a value with a different SRID can raise an error (or you can use `ST_SetSrid` to set the value’s SRID to match the column). * **Mixed-SRID columns** (`GEOMETRY(ANY)` or `GEOGRAPHY(ANY)`): Values can have different SRIDs. Only valid SRIDs are allowed. * **Storage**: Parquet, Delta, and Iceberg store geometry/geography with a fixed SRID per column; mixed-SRID types are for in-memory/query use. When writing to these formats, a concrete (fixed) SRID is required. +### Supported SRIDs + +Spark includes a pre-built registry of standard Spatial Reference Identifiers (SRIDs) from the PROJ database, with overrides to support OGC standards. This registry enables validation and proper handling of coordinate systems for geospatial data. + +#### Commonly Used SRIDs + +| SRID | Name | Description | Typical Use Case | +|------|------|-------------|------------------| +| 4326 | WGS 84 | World Geodetic System 1984 (latitude/longitude) | GPS coordinates, global data (default for GEOGRAPHY) | +| 3857 | Web Mercator | Pseudo-Mercator projection used by web mapping services | Web maps (Google Maps, OpenStreetMap, Bing Maps) | +| 2154 | RGF93 / Lambert-93 | French national coordinate system | France-specific mapping and GIS | +| 32633 | WGS 84 / UTM zone 33N | Universal Transverse Mercator, zone 33 North | Central Europe (6°E to 12°E) | +| 32634 | WGS 84 / UTM zone 34N | Universal Transverse Mercator, zone 34 North | Eastern Europe (12°E to 18°E) | +| 32635 | WGS 84 / UTM zone 35N | Universal Transverse Mercator, zone 35 North | Eastern Europe/Western Asia (18°E to 24°E) | + +The registry includes many additional SRIDs for various UTM zones, national coordinate systems, and other projections. For a complete list, refer to the [EPSG Geodetic Parameter Dataset](https://epsg.org/). + +#### Using Different SRIDs + +**Creating tables with specific SRIDs:** + +```sql +-- Web Mercator projection (common for web mapping applications) +CREATE TABLE web_map_data ( + id BIGINT, + location GEOMETRY(3857) +); + +-- UTM zone 33N for Central Europe +CREATE TABLE europe_survey_data ( + id BIGINT, + measurement_point GEOMETRY(32633) +); + +-- French national grid +CREATE TABLE france_cadastre ( + id BIGINT, + parcel GEOMETRY(2154) +); +``` + +**Converting between SRIDs:** + +```sql +-- Create a point in WGS 84 (SRID 4326) +SELECT ST_GeomFromWKB(X'0101000000000000000000F03F0000000000000040', 4326) AS point_wgs84; + +-- Change SRID to Web Mercator (note: this only changes the SRID metadata, not the coordinates) +SELECT ST_SetSrid( + ST_GeomFromWKB(X'0101000000000000000000F03F0000000000000040', 4326), + 3857 +) AS point_web_mercator; +``` + +**Important:** `ST_SetSrid` only changes the SRID metadata; it does not transform coordinates. For actual coordinate transformation between different coordinate systems, use appropriate transformation functions or external tools. + +#### SRID Validation + +When creating GEOMETRY or GEOGRAPHY values, Spark validates that the specified SRID exists in the pre-built registry. Using an unsupported or invalid SRID will result in an error. + +```sql +-- Valid: 4326 is in the registry +SELECT ST_GeomFromWKB(X'0101000000000000000000F03F0000000000000040', 4326); +-- Returns: GEOMETRY with SRID 4326 + +-- Valid: 3857 (Web Mercator) is in the registry +SELECT ST_GeomFromWKB(X'0101000000000000000000F03F0000000000000040', 3857); +-- Returns: GEOMETRY with SRID 3857 + +-- Error: 99999 is not a valid SRID in the registry +SELECT ST_GeomFromWKB(X'0101000000000000000000F03F0000000000000040', 99999); +-- Throws error: Invalid SRID +``` + +#### SRID 0 (Unspecified) + +SRID 0 represents an unspecified or unknown coordinate system. It is allowed for GEOMETRY types but should be used with caution: Review Comment: Thanks! incorporated -- 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] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
