cityjson / cityjson-qgis-plugin

A QGIS plugin that adds support for CityJSON files
Apache License 2.0
35 stars 8 forks source link

Roof Surfaces Double Geometries on QGIS: WHY? #49

Open misonishiki opened 2 years ago

misonishiki commented 2 years ago

Yooooooooo

I'm not that suave in my understanding of CityJSON models. What I did was filter out roof surfaces as an attribute of interest. This is what I get:

Screenshot 2022-06-15 at 08 41 23

Yes, the pale green is a nice touch, but upon calculating roof surface values through a DSM model, I realised there were duplicate geometries. So, I isolated the double geometries:

Screenshot 2022-06-15 at 08 42 50

If semantic roof values are basically points and lines transformed on a coordinate, why are there double geometries present in the data? Is this just on QGIS or is this also the case on CityJSON?

liberostelios commented 2 years ago

Yo @misonishiki!

First of all, welcome to the CityJSON world. 🙏

I am not entirely sure that I understand your question. Semantic roof values aren't points or lines. They are attributes attached to the polygons of the roofs themselves.

I am, also, not sure why you are getting duplicate geometries. You said you filtered for roof surfaces only? Keep in mind that, whilst the data are 3D QGIS processing cannot cope with it correctly most of the times so it treats the geometries as 2D. So, if you left there both roof and ground surfaces, QGIS might be treating them as duplicates (because they have the same 2D projection).

Which model is this one? Could you possibly share the data? You might, also, want to inspect the geometry itself in 3D through ninja, to get a better understanding of how the geometry is stored.

misonishiki commented 2 years ago

Nice, that's exactly what I mean by I'm not sure what is going on here. I can rephrase, the question is why are there double geometries?

I uploaded the CityJSON model via the plugin on QGIS. It's tile 3693 from the 3DBag. I extracted polygons by attribute = roofsurface, which is stored in the LoD2.2 layer. So QGIS is processing only what polygon/feature is labelled roof surface. So I don't think I have both roof and ground surfaces, I merely extracted only 'roof' features. Which is why I'm a bit confused on the double geometries. Essentially I'm using it to calculate the surface area of the roofs

I converted a DEM of the area of interest with SAGA's real surface area and then used zonal statistics to sum up the surface area pixels within each roof polygon. I assume I could do this directly using cjio but it's definitely not my forte...maybe if I had help but yeah...with the double geometries, I'm trying to figure how to fix the error on QGIS to get more accurate results

liberostelios commented 2 years ago

Thanks for clarifying.

I just downloaded the dataset and checked and couldn't find any duplicate geometries. Here are my steps:

I got 3805 geometries for the whole tile after extracting only the roof surfaces and same number of features after I deleted the duplicates. Can you reproduce?

misonishiki commented 2 years ago

Step 1: Uploading via processing toolbox Screenshot 2022-06-15 at 10 51 59

And then got a python error! already...damn. :(

So I reinstalled the plugin, but python error keeps occurring. This is only the case when I open it through the processing toolbox.

2022-06-15T10:57:27 WARNING Traceback (most recent call last): File "/Applications/QGIS.app/Contents/MacOS/../Resources/python/plugins/processing/gui/AlgorithmDialog.py", line 273, in runAlgorithm 'parameters': self.algorithm().asMap(parameters, self.context) Exception: unknown

liberostelios commented 2 years ago

This is weird. Which QGIS version is this?

misonishiki commented 2 years ago

QGIS Version 3.24.3-Tisler

liberostelios commented 2 years ago

You are right, I just checked. There seems to be an issue with QGIS 3.24.3 on macOS. Not sure if this has something to do with the plugin or the specific release of QGIS. Thanks for figuring it out! 🙏

Regarding the original issue, though, I can reproduce the same results as I posted before even going through the old dialog import way, that I suppose you used before. This is what I get:

Screenshot 2022-06-15 at 13 10 39
misonishiki commented 2 years ago

Yes! I also get 3805 <3 Will try the operation once more to see the surface area, thanks Stelios! Not sure if it'll be the further operations that may create double geometries but I'll keep you updated if so

liberostelios commented 2 years ago

Awesome! Glad that I was helpful. 🙏

Yes, please, if you can find out which part of your workflow created the duplicates I'd be interested to know.

Also, please be aware that you cannot trust QGIS's area function as it only computes the 2D area of a geometry (i.e., the area of the projected polygon on the horizontal plane).

Here is the difference between a true 3D area calculation (on the left) and QGIS's original area calculation (on the right) for the specific 3D BAG tile:

Screenshot 2022-06-15 at 15 10 57

If you want to know how I calculated the 3D area, I have this prototype plugin of 3D operations that I've built last summer which I can share with you. Please, feel free to contact me about this. If you have another way to compute the area in 3D, I'd be curious to know it.