# ST_LUCAS QGIS Plugin

The plugin allows to interactively select the spatial, attribute, temporal and thematic filters from the GUI. In particular, it allows selecting an area of interest (spatial filter) by the extent of the map canvas, specifying a country from a list of EU countries or using a user-defined vector polygon data layer. The plugin interface allows specifying also a list of selected years (temporal filter) and a group of attributes (thematic filter). The plugin also integrates functionality for performing a user-defined class aggregation using a JSON file, a nomenclature translation using a CSV file and showing photos of a selected LUCAS point.

The plugin consists of three tabs: Download, Analyze and Photos.

## Download

The first tab is used to download LUCAS points, where the user has to set individual parameters for downloading.

### Area of interest

In the first part, the user sets the area of interest. There are three options to choose from. If the user selects the `canvas` option, only LUCAS points that fall within the map window are downloaded.

If the user selects the `country` option, a combo box will be available to select the countries for which LUCAS points will be downloaded. More than one country may be selected.

If the user selects the `vector layer` option, the plugin will allow the user to select a polygon layer loaded into QGIS as the area of interest for downloading LUCAS points. The CRS of choosen polygon layer must be EPSG:3035! Otherwise, the download will end with an error.

### Years

The second part allows the user to select the years in which LUCAS points were measured. There are five years available: 2006, 2009, 2012, 2015 and 2018. More than one year may be selected. The user can also select the `all` option, which will return all years.

Note: Not all countries are available for all years. For example the year 2006 contains only 11 contries.

### Groups of attributes

In the third part, the user can choose which attributes in addition to the basic attributes will be included in the attribute table of downloaded LUCAS points. The user can choose `all` option, which returns all available attributes or one of the available groups of attributes can be selected. The following groups are available: Land Cover, Land Use; Land Cover, Land Use, Soil; Forestry; Copernicus; Inspire PLCC.

### Space-time aggregation

If more than one year has been selected, the user can decide whether to use space-temporal aggregation or not.

### Output GeoPackage

The last thing the user has to choose is where the geopackage with LUCAS points will be stored via tool button `...`. After this the LUCAS points can be downloaded by the `Download` button.

If the download was successful, information about the number of downloaded LUCAS points will be displayed as push message.

LUCAS points with predefined style corresponding with level 1 LUCAS nomenclature will be displayed in map window.

Level 1 nomenclature:

Note: LUCAS points with circle symbol indicate, that there are available photos of the LUCAS point. Square symbol means, that there are no photos available.

Note: In some cases it may be that there is no photograph of the point itself, but photographs of the cardinal directions are available. In such a situation, the point still has a square symbol, but the world direction photos can be displayed. For 2006, all points have a square symbol because it is not possible to determine from the attributes whether photos are available for a given point. (The necessary attributes have not yet been introduced for 2006.) However, this does not mean that the plugin is unable to display the available photos.

Note: If Space-time aggregation is checked, no QML style is currently available. This is due to the limit of the current implementation. The solution to the problem is intended for further development.

## Analyze

The second tab is used to analyze the downloaded harmonized LUCAS data. It consists of two parts - LUCAS land cover classes aggregation and nomenclature translation.

### Class aggregation

The first part is used for LUCAS land cover classes aggregation. The user has to load the `json` file with the defined aggregation using the `...` tool button. There are two `json` files. One for aggregating LUCAS classes to the first level of LUCAS nomenclature and the other to the second level of LUCAS nomenclature. These two files are stored in `lc_aggregation` subdirectory of the plugin directory. The user can also define their own aggregation.

A sample input JSON file is here.

When the `json` file with the defined aggregation is loaded, groups of aggregation are displayed.

User can click to one of these groups to show, which classes are aggregated to the specific group.

When clicked on `Apply aggregation` button, new column is added to the attribute table.

### Nomenclature translation

The second part is used for nomenclature translation. The user has to load the `csv` file with defined translation using the `...` tool button and choose the target column of the translation.

A sample input CSV file is here.

When clicked on `Apply translation` button, new column is added to the attribute table.

Note: The nomenclature translation function is still in its initial version and is intended for further development.

## Photos

The third tab is used for showing the photos of selected LUCAS point.

After selecting a LUCAS point, the photo can be shown by changing the `choose photo` combo box to one of the five options: Point, North, South, West or East. Along with the photo, information about the land cover of the LUCAS point, LUCAS point ID and year of measurement are displayed.

Note: Only one point can be selected. In other cases, the plugin returns a warning message.

Note: Showing photos for space-time aggregated data is not implemented yet. This is due to the limit of the current implementation. The solution to the problem is intended for further development.

The size of the loaded photos is adjusted to the size of the plugin window. To view a photo in a larger size, enlarge the plugin window and click the `Refresh` button.

In most cases, LUCAS point has five photos. To display individual photos, either change the value in the combo box or use the `Previous` and `Next` buttons.

Note: Loading photos into the plugin may take some time.

To show photo in full resolution there is the `Show Photo in Web Browser` button which will open the url adress of the given photo. There is also `Clear Photo` button which clears the photo if needed.

## Known issues

OWSLib library contains in version 0.23 and higher a critical bug, which affects this plugin. Please downgrade your OWSLib to version 0.22. Go to Plugins -> Python console and type:

    import pip
    pip.main(["install", "owslib==0.22"])

and restart QGIS.