Introduction
Empty geometry in geospatial data is a common issue that can cause significant problems in spatial analysis. When a dataset contains features with empty geometry, it means that those features lack spatial attributes such as coordinates or a valid geometry type.
This can occur due to various reasons, including:
Data import errors
Incomplete digitization
Corrupted datasets
Improper format conversions
Addressing this issue is crucial because empty geometry can lead to incorrect spatial analysis results, errors in geospatial processing tools and unexpected behavior in mapping applications
By resolving empty geometry issues, users can ensure the accuracy and reliability of their geospatial datasets.
This tutorial assumes that QGIS and a text editor application are already installed on your machine. In this tutorial, Visual Studio Code is used as the text editor.
This tutorial is created using a MacOS machine, but users on other operating systems should be able to follow along without significant differences.
Convert Data into GeoJSON
GeoJSON is a widely used format for encoding geographic data structures using JavaScript Object Notation (JSON). It is human-readable and easy to process, making it useful for detecting empty geometry in a dataset.
Some of the advantages of using GeoJSON for detecting empty geometry are that GeoJSON data is structured in a way that allows users to easily identify missing spatial information. Empty geometries in GeoJSON appear as empty lists ([]) or null values under the geometry field. Lastly, this format is beginner-friendly and can be checked using any text editor.
To analyze a dataset for empty geometry, first, export the data from QGIS as a GeoJSON file. In QGIS, locate the layer containing the dataset in the Layers panel.
Right-click the layer
Select Export
Select Save Feature As …
In the Format dropdown, select GeoJSON.
Click the
…button to specify the directory and filename for the exported file.Click OK to complete the export.
Once exported, navigate to the specified directory to find the saved GeoJSON file.
To examine the data structure and identify empty geometries, open the exported GeoJSON file in a text editor:
Right-click the GeoJSON file.
Select Open With.
Choose a text editor application (e.g., Visual Studio Code).
Recognizing Empty Geometry
A GeoJSON dataset consists of multiple features, each containing properties and geometry.
jsonCopy{ "type": "Feature", "properties": { "name": "Sample Feature", "id": 1 }, "geometry": { "type": "Point", "coordinates": [102.0, 0.5] } }
The properties section contains attribute information (e.g., name, ID). The geometry section defines the spatial location of the feature (e.g., coordinates for a point).
If a feature has empty geometry, the geometry section will either:
Contain an empty list (
[]) for coordinates:
jsonCopy"geometry": { "type": "Point", "coordinates": [] }Have a null value:
jsonCopy"geometry": null
Any feature with these characteristics should be flagged as an empty geometry.
Conclusion
Identifying and resolving empty geometry is essential to maintaining accurate and usable geospatial datasets. By converting data to GeoJSON and examining it in a text editor, users can efficiently detect and address empty geometries.
By ensuring that all features contain valid geometry, spatial analyses and mapping applications can function correctly, preventing data integrity issues in geospatial projects.



