GeoJSON | JSON | Use in GIS

Chirag Maniar
4 min readOct 12, 2021

Understand the GeoJSON, Similarity, and difference with JSON and GeoJSON and use cases in GIS

What we’ll learn?

  • What is GIS?
  • What is GeoJSON?
  • Why is GeoJSON required?
  • What is the difference between JSON and GeoJSON i.e. JSON v/s GeoJSON?
  • Examples and Resources

Prerequisites

Hell, No Prerequisites!!! 😅

Q. What is GIS?

GIS (Geographic Information System) is a computer system for capturing, storing, checking, and displaying data related to positions on Earth’s surface.

GIS can show many different kinds of data on one map, such as streets, buildings, and vegetation. This enables people to more easily see, analyze, and understand patterns and relationships.

Must read an in-depth article on GIS: https://www.nationalgeographic.org/encyclopedia/geographic-information-system-gis/

Q. What is GeoJSON?

To understand, GeoJSON. One must be aware what’s JSON (JavaScript Object Notation). It’s nothing but a file type used to transfer information on the internet. Like others text, images, etc.

JSON Example:

{
"name": "John",
"age": 20,
"dob": "01-01-2000",
"isMarried": false
}

It’s like a bundle of information stored in a key-value pair.

Now coming to our main thing, GeoJSON. When dealing with the maps and GIS, a hell lot of data is being transferred and received. There are n number of file types that are used for GIS and related stuff. We won’t get into it for now as it’s a different topic.

Let’s get into what’s a GeoJSON. GeoJSON itself suffice to explain that it’s JSON for Geographic specification.

GeoJSON is specification of geographic data in JSON format.

Now we know what is GeoJSON. Let’s jump to understand why it’s needed!

Q. Why is GeoJSON required?

It makes it easy to deal with Geographic data. It is easy to understand, lightweight and quick to learn.

Q. Difference between JSON and GeoJSON

JSON is simple text form which transfers information from one point to other. While the GeoJSON carries Vector data inside it. They consist of different shapes and their values i.e. Points, LIines, Polygons and MultiLines etc …GeoJSON stores attributes similar files like shape file.

“GeoJSON is a specification for creating, identifying and storing geospatial data in JSON”

More about GeoJSON

There are major three parts in a GeoJSON:

  • Geometry object: This is either the point, line, or polygon described earlier. Basically the location information.
  • Feature object: This is the geometry object and the associated random ad-hoc data. Remember, GeoJSON doesn’t care what data you associate with the location information.
  • FeatureCollection: Basically just a list of feature objects.

Examples and tips

  • Point Representation with GeoJSON

There are two types of Point representation:

  1. Single Point: Represents a single coordinate on a given map
  2. MultiPoint: Represents multiple points on the map
// Single Point
{
"type": "Point",
"coordinates": [72.83935546875,19.062117883514652]
}
Single Point Representation
// Multi Point
{
"type": "MultiPoint",
"coordinates": [[72.83935546875, 19.062117883514652],[73.80615234375, 20.076570104545173]]
}
MultiPoint Representation
  • Line Representation with GeoJSON
{  "type": "LineString",
"coordinates": [[72.83935546875, 19.062117883514652], [73.80615234375, 20.076570104545173],[73.80615234375, 21.076570104545173]]
}

Not stretching much by adding multiple map icons. One can copy-paste it in VS CODE and preview it! Ah., I missed introducing the “VS CODE Map Preview” extension. It makes your life simpler to test and practice for GeoJSON. Download from here: VS Code Map Preview

Just like LineString, we have “MultiLineString”, “Polygon”, “MultiPolygon” types of GeoObjects are available.

Generally, GeoObjects without any context is useless. We can provide it by adding context, which is known as Feature and FeatureCollections.

The below code is relateable for understanding some points for GeoJSON.

  • Feature

A Feature is something that adds identity to the GeoObject.

  • FeatureCollection

A FeatureCollection is collection (Array) of multiple Feature.

{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [ -90.0715, 29.9510 ]
},
"properties": {
"name": "Fred",
"gender": "Male"
}
},
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [ -92.7298, 30.7373 ]
},
"properties": {
"name": "Martha",
"gender": "Female"
}
},
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [ -91.1473, 30.4711 ]
},
"properties": {
"name": "Zelda",
"gender": "Female"
}
}
]
}

Resources & Credits

  1. Blog from Raymond Camden: https://developer.here.com/blog/an-introduction-to-geojson
  2. Nation Geographic: https://www.nationalgeographic.org/encyclopedia/geographic-information-system-gis/
  3. https://macwright.com/2015/03/23/geojson-second-bite.html
  4. http://132.72.155.230:3838/js/geojson-1.html
  5. Sumit Arora’s blog: https://sumit-arora.medium.com/what-is-geojson-geojson-basics-visualize-geojson-open-geojson-using-qgis-open-geojson-3432039e336d

From Author 👨🏻‍💻

GeoJSON is one of the widely used file formats in GIS, Spectrum Spatial Analysis, and many Mappings-related APIs.

I’ve recently started diving into the GIS domain, please feel free to connect, ask and correct if any correction is required.

Hope it gives you introductory information about the topic and made you familiar with some of the GIS concepts. Please like, share, and comment if it added a tiny piece of value to your knowledge! Your support motivates me to write more. . . See you techies around 👋🏻👋🏻

--

--

Chirag Maniar

Full Stack Developer | ReactJS | Angular | JavaScript | Amature Writer | Freelancer |