Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use the selected CRS as subsetting CRS #9

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jampukka
Copy link

Here's one solution to #8.
This is based on the assumption that the user would always select a CRS in the dialog that is equal to the current canvas CRS. This might not be the case.

Copy link
Owner

@marcusmohr marcusmohr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately this solution leads to another problem. The crs of the SUBSET coordinates in the query (which are taken from the map canvas) will no longer match SUBSETTINGCRS. The user would have always to choose a crs that matches the one of the map canvas. Otherwise an error will occur ("Image extent does not intersect with desired region."). To prevent this you'll have to transform the coordinates if SUBSETTINGSCRS doesn't match the destination CRS (map canvas).

@jampukka
Copy link
Author

jampukka commented Feb 11, 2022

Sorry for the inactivity. Your assessment is correct. Proper solution would be to find a crs string from wcs.getCRS() that matches the crs authid of the map canvas. For this I need to find or develop a function that can recognize and convert URL crs string to short authid format (e.g. http://www.opengis.net/def/crs/EPSG/0/3067 to EPSG:3067)

@kannes
Copy link

kannes commented Jun 1, 2023

QGIS 3.30 added QgsCoordinateReferenceSystem.toOgcUri():

>>> crs = QgsProject.instance().crs()
>>> crs.toOgcUri()
'http://www.opengis.net/def/crs/EPSG/0/4326'

@kannes
Copy link

kannes commented Jun 5, 2023

FYI I am working on this at the moment and will hopefully be able to present a nice solution soon-ish.

@kannes
Copy link

kannes commented Jun 7, 2023

Oh dear, this is overly complicated...

Services might support more CRS for subsetting if they support the CRS extension I guess. But then you need to find out the axis labels for making subset requests somehow and that is so complicated it drained any motivation from me. For the native CRS of a coverage those labels are included in the DescribeCoverage response but it seems virtually impossible to get those of other CRS from the server without making three million requests including third-party servers.

https://gis.stackexchange.com/questions/377221/where-do-i-find-crs-axis-names

https://gis.stackexchange.com/questions/461135/axes-labels-names-of-qgscoordinatereferencesystem

It would be possible to query QGIS' Proj's proj.db SQLite to get the names but that feels super icky (and hey, the server might have a different DB...) so I stopped there.

I rewrote the getCovQueryStr method to still use map canvas CRS but with correct handling of CRS URIs, axes, transformations etc to match the native CRS of the coverage. Because I also changed many other things I'll see if @marcusmohr is fine with all of them instead of investing too much time in a clean PR.

@kannes
Copy link

kannes commented Jun 8, 2023

It looks like it is fairly straightforward if we are ok with a subprocess run of projinfo. It can parse OGC URI strings and output nice PROJJSON which makes it easy to get the axis abbreviations. I'll see if I can get the time for writing something with that approach. Ref: https://gis.stackexchange.com/questions/461135/axes-labels-names-of-qgscoordinatereferencesystem/461311#461311

@kannes
Copy link

kannes commented Nov 30, 2023

FYI I am still sitting on half-finished work for this, should receive funding to continue working on it and finally contribute it to the project in Q1/2024. I hope!

@kannes kannes mentioned this pull request Nov 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants