Giter Site home page Giter Site logo

cityjson / cityjson-qgis-plugin Goto Github PK

View Code? Open in Web Editor NEW
35.0 7.0 8.0 302 KB

A QGIS plugin that adds support for CityJSON files

License: Apache License 2.0

Makefile 7.10% Python 88.29% Batchfile 2.34% Shell 1.39% QML 0.89%
qgis cityjson qgis-plugins metadata

cityjson-qgis-plugin's Introduction

CityJSON

GitHub tag (latest SemVer) GitHub license

This repository is where the specifications and the schemas of CityJSON are kept. All previous versions are kept in tags in the commits.

For all the details, see the official CityJSON website: https://cityjson.org.

What is CityJSON?

CityJSON is a JSON-based encoding for a subset of the OGC CityGML data model (version 3.0.0), which is an open standardised data model and exchange format (in GML) to store digital 3D models of cities and landscapes.

The aim of CityJSON is to offer an alternative to the GML encoding of CityGML, which can be verbose and complex (and thus rather frustrating to work with). CityJSON aims at being easy-to-use, both for reading datasets, and for creating them. It was designed with programmers in mind, so that tools and APIs supporting it can be quickly built, and several software have been created already.

Contributing to the project

We invite anyone to contribute to the development and improvement of CityJSON, all discussions, issues, and developments are open to everyone.

If you use CityJSON in an academic context, please cite this article

Ledoux H, Arroyo Ohori K, Kumar K, Dukai B, Labetski A, Vitalis S (2019). CityJSON: A compact and easy-to-use encoding of the CityGML data model. Open Geospatial Data, Software and Standards, 4:4 (DOI) (PDF)

cityjson-qgis-plugin's People

Contributors

athelena avatar liberostelios avatar paalped avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

cityjson-qgis-plugin's Issues

Add support for CityJSONFeature

It 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.

Import aglorithm is broken in 3.24.3 (macOS)

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)

Crash on loading in QGIS 3.10.0 on Linux

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
.

Change Altitude Clamping from Relative to Absolute

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

`referenceSystem` breaks if the url provided is an http

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:

  1. The property should be allowed to have an http:// url, and
  2. If this line breaks, an exception trap should be use to allow the user to continue.

AttributeError: 'CityJsonLoaderDialog' object has no attribute 'metadataPlainTextEdit'

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.

Load metadata separately

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 😅

Missing jsonref and jsonschema python packages

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...

Create layer group instead of prefix

I think it would be more convenient to have a layer group instead of prefixing the layers with the file name when the "Split by object type" option is checked. It makes it easier to manage the layers when there are layers from other sources as well in the project.

image

The "metadata" object should not be required

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.

Extracting only semantic roof surfaces for QGIS

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.

Screenshot 2022-06-15 at 07 36 51

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

Add support for surfaces semantics

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.

Semantic surfaces being dissolved

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.

Breaks on CityObject without geometry

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

Saving of a model

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.

Assign CRS on import

Currently if the data doesn't have a projection declared, its only possible to assign the CRS layer-by-layer. It would be nice if there was an option to choose a CRS instead of only displaying it when loading the file.

image

LoD1_solidsWithTIN

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.

The way semantic_colors is saved in Settings breaks QGIS during startup

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.

Moving to PostGIS?

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.

Plugin does not transform coordinates

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]
}

Import a subset with a polygon/bbox filter

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?

I got this error when I had try to install and load cityjson in qgis 3.10 ltr

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

Roof Surfaces Double Geometries on QGIS: WHY?

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?

Write support for CityJSON datasets

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.

Create parents as attribute

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"
],

CityJson.zip

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.