GeoJSON

From Tygron Preview Support Wiki
Jump to navigation Jump to search
Please note: This page is currently being updated.

Template:Learned

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 Dataset in another format can be converted to the GeoJSON file format.

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.

The 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 requirements are:

  • 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. Attributes with text values are ignored when attempting to load them as attributes.


How to create a GeoJSON file:
  1. Open the Geo Dataset in a GIS
  2. Optional: make sure all desired attributes are numerical
  3. Save the file in GeoJSON format with encoding UTF-8

How to create a GeoJSON file in QGIS

These steps for creating a GeoJSON file in QGIS are described in more detail below.

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


2. Optional: 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.


How to create fields for attributes which are not yet numeric:
  1. Select Layer → Open Attribute Table
  2. Select the "Field Calculator" option
  3. Set an "Output field name" for the new field
  4. Set the "Output field type" to "integer" or "real"
  5. Set the "Output field width" and "precision", so that the desired numeric values will fit in the field
  6. Create an expression which indicates how the field should be calculated
  7. Select "OK"
  8. Repeat steps 2 through 7 for all desired attributes

3. 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 the UTF-8 character set. Saving will create a new ".geojson" file with all the desired data, ready to import into the Tygron Engine.


How to save as GeoJSON:
  1. Right-click the layer
  2. Select Save As...
  3. Set the Format to "GeoJSON"
  4. Use "Browse" to select a name and location for the resulting file
  5. Set the encoding to "UTF-8"
  6. Select "OK" to save the file

How to create a GeoJSON file in ArcGIS

A GeoJSON file can also be created in ArcGIS. For this the Data Interoperability Extension is needed. Without this extension, it is not possible to create a GeoJSON file. Keep in mind that the JSON output data format is not the same as a GeoJSON format. Below the steps are provided for creating a GeoJSON file in ArcGIS.


How to load a GeoJSON file into the Engine

The Tygron Engine can be provided with a GeoJSON file by opening the Geo Data Wizard and selecting the first option "Import a GeoJSONf-file", or by dragging-and-dropping the relevant file into the Tygron Engine. With this last option, a window will appear for choosing the kind of component to create based on the data in the file).