6

Is there a way to customize the Layers Panel so that the layer CRS is showed next to the layer name?

A little bit more context why this would be handy: I am writing some instructions to use (Q)GIS in particular situations. Some of the people are familiar with projections, but the most of them not.

Normaly you check the CRS by opening the layer properties, but it would be very handy for those 'unfamiliar' people to see directly in which CRS a layer is loaded into QGIS.

7

You could use something like this once your layers have been loaded into QGIS:

for layer in QgsMapLayerRegistry.instance().mapLayers().values():   
    crs = layer.crs().authid()
    layer.setLayerName(layer.name() + ' (' + crs + ')')

Result:

Result


EDIT:

In response to your comment, you can automatically update a layer's name when you add a new layer by connecting the layersAdded signal to a function. Paste the following code into the Python Console and test it by adding layers:

def updateLayerName(layers):
    for layer in layers:
        crs = layer.crs().authid()
        layer.setLayerName(layer.name() + ' (' + crs + ')')

QgsMapLayerRegistry.instance().layersAdded.connect(updateLayerName)
  • is there a way to let it automaticly happen when a layer is added? – PieterB Sep 13 '16 at 14:19
  • @PieterB - Yup, I've edited the post to include an automatic method =) – Joseph Sep 14 '16 at 9:51
  • It works wonderwell! But when I trie to put your code into a macro like suggested here: gis.stackexchange.com/questions/89903/…. It does not work. – PieterB Sep 14 '16 at 10:21
  • Glad it works to some extent :). Do you receive any errors in the Python Console when running the macro? I would suggest asking this as a new question and include any errors you receive. – Joseph Sep 14 '16 at 10:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.