cityjson / cityjson-qgis-plugin Goto Github PK
View Code? Open in Web Editor NEWA QGIS plugin that adds support for CityJSON files
License: Apache License 2.0
A QGIS plugin that adds support for CityJSON files
License: Apache License 2.0
It would be nice to have the option to load the metadata as a separate file because sometimes it is stored separate to the parent dataset 😅
I'm loading a multi-lod file with BuildingBarts which has attributes only on the Building.
I load the file by splitting the lod-s to layers.
Then each lod-layer obtains the attributes from the Building, all with NULL, although they don't have attributes on their own.
File: https://data.3dbag.nl/cityjson/v210908_fd2cee53/3dbag_v210908_fd2cee53_5786.json
From CityJSON v1.1 the geometry
property is not mandatory anymore for CityObjects. If this is the case, the plugin breaks:
Traceback (most recent call last):
File "/home/balazs/.local/share/QGIS/QGIS3/profiles/balazs/python/plugins/CityJSON-loader/cityjson_loader.py", line 301, in run
self.load_cityjson(filepath)
File "/home/balazs/.local/share/QGIS/QGIS3/profiles/balazs/python/plugins/CityJSON-loader/cityjson_loader.py", line 323, in load_cityjson
skipped_geometries = loader.load()
File "/home/balazs/.local/share/QGIS/QGIS3/profiles/balazs/python/plugins/CityJSON-loader/core/loading.py", line 114, in load
self.layer_manager.add_object(key, obj)
File "/home/balazs/.local/share/QGIS/QGIS3/profiles/balazs/python/plugins/CityJSON-loader/core/layers.py", line 55, in add_object
new_features = self._feature_builder.create_features(self._fields, object_key, cityobject)
File "/home/balazs/.local/share/QGIS/QGIS3/profiles/balazs/python/plugins/CityJSON-loader/core/layers.py", line 230, in create_features
geom = self._geometry_reader.read_geometry(cityobject["geometry"])
KeyError: 'geometry'
File:
DH_01_subs.zip
It would be nice if there is an option to load semantic-surfaced layers with rule-based 3D renderer (which is available since 3.6).
Hi there,
I like to use the plugin with QGIS.
Is it possible to use CityGML data directly. So that they are converted to CityJSON when loading in QGIS?
So far I've always used https://github.com/citygml4j/citygml-tools. Can't be integrated into the plugin because of the java?
thanks
Stefan
Just came across this today with version 0.4.0:
Traceback (most recent call last):
File "/home/balazs/.local/share/QGIS/QGIS3/profiles/default/python/plugins/CityJSON-loader/gui/cityjson_loader.py", line 91, in select_cityjson_file
self.clear_file_information()
File "/home/balazs/.local/share/QGIS/QGIS3/profiles/default/python/plugins/CityJSON-loader/gui/cityjson_loader.py", line 123, in clear_file_information
self.dlg.metadataPlainTextEdit.setPlainText("")
AttributeError: 'CityJsonLoaderDialog' object has no attribute 'metadataPlainTextEdit'
Python version: 3.6.8 (default, Jan 14 2019, 11:02:34) [GCC 8.0.1 20180414 (experimental) [trunk revision 259383]]
QGIS version: 3.8.2-Zanzibar Zanzibar, e0a5e94093
Let me know if you need the data that I tried to load.
QGIS plugins are considered old-fashioned while processing algorithms are suggested instead. That might not only apply for loading CityJSON but could make a bunch of cjio operations (e.g. validate a city model, set CRS) available through the QGIS toolbox.
As per: https://media.ccc.de/v/bucharest-317-qgis-no-more-plugins-only-processings
Documentation: https://docs.qgis.org/3.4/en/docs/pyqgis_developer_cookbook/processing.html
Cityjson files can be very large and hit the max RAM during the import. It would be nice to select your desired area by drawing a polygon or bounding box on the screen before starting the import. Maybe even showing the cityjson data extent on the map?
This is a downside of fixing #43.
I suppose a solution would be to load all non-geometric features in their own layer when this option is enabled. It's neither straightforward to fix, nor very urgent so I'll just leave it as an open issue to be fixed in a later release.
See my thread on the dev list:
https://lists.osgeo.org/pipermail/qgis-developer/2020-July/061889.html
In short: I get a broken profile which crashes my QGIS, showing:
"Warning: QVariant::load: unknown user type with name PyQt_PyObject."
Looking into the QGIS3.ini I see
[CityJSON%20Loader]
semantic_colors\1\ambient=@Variant(\0\0\0\x7f\0\0\0\xePyQt_PyObject\0\0\0\0\x17\x80\x4\x95\f\0\0\0\0\0\0\0(K\xffK\0K\0K\xfft\x94.)
...
The object written to Settings is:
https://github.com/cityjson/cityjson-qgis-plugin/blob/main/core/settings.py#L6-L32
semantic_colors = {
"RoofSurface": {
"diffuse": QColor(255, 0, 0),
"ambient": QColor(255, 0, 0),
"specular": None
},
...
So we could wait if this is a SIP/Python issue or a Qt-version specific one (see if one of the core devs follows up on that thread)
Or we could think about saving the colors in another way in Settings.
Semantic surfaces are currently "dissolved" to the same feature based on their type. This is wrong as they might have more attributes that can separate them from each other.
Couldn't load plugin 'CityJSON-loader' due to an error when calling its classFactory() method
ValueError: could not convert string to float: '6378137.0.'
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/qgis/utils.py", line 334, in _startPlugin
plugins[packageName] = package.classFactory(iface)
File "/home/tomt/.local/share/QGIS/QGIS3/profiles/default/python/plugins/CityJSON-loader/init.py", line 35, in classFactory
from .gui.cityjson_loader import CityJsonLoader
File "/usr/lib/python3/dist-packages/qgis/utils.py", line 737, in _import
mod = _builtin_import(name, globals, locals, fromlist, level)
File "/home/tomt/.local/share/QGIS/QGIS3/profiles/default/python/plugins/CityJSON-loader/gui/cityjson_loader.py", line 39, in
from ..cjio import cityjson
File "/usr/lib/python3/dist-packages/qgis/utils.py", line 737, in _import
mod = _builtin_import(name, globals, locals, fromlist, level)
File "/home/tomt/.local/share/QGIS/QGIS3/profiles/default/python/plugins/CityJSON-loader/cjio/cityjson.py", line 15, in
import pyproj
File "/usr/lib/python3/dist-packages/qgis/utils.py", line 737, in _import
mod = _builtin_import(name, globals, locals, fromlist, level)
File "/usr/local/lib/python3.7/dist-packages/pyproj/init.py", line 81, in
from pyproj.crs import CRS # noqa: F401
File "/usr/lib/python3/dist-packages/qgis/utils.py", line 737, in _import
mod = _builtin_import(name, globals, locals, fromlist, level)
File "/usr/local/lib/python3.7/dist-packages/pyproj/crs.py", line 57, in
from pyproj.geod import Geod
File "/usr/lib/python3/dist-packages/qgis/utils.py", line 737, in _import
mod = _builtin_import(name, globals, locals, fromlist, level)
File "/usr/local/lib/python3.7/dist-packages/pyproj/geod.py", line 42, in
pj_ellps = get_ellps_map()
File "pyproj/_list.pyx", line 39, in pyproj._list.get_ellps_map
ValueError: could not convert string to float: '6378137.0.'
Python version: 3.7.5rc1 (default, Oct 8 2019, 16:47:45) [GCC 9.2.1 20191008]
QGIS version: 3.10.0-A Coruña A Coruña, 6c816b4204
Python Path:
/usr/share/qgis/python
/home/tomt/.local/share/QGIS/QGIS3/profiles/default/python
/home/tomt/.local/share/QGIS/QGIS3/profiles/default/python/plugins
/usr/share/qgis/python/plugins
/usr/lib/python37.zip
/usr/lib/python3.7
/usr/lib/python3.7/lib-dynload
/usr/local/lib/python3.7/dist-packages
/usr/local/lib/python3.7/dist-packages/cjio-0.6-py3.7.egg
/usr/lib/python3/dist-packages
/home/tomt/.local/share/QGIS/QGIS3/profiles/default/python
/usr/lib/python3/dist-packages/IPython/extensions
.
The plugin should be able to loads not only surfaces but solids.
Have you considered adding write support for CityJSON format? I would be interested in helping with the implementation if you are interested in having this kind of feature in the plugin.
I was really puzzled for a while why my LoD2 buildings were floating above the terrain in 3D views. Then I realised that the 3D settings for the loaded CityJSON layers was set to Relative Altitude Clamping. For terrain and buildings to match, I had to change it to Absolute.
This seems like an oversight or bug to me. Surely the buildings should be positioned in space with their absolute 3D coordinates?
QGIS 3.26.1, CityJSON-loader 0.8.1
When loading a file the plugin tries to figure if a file has declared a crs from the presence of the "referenceSystem" key in the "metadata" object. However, if the file doesn't have a crs declared, the "metadata" object might be missing completely, and still be a valid file. See minimal valid CityJSON at https://www.cityjson.org/specs/1.0.1/#cityjson-object
Currently if "metadata" is not in the file, the plugin returns a KeyError. Instead of KeyError it should set an Undefined CRS in QGIS.
In addition to the semantic surface type, any further attributes should be loaded as fields (when semantic surface loading is enabled).
Als ik 3D BAG als cityjson .json inlaad crashed Qgis bij het weergeven in 3D zonder melding. Allerlei opties geprobeerd.
https://youtu.be/9bhy5aeVles
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:
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:
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?
Hi.
I am unable to load a LoD1 CityModel into qgis successfully.
qgis=Zürich in a conda environment. (I've tried with an earlier version but it keeps crashing)
cityJSON=here.
The model loads into ninja. With qgis; the buildings (solids) fail to display. The tinrelief does.
The only settings: are defining the crs (EPSG:32733) and Split layers according to object type
.
I don't know if the following is relevant:
When passing parsing the model through val3dity the tinrelief fails ~ Error 305 MULTIPLE_CONNECTED_COMPONENTS.
Is this because the tin has isolated features (courtyards ~ interior of buildings) disconnected from the larger terrain?
Have I created the CityObject incorrectly? or am I not defining the qgis parameters correctly?
Your attention is appreciated.
Adrian.
Dear all,
first, thanks to the authors for contributing this plugin which makes it very convenient to work with 3D city data in QGIS! I am currently investigating options to share 3D models through PostGIS, and CityJSON appears to provide exactly the level of detail we will need. However, to have access to the 3D data (just as vector and raster data in 2D), I would need to store the models in my PostGIS database. Simply dragging the QGIS-Layer did not work since my PostGIS-Tables lack the z row. Would it be possible to support PostGIS as a storage for the CityJSON-models loaded into QGIS, or is this already possible and I just need to add a column to my tables? I could not find anything about this in the documentation.
Best, Lars.
Is it possible to pass the parent attribute in QGIS as an attribute when loading.
Otherwise I have entries and do not know which main entry they belong to.
"CityObjects": {
"UUID_fab50c6d-4cc0-45c7-ae1d-994de421c72c": {
"type": "BuildingPart",
"attributes": {
"measuredHeight": 7.251,
"creationDate": "2020-01-20",
"DatenquelleDachhoehe": "1000",
"Grundrissaktualitaet": "2020-01-01",
"DatenquelleLage": "1000",
"DatenquelleBodenhoehe": "1200",
"BezugspunktDach": "1000"
},
"parents": [
"DETHL57P0000QHJG"
],
Trying with Den Haag example dataset - it is using a transform, but the plugin does not apply the scale and translation, so the coordinates are completely wrong.
"transform": {
"scale":[0.001,0.001,0.001],
"translate":[78248.66,457604.591,2.463]
}
Currently there is no support for loading the semantic values of the surfaces. There should be a way to make this possible during loading, although layer features may have multiple multiple surface semantic values which makes things complicated.
I have been trying to load a file from the new 3D BAG (tile #5910 to be specific) and despite setting Load LoD:
to As Layers
I only get one layer, whereas there should be three.
QGIS version: 3.16.4-Hannover
Currently, we use a regular expression to parse the referenceSystem
, but it only expects a url that starts with https
. This breaks the loading of the file. Two things should be fixed:
http://
url, andIt should be part of #45, but extracting to its own issue as the rest of CityJSON v1.1 support should be fine for most use cases so far.
Couldn't load plugin 'CityJSON-loader' due to an error when calling its classFactory() method
ValueError: could not convert string to float: '6378137.0.'
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/qgis/utils.py", line 334, in _startPlugin
plugins[packageName] = package.classFactory(iface)
File "/home/sigma/.local/share/QGIS/QGIS3/profiles/default/python/plugins/CityJSON-loader/init.py", line 35, in classFactory
from .cityjson_loader import CityJsonLoader
File "/usr/lib/python3/dist-packages/qgis/utils.py", line 743, in _import
mod = _builtin_import(name, globals, locals, fromlist, level)
File "/home/sigma/.local/share/QGIS/QGIS3/profiles/default/python/plugins/CityJSON-loader/cityjson_loader.py", line 33, in
from .cjio import cityjson
File "/usr/lib/python3/dist-packages/qgis/utils.py", line 743, in _import
mod = _builtin_import(name, globals, locals, fromlist, level)
File "/home/sigma/.local/share/QGIS/QGIS3/profiles/default/python/plugins/CityJSON-loader/cjio/cityjson.py", line 15, in
import pyproj
File "/usr/lib/python3/dist-packages/qgis/utils.py", line 743, in _import
mod = _builtin_import(name, globals, locals, fromlist, level)
File "/usr/local/lib/python3.7/dist-packages/pyproj/init.py", line 81, in
from pyproj.crs import CRS # noqa: F401
File "/usr/lib/python3/dist-packages/qgis/utils.py", line 743, in _import
mod = _builtin_import(name, globals, locals, fromlist, level)
File "/usr/local/lib/python3.7/dist-packages/pyproj/crs.py", line 57, in
from pyproj.geod import Geod
File "/usr/lib/python3/dist-packages/qgis/utils.py", line 743, in _import
mod = _builtin_import(name, globals, locals, fromlist, level)
File "/usr/local/lib/python3.7/dist-packages/pyproj/geod.py", line 42, in
pj_ellps = get_ellps_map()
File "pyproj/_list.pyx", line 39, in pyproj._list.get_ellps_map
ValueError: could not convert string to float: '6378137.0.'
Python version: 3.7.3 (default, Jul 25 2020, 13:03:44) [GCC 8.3.0]
QGIS version: 3.10.9-A Coruña A Coruña, bf47e9d
with something more informative. alsso, the html should be removed.
thanks.
Hi guys!
I'm using LoD2.2 data on QGIS from the 3DBag (Tile 3693). Goal: Isolate roof surface polygons to calculate surface area and slope (using QGIS). However, when I select only roof surfaces in QGIS, it is incomplete, as you can see (selected roof surfaces are coloured as highlighter yellow). I'm not sure why this is the case... was wondering what you folks think.
I have two options at this point in time:
(1) Complete roof surfaces should/must be available on cityJSON...so I would have to extract directly from the CityJSON model using cjio?...I've followed the tutorial on cjio but I must admit, this does NOT come naturally to me.
(2) This is normal. CityJSON isn't perfect, fill in the other roof surfaces manually on QGIS
HELP HELP HELP
HELP <3
When importing a CityJSON file through the toolbox, the following Python error occurs:
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
Originally posted by @misonishiki in #49 (comment)
it'd be very useful to have the possibility to save an opened model.
Like we open a model, delete a few objects, and then save a subset to a new CityJSON file.
Helsinki has both LoD1 and LoD2 in their dataset. This should be possible to be parsed.
Currently, only the semantic surface type is loaded.
Trying to run the plugin on Ubuntu 18.04 I get this:
Couldn't load plugin 'CityJSON-loader' due to an error when calling its classFactory() method
ModuleNotFoundError: No module named 'jsonref'
jsonref module is not even in ubuntu/debian package repository, I had to use python3 -m pip install jsonref
On the next start, there was another missing package:
ModuleNotFoundError: No module named 'jsonschema'
This one is available in ubuntu/debian as python3-jsonschema
package.
Maybe it would be good to ship these python packages with the plugin as they are not automatically installed and users may have troubles installing those manually...
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.