Tip of the Day – Create layer definition files of standard layers for reuse and consistency


If you are like me, and if so, I apologize and sympathize, then you probably have a few layers that you use all the time. These are likely part of your base layer set that you include in most of your maps. For me, these include parcels, roads, the city boundary, and aerial photos. WHen I include these layers, I generally make them look the same every single time. After about the 2nd time of adding them to a map and resetting the symbology and labeling, I hoped there was a way to store this configuration for later. As it turns out, there is.
In ArcGIS, you save a Layer .lyr. This saves all of the characteristics of that layer to a separate file on your server. In QGIS, the process is much the same. A Layer Definition File, stores the source information for the layer, as well as anyy symbology and labeling that has been set up. These are all stored in an xml file on your server.
Let’s look at a quick example:

  1. This map contains parcel and road layers that are provided by a county GIS agency. I want to use a subset of each of these layers, and give them specific styling.
    Sample Layers
  2. These photos show the layers with the styling and filters applied. The parcels are limited to one city. The road layer is set up to use as a labeling layer, with the centerlines hidden and only the labels visible.
    Parcel Layer filter and styling
    Road layer filter and styling
  3. Once you have your layers set up properly, right click on each one, and save as a Layer Definition File. This will save all characteristics of this layer from the source, including connection information if it is a database layer, to projections, spatial filters, styles, and labeling.
    Save as Layer Definition File
  4. Once you have saved the layers, they may then be added to any existing or new QGIS project. Simply go to the Layer Menu, and select Add from Layer Definition File.
    Add from Layer Definition File
    Select Layer Definition File
  5. Here you see the layers added to a new QGIS project with the styling and labels intact.

There you have it, a quick rundown on how to save a layer out of a project that you have already set up with styling and labeling for ease of reuse in other maps. This will help with consistency by ensuring that layer styling and labeling are consistent wherever you bring a particular layer in.

If you are just getting started using QGIS, then take a look at my rundown of how to load data from a variety of sources: QGIS – Loading Data

Let me know in the comments what methods you employ for reusing layers!

Related Post

Leave a Reply

Your email address will not be published. Required fields are marked *