GeoJSON
What is GeoJSON
GeoJson is a file format for geographical data. It is a simple text-based format which can be read by humans, but also by computers. Any Geo Data file can be converted to a GeoJSON file, so that it can be loaded in the Tygron Engine.
How to create a GeoJSON file
To convert a Geo Data set so that it meets these requirements, for example a GIS (Geographical Information System) can be used. ArcGIS Desktop is one example. An open-source alternative is QGIS.
Any GeoJSON file must conform to a number of prerequisites before it can be loaded properly. Files which do not conform to these prerequisites may not be loaded properly by the Tygron Engine.
- The file must be saved in GeoJSON format
- The file must use character encoding UTF-8.
- All desired attributes must be numerical, so that they can be loaded as valid attribute values. Non-numeric attributes are ignored when attempting to load them as attributes. If any attribute is not numerical, the values of that attribute must either be changed to be valid numbers, or a new attribute must be created with a numerical value based on the desired attribute.
- Open the Geo Data file in a GIS, for example QGIS
- If necessary, make sure all desired attributes are numeric
- Save the file in GeoJSON format with encoding UTF-8
Below are the steps described in more detail for creating a GeoJSON file in QGIS. QGIS offers a free, open-source alternative.
Open a Geo Dataset
First open a Geo Data file in QGIS. It's possible to load a file either by dragging it directly into the QGIS window, or by selecting it in the "Browser" panel in the QGIS window. The file will appear in the "Layers" panel, and its contents will be displayed as shapes or polygons in the main view.
Modifying attributes
If the Geo Data file contains attributes that need to be imported as well, those attributes need to be numbers, conforming to the requirements of attributes in the Tygron Engine. If there are attributes that need to be imported which are not numeric, those attributes can be used for creating new attributes. A new attribute can be calculated, with its data type set to either "integer" or "real" (with some precision), and a value based on the value of the original attribute. This process must be repeated for each attribute that needs to be imported. When this is done, the result will be a set of attributes which can be imported into the engine.
- QGISAttributeMenu.jpg
The "Open Attribute Table" option in the menu
- QGISAttributeTable.jpg
The Attribute Table shows the attributes of all shapes
- QGISFieldCalculatorMenu.jpg
The "Field Calculator" option in the menu
- QGISFieldCalculator.jpg
The "Field Calculator" window
- QGISAttributeTableDone.jpg
The Attribute Table now contains a new numeric attribute
- Select Layer → Open Attribute Table
- Select the "Field Calculator" option
- Set an "Output field name" for the new field
- Set the "Output field type" to "integer" or "real"
- Set the "Output field width" and "precision", so that the desired numeric values will fit in the field
- Create an expression which indicates how the field should be calculated
- Select "OK"
- Repeat steps 2 through 7 for all desired attributes
Saving
The last step is to save the file as a GeoJSON file. This can be done by clicking on the specific layer with the right mouse button and selecting the "Save as" option. Choose the GeoJSON format, a location and file name and a character set (which should be UTF-8). Saving will create a new ".geojson" file with all the desired data, ready to import into the Tygron Engine.
- QGISSaveAs.jpg
The "Save vector layer as..." window
- Right-click the layer
- Select Save As...
- Set the Format to "GeoJSON"
- Use "Browse" to select a name and location for the resulting file
- Set the CRS to "EPSG:3857 WGS 84/Pseudo Mercator"
- Set the encoding to "UTF-8"
- Select "OK" to save the file
How to load a GeoJSON file into the engine
The Tygron Engine can be provided with a GeoJSON file, either by dragging-and-dropping the relevant file into the Tygron Engine, or by selecting "Import GeoJSON File" from the relevant Ribbon dropdown menu in the Tygron Engine.
- When using the dropdown menu, a file-selection screen will appear, so that the relevant GeoJSON file can be selected.
- When a GeoJSON file is dragged-and-dropped into the Engine, a window will appear, so that the type of import can be selected (i.e. what kind of component to create based on the data in the file).
Import options
After selecting a data type, a new window will appear, which allows configuring how the data will be interpreted. Some options are present for all data types. A few are only applicable for specific data types.
File selection
A GIS file can contain a number of features, but when importing them into the Tygron Engine, only the features which lie within the 3D world. When importing a file, at least one feature of the GIS file should be present in the 3D world, or it is not possible to load data from that file.
Merge polygons
It is possible to merge all features into a single polygon. This can be useful when the there just needs to be a test for the presence of the data itself, and any subdivision in that data is not relevant for the project. Be carefull when using this options, as it may lead to very large polygons, which may result in a decrease in performance.
Filter polygons
When desired, it is possible to filter which features to import into the project. When the filter option is selected, some additional fields become available, which allow for the selection of an attribute and a value to filter on. Only features, the indicated attribute of which has the value entered, will be included in the import. There will be a display of how many features are selected based on the currently selected attribute and value. To help input a valid value, there is also an option to display all valid values for that attribute.
Name
Some components in the project can be named, such as constructions and areas. For these components, it is possible to select an attribute which will dictate the names of the imported features. If no specific attribute is selected to base a name on, the components are named after the file currently being imported.
Datatype-specific options
Depending on the desired data type, some additional options are available or required to import the file.
Function
- Relevant when importing as constructions.
When importing data as constructions, a function must be selected for the created constructions. If no function is selected, the "Send" button will not be available. All constructions resulting from this import will have this function with its default values. If any construction values need to be imported as well, it's possible to perform a second import for the construction values, after completing this import.
Construction Value
- Relevant when importing as construction values.
When importing data as construction values, its necessary to indicate which construction value is updated based on which attribute in the GeoJSON file. The first selection box allows for the selection of an attribute from the file. The second selection box allows for the selection of a specific construction value which needs to be changed. It's also possible to set a multiplies. The value from the file will be multiplies by the multiplier, and then used to update the construction value.
Attribute
- Relevant when importing as constructions or areas.
When importing data as constructions or areas, it may be desirable to not just load the proper shapes into the project, but to provide them with their attributes as well. For each attribute found in the GeoJSON file, it's possible to select whether the attribute should be imported or not. The desired name of the attribute as it appears in the project can be changed, and a multiplier can be set for the attribute.
Send
When all options have been set properly, the "Send" button can be used to start the actual import process. When this option is selected, the selected features in the GeoJSON file will be imported into the project. When importing new components, they will appear in the appropriate menus. When updating existing data (such as construction values), the properties of those components will be changed to reflect the values in the file.