The GeojsonTiler is a Python tiler which creates 3DTiles (.b3dm) from Geojsons files. The tiler also creates .obj models.
Geojson files contain features. Each feature corresponds to a building and has a geometry field. The geometry has coordinates. A feature is tied to a properties containing data about the feature (for example height, precision, feature type...).
The Geojson files are computed with QGIS from IGN public data.
To execute the GeojsonTiler, use the flag -i
followed by paths of Geojson files or directories containing Geojson files
Example:
geojson-tiler -i ../../geojsons/file.geojson
It will read file.geojson and parse it into 3DTiles.
geojson-tiler -i ../../geojsons/
It will read all .geojson and .json in the geojsons directory and parse them into 3DTiles.
geojson-tiler -i ../../file_1.geojson ../../geojsons
It will read file_1.geojson and all .geojson and .json in the geojsons directory, and parse them into 3DTiles.
By default, the tiler considers that the polygons in the .geojson files are at the floor level. But sometimes, the coordinates can be at the roof level (especially for buildings). In this case, you can tell the tiler to consider the polygons as roofprints by adding the --is_roof
flag. The tiler will substract the height of the feature from the coordinates to reach the floor level.
geojson-tiler -i <path> --is_roof
When present, the --add_color
add a single colored material to each feature. The color of the material is determined by the value of a selected property for each feature.
If the property is numeric, we create a heatmap by interpolating the minimal and the maximal colors.
If the property is semantic, we choose the color depending on the value of the property. The color to use for each value must be specified in the color dictionary.
The flag takes 2 arguments: the name of the property and its type ('numeric' or 'semantic'). If only the name is given, the type will be 'numeric' by default. If no argument is given with the flag, the colors won't be added.
Example for numeric property:
geojson-tiler -i <path> --add_color HEIGTH numeric
Example for semantic property:
geojson-tiler -i <path> --add_color NATURE semantic
The default colors are defined by a JSON file. If you want to change the colors used, update the file with the right color codes. (See Color module for more details)
The Tiler uses 'height' property to create 3D tiles from features. The 'width' property will be used only when parsing LineString or MultiLineString features. This width will define the size of the buffer applied to the lines.
The Tiler also uses the 'prec' property to check if the altitude is usable and skip features without altitude (when the altitude is missing, the prec is equal to 9999, so we skip features with prec >= 9999).
A 'z' property can be used to specify a Z value used for all the coordinates of the feature's geometry. By default, the Z will be the values in the coordinates.
By default, those properties are equal to:
- 'prec' --> 'PREC_ALTI'
- 'height' --> 'HAUTEUR'
- 'width' --> 'LARGEUR'
- 'z' --> use the Z from the coordinates
It means the tiler will target the property 'HAUTEUR' to find the height, 'LARGEUR' to find the width and 'PREC_ALTI' to find the altitude precision. The tiler won't override the Z values by default.
If the file doesn't contain those properties, you can change one or several property names to target in command line with --height
, --width
or --prec
. If the features don't have a Z (2D features), a Z can be targeted with --z
.
geojson-tiler -i <path> --height HEIGHT_NAME --width WIDTH_NAME --prec PREC_NAME --z Z_NAME
You can set the height, the width or the Z to a default value (used for all features). The value must be an int or a float:
geojson-tiler -i <path> --height 10.5 --width 6.4 --z 100
If you want to skip the precision, you can set prec to 'NONE':
geojson-tiler -i <path> --prec NONE
You can use the flag -k
or --keep_properties
to store the properties of the GeoJSON features in the batch table. All the properties of each feature will be stored.
geojson-tiler -i <path> --keep_properties