• Blog posts

    Bio

    by David Crowther

    Qgis_1.png

    Question:

    What is a Layer Definition File and how can it be used?

    Answer:

    A QGIS Layer Definition File stores the following:

    • The Source of the file….and
    • Any Styling/Labelling associated to the layer in QGIS

    This means that Layer Definition Files are perfect for providing your QGIS Users with access to datasets stored in a spatial database e.g. SQL Server, PostGIS etc…. without the need for each User to have to setup complex Database Connections in their QGIS instance.

    To setup a Layer Definition File, your GIS Administrator can make the Database Connection in QGIS on their machine and then open any relevant tables. For example here I have connected to a PostGIS Database and opened the Planning Apps table.

    Qgis_2.jpg

    The GIS Administrator can now use the SYMBOLOGY and LABEL options to style the layer as needed. For example here we have created a Thematic Map of the Planning Apps using the Progress field.

    Qgis_3.jpg

    And then labelled each polygon with that Progress value.

    Qgis_4.jpg

    To now save these settings choose Layer > Save as Layer Definition File > choose a location and give the .QLR file a name e.g. postgis planning apps by progress.qlr.

    Qgis_5.jpg

     Your QGIS Users can now simply open their QGIS and instead of having to setup Connections to Spatial Databases, they simply need to choose Layer > Add from Layer Definition File and browse to find the file to open it.

    Qgis_6.jpg

    Once opened the Layer Definition File opens the PostGIS table and applies the Thematic Styling and Labelling as saved in the .QLR file.

    Qgis_7.jpg

    The above is possible because the Layer Definition File is based on XML and within the file is stored the connection parameters to the source data in the PostGIS database.

    Qgis_8.jpg

    So, instead of asking your Users to create complex connections to Spatial Databases and asking them to apply different non-corporate styling and labelling, why not utilise Layer Definition Files to supply your datasets in a simple method with standardized styling for all!