-
Notifications
You must be signed in to change notification settings - Fork 876
Creating and Editing Feature Files
This page describes how to create and edit feature files using QGIS.
This section was written using QGIS v3.34. Older versions likely still have the same tools, though.
There are two methods for creating a new GeoJSON file to hold the boundary data for a new feature:
- Copy any existing feature file from any country's folder in
features
to the folder belonging to the country to which the new feature applies, and rename the copied file according to the existing naming conventions for regional features. - Open QGIS, and add a "New Temporary Scratch Layer" to a new or existing project. Select "Polygon" for the geometry type and press OK. This will add a new layer to your project. Right click on the layer, and select "Make Permanent". Click the button with three dots to the right of "File name", and navigate to the
features
folder belonging to the country to which the new feature applies. Enter the appropriate file name for the feature, press Save, then press OK. For best results, remove and re-add the new layer before proceeding further. If you are prompted to save while doing so, decline the option; your new GeoJSON file has already been created and saved.
If the country's features
subfolder does not exist, create it using the country's ISO 3166-1 alpha-2 code as its name.
You will need to add a starting polygon to GeoJSON files created from scratch (method 2). This can be done by clicking the "Toggle Editing" button, then the "Add Polygon Feature" button. Draw a simple polygon (it can contain as few as three nodes) by left clicking on the map, and right click when you are finished to exit drawing mode. Don't worry if the points are inaccurate; they can be adjusted later.
Open QGIS and add your GeoJSON file to a new or existing project if you did not already do so. Follow the steps and guidance outlined below in "How to update state/region GeoJSONs" (particularly from "Topological Editing / Snapping" onward) to adjust the file's polygon to cover the subdivision or area you wish to be represented by the feature. (If you used method 1 to create your file and have extra nodes, you can delete them by left clicking them and pressing the Delete key.)
If an adjacent country already has regional features, please load them into your project as well to ensure that any new features along country boundaries share the same nodes as existing features. This will help avoid the creation of gaps or overlaps along country boundaries and help ensure that regional features of different countries can be used to create a seamless, contiguous locationSet
.
As a general rule of thumb, try to keep the feature as simple as possible. It is OK to use multiple nodes to delineate the boundary in urban areas or other areas where there are relevant items or places on both sides of the border, but in rural areas or areas over water, it is equally OK to only loosely follow the actual boundary. For additional guidance, see @bhousel's comment on PR #5449.
If you are creating features for multiple subdivisions, repeat the above two sections for each subdivision. When you are satisfied with your work, you may commit the new feature or features to the NSI via a pull request. You and other contributors can then use the feature(s) as locationSet
values beginning with the pull request that adds the feature(s) to the project.
Originally posted by @jdcarls2 in #5449 (comment)
Updating and refining boundaries between adjacent GeoJSONs is not too hard. It is recommended that users wishing to perform such edits use QGIS. While QGIS 3.20 is pictured below, the tools used have been in the application for many versions, and users who opt for the LTR will be as able to perform these edits as those on the latest release.
Open a new project in QGIS. Browse to the repository in the Browser pane and find the features you wish to edit.
From there, you can simply drag the features into the map canvas. When adjusting a boundary, you must load all features which participate in that boundary. This will typically be between two or maybe three areas. While not strictly necessary, you may load all the features.
This is what ensures your edits do not create overlaps or gaps, so it's very important. On the Snapping Toolbar, click the magnet icon to enable snapping. The toolbar may not be visible at first; go to View > Toolbars > Snapping Toolbar from the menu bar, or right-click the toolbar area and select the snapping toolbar from the context menu.
On the toolbar, you will see an icon with three ways joined by a shared node:
Click this icon to enable topological editing.
In QGIS, there is an Editing Toolbar. (Look for the pencil icon.) With a layer selected in the Layers pane, click the pencil icon for Toggle Editing. You can also right-click the layer and find this command in the context menu.
NOTE: You will need to repeat this for each layer being editing. If I adjust the IL / IN boundary with editing only enabled on IL, I will only affect the IL GeoJSON.
Near the Toggle Editing icon, you'll find the Vertex Editor icon, a hammer and screwdriver under a way/node. Click this to activate the Vertex Editor tool. The cursor will change to a crosshair, and as you hover over edges and nodes, they will highlight.
Click on a vertex to "pick it up", click again to "put it down". The same is true for edges and selections of multiple nodes, though in this context that is probably less useful. On the midpoint of any edge, a "helper node" is visible as a grey +. Clicking this will add a new vertex at that point, which can be dragged into the desired position.
When there are pending edits, the Save icon will be enabled on the toolbar. Simply click the icon to save your edits to the layer.
NOTE: As with Toggle Editing, this button only applies to the currently selected layer. It's possible to successfully edit two layers and inadvertently only save the edits to a single layer. Fortunately, the Edit Toolbar does have a quicker way to save multiple edits. To the left of Toggle Editing is the Current Edits icon, two red pencils. Click this icon to open a small dropdown menu, where you can find the Save for All Layers command.
Once you've saved your edits, you may commit the changes. If possible, run npm build
first, though someone else can do this after the fact as well.
Here are a few things that might make your life easier using QGIS.
For several versions, QGIS has come with the OSM carto tiles as a pre-configured XYZ Tile service, which you can find in the Browser pane. Drag this into your map to help guide your edits. You can also bring in aerial imagery, vector layers, etc.. Vector layers have the benefit of being "snappable".
By default, your vector layers come in as opaque areas. To make your reference layers actually useful, put them higher up on the layer list. For a raster layer like the OSM tiles, you can set the Blending Mode to something like multiply in order to view the layers below.
You can add layers to groups in the Layers pane. This makes it easier to keep different regions, reference layers, etc., separate, and keeps the layer list from getting too long.
Load all the features from the NSI repo and save your QGIS project. This will help save you setup time if you need to adjust other boundaries in the future.
Contributing to the index
- Feature Files (geofences)
- Using Overpass Turbo
- Config Files
- Property Reference
- Technical Details
Information for developers using the name-suggestion-index in another project.
Information for maintainers, including how to clone and build the project.