This page describes the requirements for any dataset files you upload to the plugin configuration, whether you are using them to create new dataset pages or update existing dataset pages.

File Format

Uploaded files must be .json files (or in rare cases .js files) in standard GeoJSON format.

If your GeoJSON file was automatically generated, it will probably start with "type": "FeatureCollection". This is not necessary (the plugin will ignore it), but may be an indication of whether or not the generated file is in the correct format.

All GeoJSON files must include a "features": [ ... ] list with at least one valid GeoJSON feature. An automatically generated feature will probably start with "type": "Feature" (which the plugin will ignore). The feature must include a geometry field/list with both type and coordinates. It can optionally include a properties field/list, which will be used to generate a list of properties for all features in the dataset. This is a great place to include "id" and "name" properties.

If the file will be used to create a new dataset, you can also include a name for the dataset, which will be used to generate the new dataset's title/name.

Example JSON

Note that the spacing is unimportant - your file may be organized differently.

{
    "type": "FeatureCollection",
    "name": "My Dataset",
    "features": [
        {
            "type": "Feature",
            "geometry": {
                "type": "Point",
                "coordinates": [2.8, -5.3339]
            },
            "properties": {
                "name": "My Feature",
                "id": "some-id",
                "other-property": "some value"
            }
        }
    ]
}

GeoJSON Files

Geographic data comes in many forms, many of which are not GeoJSON files. Fortunately, it should not be too difficult to convert well-formed geographic data into the required format.

  • Data from a normal spreadsheet (Excel, Google Sheets, etc.): Recommended to save the spreadsheet as a CSV and then convert. Note: CSV stands for comma separated values and is essentially a spreadsheet in its most simplified form - no formatting, no merged cells. If you have a spreadsheet where the first row is a list of column headers and each subsequent row is a location then you should be set.
  • Convert CSV to GeoJSON
  • Conver ESRI Shapefile to GeoJSON (if you use ArcGIS)

These are just a couple of the options: If your data is in any kind of standard format there should be an online tool you can find and use to convert it.

JavaScript Files

The plugin can also accept JavaScript files (extension .js) that consist of a valid GeoJSON object. JavaScript files are a bit more complicated, so JSON files are recommended unless you are using data from a qgis2web export, which stores the GeoJSON data in JavaScript files. These files can be found in the export's data folder and should look like var json_varNameHere = { "GeoJSON" }, where "GeoJSON" is a valid GeoJSON object.

In order to upload JavaScript files, you will need to modify your site's security settings:

  1. Go to Configuration from the Admin panel.
  2. Choose the Security tab (between Media and Info).
  3. Find Dangerous Extensions under Uploads Security. This should have a list with several extensions, including js.
  4. Click on js and press delete.
  5. Save.

The following should be automatically followed by qgis2web, so you probably will not need to worry about them:

  • The JavaScript file should consist of the variable holding the GeoJSON data and nothing else (although comments at the beginning should be fine).
  • The variable holding the GeoJSON data must begin with json_ and use only letters, numbers, and underscores.