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.39k stars 2.98k forks source link

Incorrect elevation profile of a LineStringZ at both ends #54448

Open jfbourdon opened 1 year ago

jfbourdon commented 1 year ago

What is the bug or the crash?

It's not systematic, but for some of my LineStringZ, either the first or last segment (or both) are not represented correctly if I compare to the Z values of the vertices. In the case below, I have a LineStringZ that continuously drops from start to finish, but we can see at the arrows that the plot doesn't show the same story at both ends:

plot

Steps to reproduce the issue

  1. Create this LineStringZ:
layer = QgsVectorLayer("linestringZ?crs=epsg:6622", "linestringZ", "memory")
wkt = 'LineStringZ (-280010.5 179978.5 236.069000244140625, -280010.5 179977.5 236.0688018798828125, -280012.5 179975.5 236.051849365234375, -280013.5 179975.5 236.0516510009765625, -280016.5 179972.5 236.051055908203125, -280017.5 179972.5 236.05084228515625, -280023.5 179966.5 235.8927001953125, -280025.5 179966.5 235.892303466796875, -280027.5 179964.5 235.89190673828125, -280028.5 179964.5 235.7825164794921875, -280029.5 179963.5 235.782318115234375, -280030.5 179963.5 235.7821197509765625, -280033.5 179960.5 235.7815093994140625, -280035.5 179960.5 235.484954833984375, -280037.5 179958.5 235.29376220703125, -280038.5 179958.5 235.280914306640625, -280039.5 179957.5 235.2727203369140625, -280042.5 179957.5 235.2545013427734375, -280043.5 179956.5 235.254302978515625, -280046.5 179956.5 235.118255615234375, -280047.5 179955.5 235.117156982421875, -280048.5 179955.5 235.1169586181640625, -280050.5 179953.5 235.1165618896484375, -280051.5 179953.5 234.9947967529296875, -280053.5 179951.5 234.8652191162109375, -280054.5 179951.5 234.865020751953125, -280055.5 179950.5 234.8648223876953125, -280058.5 179950.5 234.8065338134765625, -280059.5 179949.5 234.80633544921875, -280060.5 179949.5 234.783782958984375, -280061.5 179948.5 234.755035400390625, -280062.5 179948.5 234.73138427734375, -280065.5 179945.5 234.667816162109375, -280066.5 179945.5 234.6676177978515625, -280068.5 179943.5 234.6063232421875, -280069.5 179943.5 234.572723388671875, -280070.5 179942.5 234.5725250244140625, -280072.5 179942.5 234.5721282958984375, -280073.5 179941.5 234.54888916015625, -280074.5 179941.5 234.529083251953125, -280075.5 179940.5 234.5288848876953125, -280078.5 179940.5 234.528289794921875, -280079.5 179939.5 234.528076171875, -280080.5 179939.5 234.5278778076171875, -280082.5 179937.5 234.4928131103515625, -280086.5 179937.5 234.4521026611328125, -280087.5 179936.5 234.381256103515625, -280088.5 179936.5 234.3810577392578125, -280089.5 179935.5 234.380859375, -280090.5 179935.5 234.3610687255859375, -280091.5 179934.5 234.333221435546875, -280092.5 179934.5 234.3330230712890625, -280093.5 179933.5 234.3267059326171875, -280094.5 179933.5 234.326507568359375, -280095.5 179932.5 234.294189453125, -280096.5 179932.5 234.258453369140625, -280098.5 179930.5 234.237274169921875, -280099.5 179930.5 234.1858978271484375, -280100.5 179929.5 234.185699462890625, -280101.5 179929.5 234.1451873779296875, -280102.5 179928.5 234.144989013671875, -280103.5 179928.5 234.1447906494140625, -280104.5 179927.5 234.14459228515625, -280105.5 179927.5 234.138336181640625, -280107.5 179925.5 234.0925750732421875, -280108.5 179925.5 234.092376708984375, -280110.5 179923.5 234.021575927734375, -280112.5 179923.5 233.9473419189453125, -280115.5 179920.5 233.900360107421875, -280116.5 179920.5 233.89520263671875, -280117.5 179919.5 233.83599853515625, -280118.5 179919.5 233.8358001708984375, -280119.5 179918.5 233.835601806640625, -280120.5 179918.5 233.8301849365234375, -280122.5 179916.5 233.790313720703125, -280123.5 179916.5 233.7901153564453125, -280124.5 179915.5 233.784576416015625, -280125.5 179915.5 233.7457427978515625, -280126.5 179914.5 233.74554443359375, -280132.5 179914.5 233.628143310546875, -280133.5 179913.5 233.6036376953125, -280134.5 179913.5 233.6034393310546875, -280136.5 179911.5 233.602691650390625, -280137.5 179911.5 233.6024932861328125, -280138.5 179910.5 233.602294921875, -280138.5 179909.5 233.6020965576171875, -280142.5 179905.5 233.4368743896484375, -280145.5 179905.5 233.30975341796875)'
geom = QgsGeometry.fromWkt(wkt)
fet = QgsFeature()
fet.setGeometry(geom)
layer.dataProvider().addFeature(fet)
QgsProject.instance().addMapLayer(layer)
  1. In the Elevation Panel of the new layer, change the Elevation Clamping to "Absolute" and the Profile Chart Appearrance Interpretation to "Continuous Surface (e.g. Contours)".
  2. Open the Elevation Profile and click on the line with the tool "Capture Curve From Feature" to plot the elevation profile.

Versions

QGIS 3.32.3 Windows 10 Enterprise 21H2

Supported QGIS version

New profile

Additional context

No response

jfbourdon commented 8 months ago

I tried the same steps on QGIS 3.34.3 and I now only get an incorrect profil at the end of the line:

Interestingly, the approximate value of the last vertex of line shown is different than the one with QGIS 3.32.3 (233.8346 vs 233.8225).

uprel commented 1 week ago

I had a similar issue and when testing found at that you need to set Individual features in Interpretation setting, here: image That way you get correct values in profile and it makes sense since we want to display specific feature. Your example that way works correctly so I think you can check and close the issue. I tested with 3.34.7 and also latest master build.