GeoJSON Point, LineString, Polygon, and FeatureCollection Explained
GeoJSON is simple enough to read, but small structural mistakes can make a map render in the wrong place or fail completely. Before debugging a map library, check whether the GeoJSON object is shaped correctly.
The core idea is that GeoJSON stores geographic data as geometry objects, features, and feature collections. A GeoJSON globe viewer can help you preview those structures, but understanding the types makes errors much easier to spot.
Coordinates Come First
In GeoJSON, a position is written as longitude first, then latitude:
[-122.4194, 37.7749]
That is the opposite of how many people say coordinates in conversation. If you accidentally write latitude first, longitude second, the point may land in the wrong country or ocean.
A position may include altitude as a third number:
[-122.4194, 37.7749, 20]
Many simple viewers ignore altitude, but they should still parse the coordinate.
Point and MultiPoint
A Point represents one location:
{
"type": "Point",
"coordinates": [-122.4194, 37.7749]
}
Use it for stores, sensors, landmarks, addresses, or any single location. MultiPoint represents multiple points in one geometry. It is useful when the points belong together as one feature, but separate Feature objects may be easier if every point has different properties.
LineString and MultiLineString
A LineString represents a path made from two or more positions:
{
"type": "LineString",
"coordinates": [
[-122.42, 37.77],
[-73.98, 40.75]
]
}
Use lines for routes, boundaries, cables, trails, traces, and connections. A MultiLineString groups several lines into one geometry.
If a line unexpectedly crosses the whole globe, check coordinate order and antimeridian behavior first.
Polygon and MultiPolygon
A Polygon represents an area. Its coordinates are arrays of rings. The first ring is the outer boundary. Later rings can represent holes.
{
"type": "Polygon",
"coordinates": [
[
[-122.5, 37.7],
[-122.3, 37.7],
[-122.3, 37.9],
[-122.5, 37.9],
[-122.5, 37.7]
]
]
}
Notice the first and last positions are the same. Polygon rings should close. A MultiPolygon is used when one feature contains multiple separate areas, such as a territory made from several islands.
Feature vs FeatureCollection
A raw geometry only describes shape. A Feature wraps geometry with optional properties:
{
"type": "Feature",
"properties": { "name": "Example area" },
"geometry": {
"type": "Polygon",
"coordinates": []
}
}
A FeatureCollection wraps many features:
{
"type": "FeatureCollection",
"features": []
}
Most map datasets use FeatureCollection because it lets every shape carry its own properties.
How to Choose the Right Shape
Choose the geometry based on what the thing is, not how you want it styled. A store is a Point. A delivery path is a LineString. A service area is a Polygon. If one business object contains several separate shapes, use a multi-geometry or multiple features depending on whether those shapes need separate properties.
For example, a chain with five store locations is usually easier as five Feature objects, each with a Point and its own store name. A protected area made of several islands may make sense as one MultiPolygon feature because the islands are one named area.
How to Debug a Wrong Preview
When a GeoJSON preview looks wrong, work from the outside in:
- Check the top-level
type. - If it is a
FeatureCollection, countfeatures. - Open one feature and confirm it has
geometry. - Check the geometry
type. - Check coordinate nesting for that type.
- Check whether coordinates are longitude-latitude.
- Check bounds for impossible outliers.
This is faster than changing map settings randomly. Most display problems are caused by data shape, coordinate order, projection assumptions, or one bad feature.
Geometry Is Not Styling
GeoJSON does not guarantee how a shape should look. A polygon may have a category or color property, but the renderer decides how to style it. Likewise, a line might represent a road, a flight, a cable, or a boundary. The geometry tells the viewer what to draw; properties and application logic tell it what the shape means.
Keep that separation in mind when designing exports. Put stable business fields in properties, but do not rely on a generic viewer to understand every custom field.
Common Mistakes
| Mistake | Symptom |
|---|---|
| Latitude before longitude | Features appear in the wrong place. |
| Raw array instead of GeoJSON object | Parser says the type is missing. |
| Polygon ring not closed | Area may fail or render oddly. |
| Properties placed outside a Feature | Metadata is ignored or invalid. |
| Wrong nesting level | Lines and polygons fail validation. |
Quick Answer
GeoJSON uses longitude-latitude coordinate order. Point stores one location, LineString stores a path, Polygon stores an area, Feature adds properties to geometry, and FeatureCollection groups many features. When a preview looks wrong, check coordinate order, nesting, and polygon ring closure first.
Ready to try it yourself?
Put what you have learned into practice with our free online tool.
View GeoJSON on a Globe