Skip to content

Commit

Permalink
Add expression functions to create CRS from string definition and to …
Browse files Browse the repository at this point in the history
…get CRS authid

Fixes qgis#9641
  • Loading branch information
DelazJ committed Feb 14, 2025
1 parent a6c1d8b commit 748c1a5
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 3 deletions.
49 changes: 49 additions & 0 deletions docs/user_manual/expressions/expression_help/CRS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
:orphan:

.. DO NOT EDIT THIS FILE DIRECTLY. It is generated automatically by
populate_expressions_list.py in the scripts folder.
Changes should be made in the function help files
in the resources/function_help/json/ folder in the
qgis/QGIS repository.
.. _expression_function_CRS_crs_from_text:

crs_from_text
.............

Creates a coordinate reference system from a string definition. The string can represent an auth:id code, a WKT definition, or a PROJ string definition of the CRS.

.. list-table::
:widths: 15 85

* - Syntax
- crs_from_text(definition)
* - Arguments
- * **definition** - CRS definition
* - Examples
- * ``crs_from_text('EPSG:3857')`` → crs value 'EPSG:3857 - WGS 84 / Pseudo-Mercator'
* ``crs_from_text('PROJ:+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')`` → crs value 'EPSG:3857 - WGS 84 / Pseudo-Mercator'


.. end_crs_from_text_section
.. _expression_function_CRS_crs_to_authid:

crs_to_authid
.............

Returns the authority:id identifier string for a coordinate reference system.

.. list-table::
:widths: 15 85

* - Syntax
- crs_to_authid(crs)
* - Arguments
- * **crs** - crs value
* - Examples
- * ``crs_to_authid(crs_from_text('PROJ:+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'))`` → 'EPSG:3857'


.. end_crs_to_authid_section
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ Returns the north-based bearing as the angle in radians measured clockwise on th
* - Arguments
- * **point_a** - point geometry
* **point_b** - point geometry
* **source_crs** - an optional string representing the source CRS of the points. By default the current layer's CRS is used.
* **source_crs** - an optional string or CRS object representing the source CRS of the points. By default the current layer's CRS is used.
* **ellipsoid** - an optional string representing the acronym or the authority:ID (eg 'EPSG:7030') of the ellipsoid on which the bearing should be measured. By default the current project's ellipsoid setting is used.
* - Examples
- * ``degrees( bearing( make_point(16198544, -4534850), make_point(18736872, -1877769), 'EPSG:3857', 'EPSG:7030') )`` → 49.980071
Expand Down Expand Up @@ -3198,8 +3198,8 @@ Returns the geometry transformed from a source CRS to a destination CRS.
- transform(geometry, source_auth_id, dest_auth_id)
* - Arguments
- * **geometry** - a geometry
* **source_auth_id** - the source auth CRS ID
* **dest_auth_id** - the destination auth CRS ID
* **source_auth_id** - the source CRS definition or CRS object
* **dest_auth_id** - the destination CRS definition or CRS object
* - Examples
- * ``geom_to_wkt( transform( make_point(488995.53240249, 7104473.38600835), 'EPSG:2154', 'EPSG:4326' ) )`` → 'POINT(0 51)'

Expand Down
14 changes: 14 additions & 0 deletions docs/user_manual/expressions/functions_list.rst
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,20 @@ Further reading: :ref:`expression_function_Date_and_Time_format_date`
.. include:: expression_help/Conversions.rst
:start-after: .. end_to_time_section


CRS Functions
-----------------

This group contains functions to operate on coordinate reference system objects.

.. include:: text_include.rst
:start-after: .. functions_group_toc
:end-before: .. end_functions_group_toc

.. include:: expression_help/CRS.rst
:start-after: :orphan:


Custom Functions
-----------------

Expand Down

0 comments on commit 748c1a5

Please sign in to comment.