Class: QgsCoordinateReferenceSystemRegistry

class qgis.core.QgsCoordinateReferenceSystemRegistry(parent: QObject = None)

Bases: PyQt5.QtCore.QObject

Constructor for QgsCoordinateReferenceSystemRegistry, with the specified parent object.

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().

New in version 3.18.

Parameters

parent

class UserCrsDetails

Bases: sip.wrapper

Contains details of a custom (user defined) CRS.

New in version 3.18.

crs
id
name
proj
wkt
addUserCrs(self, crs: QgsCoordinateReferenceSystem, name: str, nativeFormat: QgsCoordinateReferenceSystem.Format = QgsCoordinateReferenceSystem.FormatWkt) → int

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
  • crs (QgsCoordinateReferenceSystem) –

  • name (str) –

  • nativeFormat (QgsCoordinateReferenceSystem.Format = QgsCoordinateReferenceSystem.FormatWkt) –

Return type

int

childEvent(self, QChildEvent)
connectNotify(self, QMetaMethod)
crsDefinitionsChanged

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

customEvent(self, QEvent)
disconnectNotify(self, QMetaMethod)
isSignalConnected(self, QMetaMethod) → bool
receivers(self, PYQT_SIGNAL) → int
removeUserCrs(self, id: int) → bool

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

sender(self) → QObject
senderSignalIndex(self) → int
timerEvent(self, QTimerEvent)
updateUserCrs(self, id: int, crs: QgsCoordinateReferenceSystem, name: str, nativeFormat: QgsCoordinateReferenceSystem.Format = QgsCoordinateReferenceSystem.FormatWkt) → bool

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
  • id (int) –

  • crs (QgsCoordinateReferenceSystem) –

  • name (str) –

  • nativeFormat (QgsCoordinateReferenceSystem.Format = QgsCoordinateReferenceSystem.FormatWkt) –

Return type

bool

userCrsAdded

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()

See also

crsDefinitionsChanged() [signal]

Parameters

id (str) –

userCrsChanged

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() [signal]

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]

userCrsRemoved

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

See also

removeUserCrs() [signal]

Parameters

id (int) –