(datasource-settings)= # Configuration via datasource In addition to the configuration via the experience builders settings UI (see {ref}`ui-settings`), the ncWMS widget can be configured through a so-called _datasource_ (see [ESRIs docs on adding data][datasource-docs]). You can select a Feature Layer (tabular data) and populate the widget from it's content. The advantage of this approach is that Feature Layers can be automatically updated via ESRIs Rest API, or they can be dynamically populated by other widgets, such as the [DASF Experience Builder Plugin][dasf-experiencebuilder-plugin]. ## Creating a compatible datasource ESRIs experience builder distinguishes between static server-side data sources (i.e. feature layers that have been created on the server), and client-side data sources (i.e. data sources that only exist in the runtime environment of the user and are deleted once the user refreshes the page). The former is the standard case with the Experience Builder, the latter is used by the [DASF Experience Builder Plugin][dasf-experiencebuilder-plugin] for dynamic data creation. ### Creating a compatible Feature Layer The easiest way to create a compatible feature layer is to copy the existing [_ncWMS Demo Datasource_](https://hub.hereon.de/portal/home/item.html?id=1de0ca89132e4879820c875c1c8324ca#overview). 1. Navigate to your [Content Page on the GeoHub](https://hub.hereon.de/portal/home/content.html) 2. Click the _New item_ button in the the upper left corner ![button to create a new item](screenshots/new-item-button.png) 3. Click _Feature layer_ to create a new feature layer ![button to create a new feature layer](screenshots/feature-layer-button.png) 4. Select _Provide an ArcGIS Server layer URL_ out of the 4 choices ![button to select an existing feature layer](screenshots/provide-feature-layer-url.png) 5. Enter the URL of the RestAPI for the _ncWMS Demo Datasource_: Now give it a suitable name, keywords, description, etc. and you are done. ### Creating a compatible DataSource with the DASF Experience Builder Plugin To create a Datasource that can be dynamically populated by the DASF Experience Builder Plugin, use it's possibility to upload a datasource config. Click your DASF Experience Builder Plugin in the Experience Builder and in the settings UI: 1. Expand the _Add new datasource_ section in the _Output datasources_ section 2. Upload the following config: {download}`dasf-datasource-config.json` 3. Edit the name of the datasource Now you can populate it from your DASF backend module. ### Datasource Spec The columns of the feature layer define the ncWMS widget. They can populate the widget with WMS services, or provide default visualization settings or dimension settings. Each row is treated sequentially. Only the _WMS Service_ specific columns are added up, for the other columns we have the rule that rows down below overwrite rows above with the same grouper. Note that all columns are optional, and you can load multiple data sources at once in the widget. As such, you can use this framework to define default visualization settings, etc. #### General columns There is one general column, namely grouper : When empty, the visualization and dimension settings defined by this record are applied to all _WMS Configs_. Otherwise this _grouper_ should be the name of a _WMS Config_ that this row applies to (except for _url_ and _label_) #### WMS Service columns The following two columns can be used to add a new WMS Service to the _WMS Config_ defined via the _grouper_ column. If the _grouper_ column is empty, a new _WMS Config_ labeled _unnamed_ will be created. The _url_ and _label_ columns fill up, i.e. each _url_ and _label_ will become a separate tab for the given _WMS Config_. label : The label determines the name of the tab for the service. If the _WMS config_ has only one single service, there will be no tabs and the label does not have any effect. url : The URL of the service is the so-called `GetCapabilities` provided by your ncWMS-Server. If your using a THREDDS-Server ([this one here][thredds-example] for instance), you can get this by copying the URL of the _WMS_-Link in the _Access_-Section of your netCDF file ![screenshot for getting a WMS GetCapabilities URL](screenshots/get-wms-url.png) [thredds-example]: https://thredds.hcdc.hereon.de/thredds/catalog/cD4_wfns_offs_E5_chr_ALHFL_S/catalog.html?dataset=cD4_wfns_offs_E5_chr_ALHFL_S/cD4_wfns_offs_E5_chr_ALHFL_S_2022.nc #### Dimension columns The dimension columns specify what variable, what service and what time step is specified. selectedservice : The label of the service to show in the beginning. If a service does not have a label, use the url instead variablename : The variable to visualize. If not set, it will be defined by the ncWMS server variablelabel : The label of the variable to visualize. If not set, it will default to the _variablename_ (or defined by the ncWMS Server if the latter is empty) selectedyear : The year of the time step to show in the beginning selectedmonth : The month of the time step to show in the beginning selectedday : The day of the time step to show in the beginning selectedtime : The timestamp of the time step to show in the beginning zvalue : The vertical level to show in the beginning #### Visualization columns The visualization parameters are mostly defined through the custom parameters to [ncWMSs GetMap request][GetMap Docs]. visualizationstyle : The visualization style for the ncWMS request. Common once are `default-scalar`, `colored_contours`, `contours` and `raster` colorbands : The number of discrete colours to plot the data. Must be between 2 and 250 (`NUMCOLORBANDS`) mincolor : The minimum of the `COLORSCALERANGE` used for plotting the data maxcolor : The minimum of the `COLORSCALERANGE` used for plotting the data palette : The palette used for visualization (see the `STYLES` parameter) logscale : `1` (true) or `0` (false) - whether to plot data with a logarithmic scale (`LOGSCALE) opacity : The opacity for the layer added to the map belowmincolor : The colour to plot values which are below the minimum end of the scale range. Colours are as defined in the [GetMap Docs][GetMap Docs], with the addition of "extend", which will use the minimum value of the palette. (`BELOWMINCOLOR`) abovemaxcolor : The colour to plot values which are above the maximum end of the scale range. Colours are as defined in the [GetMap Docs][GetMap Docs], with the addition of "extend", which will use the maximum value of the palette. (`ABOVEMAXCOLOR`) nodatacolor : The colour to plot missing values (`NaN`). Colours are as defined in the [GetMap Docs][GetMap Docs], with the addition of "extend", which will use the maximum value of the palette. (`BGCOLOR`) [GetMap Docs]: https://reading-escience-centre.gitbooks.io/ncwms-user-guide/content/04-usage.html#getmap (connect-datasource)= ## Connecting to a datasource To connect to a data source, created as described above, click the ncWMS widget in the experience builder and toggle the _Connect to data_ switch in the _Data Sources_ section ![connect data switch](screenshots/connect-data-switch.png) Once enabled, you will see a _Select data_ button. ![select data button](screenshots/select-data-button.png) Once clicked, another sidebar pops up where you can choose the data. If you don't see any data source, click the _Add new data_ button at the bottom and in the upcoming window, you should be able to select _Layers_ in the left sidebar where you then find your layer you created above. Select it and click _Done_. Now you can select the data source and it will be used to populate the widget. [datasource-docs]: https://doc.arcgis.com/en/experience-builder/latest/build-apps/select-data.htm [dasf-experiencebuilder-plugin]: https://codebase.helmholtz.cloud/dasf/dasf-experiencebuilder-plugin