Skip to content

Commit fd3f16d

Browse files
authored
Doc: add Projections tutorial (#14285)
1 parent bd03b8f commit fd3f16d

12 files changed

Lines changed: 410 additions & 8 deletions
144 KB
Loading

doc/source/glossary.rst

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@ The GDAL glossary contains terms and acronyms found throughout the GDAL document
5858

5959
The date tied to spatial coordinates in a dynamic reference frame, used to account for positional changes over time (e.g., due to tectonic motion).
6060

61+
Coordinate System
62+
63+
The mathematical framework that defines how coordinates are measured and represented within a geometric coordinate space.
64+
6165
CPL
6266

6367
Common Portability Library. Part of the C API that provides convenience
@@ -74,8 +78,8 @@ The GDAL glossary contains terms and acronyms found throughout the GDAL document
7478

7579
CRS
7680

77-
Coordinate Reference System. A system that maps spatial data coordinates to real-world locations,
78-
combining a coordinate system with a reference surface like a projection or :term:`ellipsoid`.
81+
Coordinate Reference System. Specifies how coordinates correspond to locations on Earth (or other celestial bodies),
82+
including the :term:`coordinate system`, :term:`datum`, and, if applicable, a projection.
7983

8084
CSL
8185

@@ -87,6 +91,12 @@ The GDAL glossary contains terms and acronyms found throughout the GDAL document
8791
A command-line tool and library for transferring data with URLs, supporting protocols such as HTTP, HTTPS, FTP, and more.
8892
Commonly used for testing and interacting with web services.
8993

94+
Datum
95+
96+
A model of the Earth that specifies the size and shape of the reference :term:`ellipsoid` and its position and orientation
97+
relative to the Earth, providing the basis for a :term:`CRS`. In geodetic datums, this defines horizontal positioning.
98+
Vertical datums define a reference surface for height values (e.g., mean sea level or a geoid) used for vertical coordinates in 3D operations.
99+
90100
DEM
91101

92102
Digital Elevation Model. A raster representation of the height of the earth's surface.

doc/source/programs/gdal_bash_completion.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ Examples of completion
9797
9898
.. example::
9999
:title: Auto-completion of EPSG CRS codes
100+
:id: gdal-bash-completion-crs
100101

101102
.. code-block:: console
102103

doc/source/programs/gdal_raster_info.rst

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,3 +193,17 @@ Examples
193193

194194
> gdal raster info https://sentinel-cogs.s3.us-west-2.amazonaws.com/sentinel-s2-l2a-cogs/36/Q/WD/2020/7/S2A_36QWD_20200701_0_L2A/TCI.tif --of=JSON `
195195
| jq '.metadata.IMAGE_STRUCTURE.LAYOUT == \"COG\"'
196+
197+
.. example::
198+
:title: Return the CRS used by the raster using ``jq``
199+
:id: gdal-raster-info-crs
200+
201+
.. tabs::
202+
203+
.. code-tab:: bash
204+
205+
gdal raster info in.tif --of json | jq -r '.stac."proj:projjson".id | .authority + ":" + (.code|tostring)'
206+
207+
.. code-tab:: ps1
208+
209+
gdal raster info in.tif --of json | jq -r '.stac.\"proj:projjson\".id | .authority + \":\" + (.code|tostring)'

doc/source/programs/gdal_raster_reproject.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ Program-Specific Options
8888

8989
.. option:: -d, --dst-crs <SRC-CRS>
9090

91-
Set source spatial reference. If not specified the SRS found in the input
91+
Set destination spatial reference. If not specified the SRS found in the input
9292
dataset will be used.
9393

9494
.. include:: options/srs_def_gdalwarp.rst

doc/source/programs/gdal_vector_edit.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,3 +132,13 @@ Examples
132132
.. code-block:: bash
133133
134134
$ gdal vector edit --crs=EPSG:4326 --geometry-type=POLYGONZM in.gpkg out.gpkg --overwrite
135+
136+
.. example::
137+
:title: Apply a CRS to a Shapefile
138+
139+
If a Shapefile is missing its associated ``.prj`` file, it can be created as follows:
140+
141+
.. code-block:: bash
142+
143+
$ gdal vector edit --crs=EPSG:3857 in.shp out.shp
144+

doc/source/programs/gdal_vector_reproject.rst

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,3 +98,56 @@ Examples
9898
.. code-block:: bash
9999
100100
$ gdal vector reproject --dst-crs=EPSG:32632 in.gpkg out.gpkg --overwrite
101+
102+
.. example::
103+
:id: gdal-vector-reproject-crs
104+
:title: Reproject data using various CRS formats
105+
106+
The following examples demonstrate different ways to specify a coordinate reference system.
107+
Each command reprojects the data to the Web Mercator (EPSG:3857) projection and produces identical output.
108+
109+
.. code-block:: bash
110+
111+
# OGC CRS URI
112+
$ gdal vector reproject \
113+
--dst-crs="http://www.opengis.net/def/crs/EPSG/0/3857" \
114+
natural_earth_vector.gpkg --layer=ne_10m_populated_places \
115+
places.json --overwrite
116+
117+
# OGC CRS URN
118+
$ gdal vector reproject \
119+
--dst-crs="urn:ogc:def:crs:EPSG::3857" \
120+
natural_earth_vector.gpkg --layer=ne_10m_populated_places \
121+
places.json --overwrite
122+
123+
# PROJ string (legacy format)
124+
$ PROJ4="+proj=merc +a=6378137 +b=6378137 +lat_ts=0 +lon_0=0 +x_0=0 +y_0=0 +k=1 +units=m +nadgrids=@null +wktext +no_defs +type=crs"
125+
$ gdal vector reproject \
126+
--dst-crs="$PROJ4" \
127+
natural_earth_vector.gpkg --layer=ne_10m_populated_places \
128+
places.json --overwrite
129+
130+
.. example::
131+
:title: Reproject a layer in a GeoPackage to Web Mercator GeoJSON
132+
133+
The timezone layer cannot be fully reprojected to Web Mercator as the coordinates at the poles fall outside the extent of the Web Mercator bounding-box causing
134+
some features to be missing in the output. The following errors are returned:
135+
136+
.. code-block:: bash
137+
138+
ERROR 1: Full reprojection failed, but partial is possible if you define OGR_ENABLE_PARTIAL_REPROJECTION configuration option to TRUE
139+
ERROR 1: PROJ: webmerc: Invalid latitude
140+
ERROR 1: Reprojection failed, err = 2049, further errors will be suppressed on the transform object.
141+
142+
You can follow the suggestion above and enable ``OGR_ENABLE_PARTIAL_REPROJECTION``.
143+
Errors from PROJ relating to invalid coordinates (``ERROR 1: PROJ: webmerc: Invalid latitude``) will still be reported, but all features will be written to the output.
144+
145+
.. code-block:: bash
146+
147+
$ gdal vector reproject \
148+
--dst-crs=EPSG:3857 \
149+
--config OGR_ENABLE_PARTIAL_REPROJECTION=TRUE \
150+
natural_earth_vector.gpkg --layer=ne_10m_time_zones \
151+
ne_10m_time_zones.json \
152+
--overwrite
153+

doc/source/substitutions.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
.. |Docker| replace:: `Docker <https://www.docker.com/>`__
1515
.. |gdal-dev| replace:: `gdal-dev <https://lists.osgeo.org/mailman/listinfo/gdal-dev>`__
1616
.. |OSGeo/gdal| replace:: `OSGeo/gdal <https://github.com/OSGeo/gdal>`__
17+
.. |OGC| replace:: `OGC <https://www.ogc.org//>`__
1718
.. |Sphinx| replace:: `Sphinx <https://www.sphinx-doc.org/>`__
1819
.. |sphinx-autobuild| replace:: `sphinx-autobuild <https://pypi.org/project/sphinx-autobuild/>`__
1920
.. |about-config-options| replace:: :ref:`Configuration options <configoptions>` can be specified in command-line tools using the syntax ``--config <NAME>=<VALUE>`` or using functions such as :cpp:func:`CPLSetConfigOption` (C) or :py:func:`gdal.config_options<osgeo.gdal.config_options>` (Python).

doc/source/tutorials/index.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,13 @@ Geographic Network Model
4545

4646
gnm_api_tut
4747

48-
Projections and Spatial Reference Systems tutorial (OSR - OGRSpatialReference)
49-
------------------------------------------------------------------------------
48+
Projections / CRS
49+
-----------------
5050

5151
.. toctree::
5252
:maxdepth: 1
5353

54+
reprojecting_data
5455
osr_api_tut
5556

5657
Workshops

doc/source/tutorials/osr_api_tut.rst

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,11 @@ WKT2:2015 and WKT2:2018) for describing coordinate systems.
2626
References and applicable standards
2727
-----------------------------------
2828

29-
- `PROJ documentation <https://proj4.org>`_: projection methods and coordinate operations
30-
- `ISO:19111 and WKT standards <https://proj4.org/development/reference/cpp/cpp_general.html#standards>`_
29+
- |PROJ| documentation: projection methods and coordinate operations
30+
- `Spatial Reference <https://spatialreference.org>`_: an extensive database of spatial reference systems in standardized formats like Well-Known Text (WKT) or PROJJSON
31+
- `ISO:19111 and WKT standards <https://proj.org/development/reference/cpp/cpp_general.html#general_doc_1standards>`_
3132
- `GeoTIFF Projections Transform List <http://geotiff.maptools.org/proj_list>`_: understanding formulations of projections in WKT for GeoTIFF
32-
- `EPSG Geodesy web page <http://www.epsg.org>`_ is also a useful resource
33+
- `EPSG Geodesy web page <https://www.epsg.org>`_ is also a useful resource
3334

3435
Defining a Geographic Coordinate Reference System
3536
-------------------------------------------------
@@ -172,6 +173,8 @@ This method with options is available in C as the :cpp:func:`OSRExportToWktEx` f
172173
The :cpp:func:`OGRSpatialReference::importFromWkt` method can be used to set an
173174
OGRSpatialReference from a WKT CRS definition.
174175

176+
.. _osr_api_tut_axis_order:
177+
175178
CRS and axis order
176179
------------------
177180

0 commit comments

Comments
 (0)