qgis / QGIS

QGIS is a free, open source, cross platform (lin/win/mac) geographical information system (GIS)
https://qgis.org
GNU General Public License v2.0
10.44k stars 2.99k forks source link

ArcGIS ImageServer Multi-Band Imagery #47640

Open tpwrules opened 2 years ago

tpwrules commented 2 years ago

Feature description

Currently, attempting to connect to an ArcGIS image server (e.g. NAIP/USDA_CONUS_PRIME on the REST server https://gis.apfo.usda.gov/arcgis/rest/services) renders as singleband color data.

However, adding the bandIds query parameter to the exportImage endpoint would allow the band mapping to be configured and allow multiband color rendering. For example, bandIds=0,1,2 requests RGB data, bandIds=3,0,1 requests colored IR, and so forth. It would be nice to add this and a corresponding multiband color option.

Additional context

I am investigating the possibility of writing a PR to implement this but I don't know much about QGIS internals.

nyalldawson commented 2 years ago

@tpwrules quick hint if you're writing this: focus intially on adding support for a bands= parameter in the source Uri for the qgis layer, which gets turned into the corresponding url parameter in the ams provider's requests. Require users to manually create layers initially with this Uri parameter set, and ignore the GUI component till this works.

nyalldawson commented 2 years ago

Specifically checkout how the referer is used here: https://github.com/qgis/QGIS/blob/734dae74da1dd7de7ad495befa674e1efd558ffb/src/providers/arcgisrest/qgsamsprovider.cpp#L199

tpwrules commented 2 years ago

@nyalldawson yeah, I saw that and was going to start there. But the funny thing is I'm a very new QGIS user and couldn't figure out how to modify the source URI of the layer. I just added it by adding the ArcGIS REST server and double clicking on the corresponding item. Do you have a pointer there?

nyalldawson commented 2 years ago

Copy the existing Uri for a layer, then create a new QgsRasterLayer via PyQGIS with the modified Uri

Or use

iface.activeLayer().setDataSource(...)

https://qgis.org/pyqgis/master/core/QgsMapLayer.html#qgis.core.QgsMapLayer.setDataSource

tpwrules commented 2 years ago

Okay, I'll give that a try. Is there not a GUI option? I fear the feature won't be very useful if it's not easy to modify the URI, and I probably won't submit a PR until I can get the GUI color selector working. But this is definitely helpful for development.

nyalldawson commented 2 years ago

There is definitely ways to handle the UI for this, but if you're new to qgis dev then it's best to start with a small atomic change which doesn't touch UI. (Otherwise you'll need to learn the qt UI framework too, which is another layer again!).

Ideally this would be exposed through the browser panel somehow -- eg showing child items with the available bands for ims service layers. But again, that's another part of the qgis code to get your head around 😝

tpwrules commented 2 years ago

It seems ArcGIS only provides this option with the exportImage endpoint that is only used in tiled='false' mode. I can't get that mode to work, so maybe there is some other underlying bug. This might not be feasible in the general case.