Class: QgsCoordinateReferenceSystemRegistry

A registry for known coordinate reference system (CRS) definitions, including any user-defined CRSes.

QgsCoordinateReferenceSystemRegistry is not usually directly created, but rather accessed through QgsApplication.coordinateReferenceSystemRegistry().

Added in version 3.18.

Class Hierarchy

Inheritance diagram of qgis.core.QgsCoordinateReferenceSystemRegistry

Base classes

QObject

Methods

addUserCrs

Adds a new crs definition as a custom ("USER") CRS.

authorities

Returns a list of all known authorities.

celestialBodies

Returns a list of all known celestial bodies.

clearRecent

Cleans the list of recently used CRS.

projOperations

Returns a map of all valid PROJ operations.

pushRecent

Pushes a recently used CRS to the top of the recent CRS list.

recentCrs

Returns a list of recently used CRS.

removeRecent

Removes a CRS from the list of recently used CRS.

removeUserCrs

Removes the existing user CRS with matching id.

updateUserCrs

Updates the definition of the existing user CRS with matching id.

userCrsList

Returns a list containing the details of all registered custom (user-defined) CRSes.

Signals

crsDefinitionsChanged

Emitted whenever an operation has caused any of the known CRS definitions (including user-defined CRS) to change.

recentCrsCleared

Emitted when the list of recently used CRS has been cleared.

recentCrsPushed

Emitted when a recently used CRS has been pushed to the top of the recent CRS list.

recentCrsRemoved

Emitted when a recently used CRS has been removed from the recent CRS list.

userCrsAdded

Emitted whenever a new user CRS definition is added.

userCrsChanged

Emitted whenever an existing user CRS definition is changed.

userCrsRemoved

Emitted when the user CRS with matching id is removed from the database.

class qgis.core.QgsCoordinateReferenceSystemRegistry[source]

Bases: QObject

__init__(parent: QObject | None = None)

Constructor for QgsCoordinateReferenceSystemRegistry, with the specified parent object.

Parameters:

parent (Optional[QObject] = None)

class UserCrsDetails[source]

Bases: object

Contains details of a custom (user defined) CRS.

Added in version 3.18.

crs: QgsCoordinateReferenceSystem

QgsCoordinateReferenceSystem object representing the user-defined CRS.

id: int

CRS ID

name: str

CRS name (or description)

proj: str

PROJ string definition of CRS

wkt: str

WKT definition of CRS. This will be empty for custom CRSes which were defined using a PROJ string only.

addUserCrs(self, crs: QgsCoordinateReferenceSystem, name: str | None, nativeFormat: Qgis.CrsDefinitionFormat = Qgis.CrsDefinitionFormat.Wkt) int[source]

Adds a new crs definition as a custom (“USER”) CRS.

Returns the new CRS srsid(), or -1 if the CRS could not be saved.

The nativeFormat argument specifies the format to use when saving the CRS definition. FormatWkt is recommended as it is a lossless format.

Warning

Not all CRS definitions can be represented as a Proj string, so take care when using the FormatProj option.

See also

updateUserCrs()

See also

userCrsAdded()

Parameters:
Return type:

int

authorities(self) Set[str]

Returns a list of all known authorities.

Note

authority names will always be returned in lower case

Added in version 3.34.

Return type:

Set[str]

celestialBodies(self) List[QgsCelestialBody]

Returns a list of all known celestial bodies.

Added in version 3.20.

Return type:

List[QgsCelestialBody]

clearRecent(self)[source]

Cleans the list of recently used CRS.

Added in version 3.36.

signal crsDefinitionsChanged[source]

Emitted whenever an operation has caused any of the known CRS definitions (including user-defined CRS) to change.

projOperations(self) Dict[str, QgsProjOperation]

Returns a map of all valid PROJ operations.

The map keys correspond to PROJ operation IDs.

Added in version 3.20.

Return type:

Dict[str, QgsProjOperation]

pushRecent(self, crs: QgsCoordinateReferenceSystem)[source]

Pushes a recently used CRS to the top of the recent CRS list.

Added in version 3.16.

Parameters:

crs (QgsCoordinateReferenceSystem)

recentCrs(self) List[QgsCoordinateReferenceSystem]

Returns a list of recently used CRS.

Added in version 3.36.

Return type:

List[QgsCoordinateReferenceSystem]

signal recentCrsCleared[source]

Emitted when the list of recently used CRS has been cleared.

See also

clearRecent()

Added in version 3.36.

signal recentCrsPushed(crs: QgsCoordinateReferenceSystem)[source]

Emitted when a recently used CRS has been pushed to the top of the recent CRS list.

See also

pushRecent()

Added in version 3.36.

Parameters:

crs (QgsCoordinateReferenceSystem)

signal recentCrsRemoved(crs: QgsCoordinateReferenceSystem)[source]

Emitted when a recently used CRS has been removed from the recent CRS list.

See also

removeRecent()

Added in version 3.36.

Parameters:

crs (QgsCoordinateReferenceSystem)

removeRecent(self, crs: QgsCoordinateReferenceSystem)[source]

Removes a CRS from the list of recently used CRS.

Added in version 3.36.

Parameters:

crs (QgsCoordinateReferenceSystem)

removeUserCrs(self, id: int) bool[source]

Removes the existing user CRS with matching id.

Returns False if the CRS could not be removed.

See also

userCrsRemoved()

Parameters:

id (int)

Return type:

bool

updateUserCrs(self, id: int, crs: QgsCoordinateReferenceSystem, name: str | None, nativeFormat: Qgis.CrsDefinitionFormat = Qgis.CrsDefinitionFormat.Wkt) bool[source]

Updates the definition of the existing user CRS with matching id.

The crs argument specifies a CRS with the desired new definition.

Returns False if the new CRS definition could not be saved.

The nativeFormat argument specifies the format to use when saving the CRS definition. FormatWkt is recommended as it is a lossless format.

Warning

Not all CRS definitions can be represented as a Proj string, so take care when using the FormatProj option.

See also

addUserCrs()

See also

userCrsChanged()

Parameters:
Return type:

bool

signal userCrsAdded(id: str)[source]

Emitted whenever a new user CRS definition is added.

The id argument specifies the ID of the user CRS which has been changed.

See also

userCrsChanged()

Parameters:

id (str)

signal userCrsChanged(id: str)[source]

Emitted whenever an existing user CRS definition is changed.

The id argument specifies the ID of the user CRS which has been changed.

Objects which store QgsCoordinateReferenceSystem members should connect to this signal and update any stored CRS definitions to ensure that they always use the current definition of any user defined CRSes.

See also

userCrsAdded()

Parameters:

id (str)

userCrsList(self) List[QgsCoordinateReferenceSystemRegistry.UserCrsDetails]

Returns a list containing the details of all registered custom (user-defined) CRSes.

Return type:

List[QgsCoordinateReferenceSystemRegistry.UserCrsDetails]

signal userCrsRemoved(id: int)[source]

Emitted when the user CRS with matching id is removed from the database.

See also

removeUserCrs()

Parameters:

id (int)