Accessing Data from External Clients (QGIS)

Install QGIS Desktop

  • Open the Ubuntu Software app

    image

  • Click CTRL + F and search for qgis, click on the QGIS Desktop icon

    image

  • Click on INSTALL and wait for the process to finish

    image

  • Once the app has been installed, open it by clicking on the icon

    image

Connect through BASIC Auth

This is the easiest way to connect the client to GeoNode:

- Pros: very easy to configure
- Cons: it always uses a fixed user and you need to change it anytime if you want to switch user
  • Let’s add a VECTORIAL layer accessible to test_user1 to the client. Click on Layer > Add Layer > Add WFS Layer...

    image

  • Create a New Connection

    image

  • Provide a name, e.g. GeoNode WFS, and the following URL:

    • http://localhost/gs/ows

    image

    IMPORTANT: It is mandatory to pass through the GeoNode proxy /gs/ instead of hitting the GeoServer endpoint directly

  • If the client asks for a NEW master password you can provide any one (e.g. geonode)

    image

  • Switch to Basic authentication, provide the test_user1 credentials, and click on Convert to configuration

    image

  • Make sure the converted configuration is selected and click on Detect to verify that it works. Click on OK when finished

    image

Connect through OAuth2

This is the easiest way to connect the client to GeoNode:

- Pros: it redirects to GeoNode to authenticate, so you can use any login provided by GeoNode
- Cons: difficult to configure
  • We need to prepare GeoNode first, as an admin go to the Admin Dashboard and look for Django OAuth Toolkit > Applications

    image

  • Edit the GeoServer one

    image

  • Add the following URL to the Redirect URIs section and take note of the Client ID and Client Secret keys:

    • Copy the Client ID / Client Secret

    image

    • Add Redirect URIs and Save: http://127.0.0.1:7070/qgis-client

    image

  • Let’s add a VECTORIAL layer accessible to test_user1 to the client. Click on Layer > Add Layer > Add WFS Layer...

    image

  • Add a new OAuth2 Authentication config and fill the fields as follows:

    • Name: Provide any name you want, e.g. GeoNode OAuth2

    • Grant Flow: Authorization Code

    • Request URL: http://localhost/o/authorize/ (the / at the end is IMPORTANT!)

    • Token URL: http://localhost/o/token/ (the / at the end is IMPORTANT!)

    • Refresh token URL: http://localhost/o/token/ (the / at the end is IMPORTANT!)

    • Client ID / Client Secret: The ones above

    • Scope: openid write

    • Token session: True

    • Access method: Header

    • Token header: empty (it is important you leave this parameter empty)

    • Save

    image

  • Make sure the new configuration is selected, and click on Detect to verify that it works. Click on OK when finished

    image

  • The client will automatically open a browser session. If you are not logged in, sign in with admin (or whatever user you want).

  • The window below means that the authentication process was successful. You can safely close it and go back to the client

    image

Throubleshooting: if the QGIS client does not correctly redirect to the browser

  • Check that the Default Application for the WEB is set to Firefox

    image

  • If this is not the case, open a Terminal window and run the following command lines:

    sudo apt update
    sudo apt install firefox
    
  • Close the Firefox windows and try again.

Throubleshooting: if the QGIS client returns a redirect uri error code

  • In the case you get an error like this

    image

  • Check the URL on the browser location bar and make sure the redirect_uri is set to http://127.0.0.1:7070/qgis-client; if not, change it manually and refresh!

  • This should be also added to the GeoNode Oauth2 application.

Attach Layer to the Project

  • Once the connection has been configured and saved, whatever it is, go back to the WFS panel, select the connection you just created and click on Connect

    image

  • If everything goes well, you should be able to see the server offering. It will list all the layers the user has access to

    image

  • Select the Test Layer, and click on Add

    image

  • QGIS will create a new project with the layer already loaded and centered on the map

    image

Editing Contents: Values

  • Enable Editing Mode on QGIS, and click on the Info button

    image

  • Click over the geometry to edit, and on the right-hand panel, expand and click on the link Edit feature form

    image

  • That will show a small form with the values, change a few of them, and click on the OK button

    image

  • A small floppy disk button will enable near the editing one meaning that there are some pending changes to be committed to the server. Click on it in order to persist the changes

    image

  • After a successful commit, the floppy disk button will be disabled again

Editing Contents: Geometries

  • Enable Editing Mode on QGIS and click on the Info button

    image

  • Click on the Vertex Tool and enable it. From now on, you will be able to modify a geometry’s vertices by moving over it

    image

  • Once happy with the changes, save them as we have done previously with the values

    image

  • With this specific layer, you will most probably get an error on the bounding box extension. This is caused by the native projection of the layer, and QGIS not being able to correctly manage the dateline

    image

  • It is still possible to edit the layer from GeoNode directly. However, to fix this issue easily, we will convert the layer into a Mercator Projected one.

We will pass it through the database to perform such an operation. In the next section, we will see how to re-project and store a DB table in a layer and then push it back to GeoNode.

Next Section: Advanced layers publishing and management