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

Roof Surfaces Double Geometries on QGIS: WHY? #49

Open
misonishiki opened this issue Jun 15, 2022 · 9 comments
Open

Roof Surfaces Double Geometries on QGIS: WHY? #49

misonishiki opened this issue Jun 15, 2022 · 9 comments

Comments

@misonishiki
Copy link

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
Copy link
Contributor

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
Copy link
Author

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
Copy link
Contributor

Thanks for clarifying.

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

  • Import the dataset from the processing toolbox with the following parameters:
processing.run("cityjsonloader:loadcityjson", {'INPUT':'/Users/liberostelios/Downloads/3dbag_v210908_fd2cee53_3693.json','DIVIDE_BY_OBJECT_TYPE':False,'LOD_AS':2,'LOAD_SEMANTIC_SURFACES':True,'STYLE_BY_SEMANTIC_SURFACES':False,'SRID':QgsCoordinateReferenceSystem('EPSG:28992'),'BBOX':None,'OBJECT_TYPE':[]})
  • Extract by attribute (only for the LoD2.2 layer):
processing.run("native:extractbyattribute", {'INPUT':'memory://MultiPolygon?crs=EPSG:28992&uid={299850c6-62b8-48ca-80ce-023336c01264}','FIELD':'surface.type','OPERATOR':0,'VALUE':'RoofSurface','OUTPUT':'TEMPORARY_OUTPUT'})
  • Delete duplicate geometries:
processing.run("native:deleteduplicategeometries", {'INPUT':'memory://MultiPolygon?crs=EPSG:28992&field=uid:string(0,0)&field=type:string(0,0)&field=parents:string(1000,0)&field=children:string(1000,0)&field=attribute.dak_type:string(0,0)&field=attribute.data_area:string(0,0)&field=attribute.data_coverage:string(0,0)&field=attribute.documentnummer:string(0,0)&field=attribute.geconstateerd:string(0,0)&field=attribute.gid:string(0,0)&field=attribute.h_dak_50p:string(0,0)&field=attribute.h_dak_70p:string(0,0)&field=attribute.h_dak_max:string(0,0)&field=attribute.h_dak_min:string(0,0)&field=attribute.h_maaiveld:string(0,0)&field=attribute.identificatie:string(0,0)&field=attribute.kas_warenhuis:string(0,0)&field=attribute.lod11_replace:string(0,0)&field=attribute.ondergronds_type:string(0,0)&field=attribute.oorspronkelijkbouwjaar:string(0,0)&field=attribute.pw_actueel:string(0,0)&field=attribute.pw_bron:string(0,0)&field=attribute.reconstructie_methode:string(0,0)&field=attribute.reconstruction_skipped:string(0,0)&field=attribute.rmse_lod12:string(0,0)&field=attribute.rmse_lod13:string(0,0)&field=attribute.rmse_lod22:string(0,0)&field=attribute.rn:string(0,0)&field=attribute.status:string(0,0)&field=attribute.t_run:string(0,0)&field=attribute.val3dity_codes_lod12:string(0,0)&field=attribute.val3dity_codes_lod13:string(0,0)&field=attribute.val3dity_codes_lod22:string(0,0)&field=attribute.voorkomenidentificatie:string(0,0)&field=lod:string(0,0)&field=surface.type:string(0,0)&field=surface.on_footprint_edge:string(0,0)&uid={6510ee43-46fe-4a82-bf8e-4a5f01317a45}','OUTPUT':'TEMPORARY_OUTPUT'})

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
Copy link
Author

misonishiki commented Jun 15, 2022

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
Copy link
Contributor

This is weird. Which QGIS version is this?

@misonishiki
Copy link
Author

QGIS Version 3.24.3-Tisler

@liberostelios
Copy link
Contributor

liberostelios commented Jun 15, 2022

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
Copy link
Author

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
Copy link
Contributor

liberostelios commented Jun 15, 2022

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.

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

No branches or pull requests

2 participants