domlysz / BlenderGIS

Blender addons to make the bridge between Blender and geographic data
GNU General Public License v3.0
7.6k stars 1.34k forks source link

Custom WMS as elevation #893

Open AbdelghaniTamort opened 3 months ago

AbdelghaniTamort commented 3 months ago

Blender and OS versions

Blender 4.1 Windows 10 Professional BlenderGIS latest release

Describe the bug

This isn't a bug but only a question that have been raised in https://github.com/domlysz/BlenderGIS/issues/158. Since it has been 5 years now I was wondering if it is now possible to import custom elevation from WMS even though it serves a 3 band geotiff (the elevation information is in the first band).

How to Reproduce

What I have been doing is trying to add the WMS GetMap request in the list named DEFAULT_DEM_SERVER of the prefs.py source code. It doesn't seem to be working which is quite anticipated.

Error message

DEBUG:BlenderGIS-2210.operators.io_get_dem:111:https://data.geopf.fr/wms-r/wms?SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&STYLES=normal&FORMAT=image/geotiff&LAYERS=ELEVATION.ELEVATIONGRIDCOVERAGE.HIGHRES&WIDTH=10000&HEIGHT=10000&CRS=EPSG:4326&BBOX=2.2941425720256485,48.84102834957891,2.37504687855078,48.88116715214006 ERROR:BlenderGIS-2210:96:Uncaught exception Traceback (most recent call last): File "C:\Users\atamort\AppData\Roaming\Blender Foundation\Blender\4.1\scripts\addons\BlenderGIS-2210\operators\io_get_dem.py", line 148, in execute bpy.ops.importgis.georaster( File "C:\Program Files\Blender Foundation\Blender 4.1\4.1\scripts\modules\bpy\ops.py", line 107, in call ret = _op_call(self.idname_py(), kw, C_exec, C_undo) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RuntimeError: Error: Non overlap data

AbdelghaniTamort commented 3 months ago

In other words, how to adjust the source code so it can allow for WMS handling along with REST for elevations models ?

domlysz commented 3 months ago

Since WMS 1.3.0 the order of bbox coordinates depends on the CRS. Systems with angular coordinates like EPSG:4326 use latitude as first axis. So the BBOX should be S,W,N,E

DEFAULT_DEM_SERVER = [
    ("https://data.geopf.fr/wms-r/wms?SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&STYLES=normal&FORMAT=image/geotiff&LAYERS=ELEVATION.ELEVATIONGRIDCOVERAGE.HIGHRES&WIDTH=5000&HEIGHT=5000&CRS=EPSG:4326&BBOX={S},{W},{N},{E}", 'Geoplateforme', 'Elevation data from IGN')
]

This url works but it miss a peace of code into _operators/io_getdem.py to correctly setup WIDTH and HEIGHT according to the target resolution of the DEM (meter/pixel).

AbdelghaniTamort commented 3 months ago

Oh I see, I just checked and it works indeed. So you also implemented this handling of WIDTH and HEIGHT according to target resolution for the Basemap I presume? Maybe if you guide me to which line in which file you implemented it I can reproduce the same for the DEM ?

domlysz commented 3 months ago

check this branch : https://github.com/domlysz/BlenderGIS/tree/wms_dem

The target res is hardcoded to 5m/pixel : https://github.com/domlysz/BlenderGIS/commit/b3e6a6a788913f3a23d4d893e9fe462a7fcbe63f

AbdelghaniTamort commented 3 months ago

alright, cool! So the WMS version of RGE ALTI's resolution is 5m and not 1m? Also there is a max height/width of 10000 imposed by the server, what happens if the user chooses an extent bigger than 10km * 10km ?