geco-nhm / nin-qgis-plugin

Other
4 stars 0 forks source link

Add WMS background map #13

Closed peterhor closed 2 months ago

peterhor commented 3 months ago

In the QGIS project, we want to add a background map.

9ls1 commented 3 months ago

Have tested adding WMS (using the latest URL from Kartverket ongoing work with changing URL-addresses) for

"scale Norway" means you may zoom to the layer and the layer will be visible. (Not the case for AR5 unless you zoom in to appr. 1:45 000).

Perhaps as default we could zoom to layer Norgeskart gråtone.

  1. From this startingpoint, the user zoom in to the area of interesest.
  2. The user may export the wms (or canvas) as COG (cloud optimized geotiff)

Questions

  1. Which WMS may be handy? One, two, all mentioned above? Others?
  2. The zoom level may perhaps be according to the level of mapping (scale 1:20 000, 1:5000 or 1:750 when grunntyper?)?
  3. The scale could be set to little bit less, e.g. 1:25000, 1:7500, 1:1000?
  4. Where should I include the code? In project_setup.py?
peterhor commented 3 months ago

Perfect @9ls1. @lasseke commited implementation of Norgeskart in color yesterday db90d37, which is now selectable in the plugin. Replies:

  1. We could do the same for the rest of the layers you suggest (all of the mentioned), and the user will be able to choose.
  2. Zoom level at the plugin startup doesn't need to be adjusted - could stay "scale Norway". User will adjust
  3. Also not sure whether we need to adjust this?
  4. correct, inside https://github.com/geco-nhm/nin-qgis-plugin/blob/master/nin_qgis_plugin/project_setup.py
9ls1 commented 3 months ago
  1. OK
  2. OK, starting point will be "Norway" (since default will be "Topografisk Norgeskart farge"), and then the user will zoom into AOI.
  3. This is regarding the export image-option to avoid the user downloading a "too big area" making the raster file(s) very large.
  4. Perhaps the adding WMS-routine could be in a separate py-file making it easier find the lines in the python-file when updating (add/change) WMS-adressesses in future.
9ls1 commented 2 months ago

I have added the code for WMS topograatone and WMS nib the project_setup.py and nin_qgis_plugin_dialog_base.ui. However, no WMS-layer is appearing when I check 1, 2, or all 3 check boxes, and I can't figure out how to correct the code (no error is thrown, but the code doesn't react to the changes in the check boxes. @lasseke, I need help. 🙏 NB! NiB requires permission (the user must be a Norge digital-partner). May use NiB WMTS instead (less resolution)?

lasseke commented 2 months ago

Hey @9ls1! This was on me, the status of the checkboxes was retrieved only when the UI was initialized, not when the button was clicked... Commit fdcada4 should fix this. However, the "Norge i bilder" WMS layer doesn't seem to work, could you double-check if the URI string contains the correct information?

Also FYI, the snapping options you added throw a deprecation warning:

warning:C:\Users/lassetk/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\nin_qgis_plugin\project_setup.py:522: DeprecationWarning: IndividualLayerSettings constructor is deprecated
              snap_settings = QgsSnappingConfig.IndividualLayerSettings()

Not really a problem, but they apparently changed how this should be handled in newer pygis versions :) Thanks for your work!

lasseke commented 2 months ago

Ahh sorry @9ls1, I overlooked your comment about the NiB credentials in my last reply - this probably explains why the WMS layer doesn't load. I'd suggest we use the lower-resolution one in the interest of open accessibility, but I'm happy to go for the credential solution, too (might get a bit tricky regarding handling data security programmatically).

9ls1 commented 2 months ago

Also FYI, the snapping options you added throw a deprecation warning:

warning:C:\Users/lassetk/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\nin_qgis_plugin\project_setup.py:522: DeprecationWarning: IndividualLayerSettings constructor is deprecated
              snap_settings = QgsSnappingConfig.IndividualLayerSettings()

Not really a problem, but they apparently changed how this should be handled in newer pygis versions :)

Oh, we don't want to be to old fashioned, do we? :-) I'll look into it and will update the code soon.

9ls1 commented 2 months ago

Ahh sorry @9ls1, I overlooked your comment about the NiB credentials in my last reply - this probably explains why the WMS layer doesn't load. I'd suggest we use the lower-resolution one in the interest of open accessibility, but I'm happy to go for the credential solution, too (might get a bit tricky regarding handling data security programmatically).

I'll look into the WMTS-possibilty (no valid IP in the field any way I suppose).

9ls1 commented 2 months ago

Replaced wms with wmts, but NiB wmts is not loaded. May that be due to this is tile (looking differently in QGIS comparing with wms) and therefor the parameters need to be adjustet (something else)? image vs. image

9ls1 commented 2 months ago

Regarding the deprecation warning, I'll look into to it soon.

peterhor commented 2 months ago

wmts norge i bilder added in #38