How to Use GeoJSON Files: A Beginner’s Guide
GeoJSON is a widely used format for encoding geographic data structures. If you're working with maps, spatial analysis, or location-based data, you'll likely encounter it. In this article, we’ll break down what you need to know about GeoJSON, how to create one, and the tools you can use to open and work with it.
🧠 What You Should Know About GeoJSON
GeoJSON stands for Geographic JavaScript Object Notation. It’s based on the JSON format and is used to represent simple geographical features along with their non-spatial attributes.
✅ Key Features
Human-readable: Easy to understand and edit with any text editor.
Lightweight: It uses plain text (UTF-8), which makes it great for web applications.
Feature types: Supports Points, LineStrings, Polygons, MultiPolygons, and FeatureCollections.
CRS (Coordinate Reference System): By default, it uses WGS 84 (
EPSG:4326
) — the standard latitude/longitude format.
📦 Common Use Cases
Creating custom map layers
Plotting markers or regions on web maps
Sharing spatial data in web apps or GIS platforms
🛠️ How to Create a GeoJSON File
There are three main ways to create a GeoJSON file:
1. Manually (for small data)
If you're working with simple geometry, you can write GeoJSON by hand in any text editor. Here's a basic example:
{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [102.0, 0.5]
},
"properties": {
"name": "Sample Point"
}
}
]
}
2. Using GIS Software
Tools like QGIS or ArcGIS can export spatial layers as GeoJSON.
In QGIS:
Load your vector data (e.g., shapefile).
Right-click the layer >
Export
>Save Features As...
Format:
GeoJSON
Set CRS and other properties, then click
OK
.
3. Convert from Other Formats
You can convert shapefiles, CSVs with coordinates, or KML files into GeoJSON using:
Command-line tools like
ogr2ogr
(part of GDAL)
Example GDAL command:
r2ogr -f GeoJSON output.geojson input.shp
🧰 What Software Do You Need to Open a GeoJSON File?
Here are several options for opening, viewing, or editing GeoJSON files:
💻 Desktop GIS
QGIS (Free and open-source)
ArcGIS Pro (Commercial)
Both can load and display GeoJSON layers and style them as needed.
🌐 Online Tools
geojson.io – Interactive web editor and viewer
Mapshaper.org – Great for simplifying and editing GeoJSONs
Kepler.gl – Visualize large geospatial datasets with drag-and-drop
👨💻 Code Environments
If you’re a developer:
Leaflet.js, Mapbox GL JS – Use GeoJSON as data layers in web maps
Python (geopandas):
import geopandas as gpd
gdf = gpd.read_file("your_file.geojson")
R (sf package):
library(sf)
data <- st_read("your_file.geojson")
[Insert code snippet]
JavaScript (for web apps):
fetch('yourfile.geojson')
.then(response => response.json())
.then(data => {
// do something with data
});
📝 Best Practices
✅ Always validate your GeoJSON (use GeoJSONLint)
✅ Stick to WGS 84 projection unless you have a specific need
✅ Keep it simple: avoid overly complex geometries if you're targeting the web
✅ Compress large files with gzip or split into tiles for performance
🗺️ Final Thoughts
GeoJSON is a flexible and accessible format for geographic data, especially in the web and open-source GIS ecosystem. Whether you're plotting a few points or building an interactive map, knowing how to create, edit, and validate GeoJSON files is a valuable skill in spatial data work.