GeoJSON is a standardized format for representing geographic data in JSON. There’s a lot of great tooling out there for visualizing GeoJSON data. And GeoJSON is good for more than just storing points: it can represent points, lines, polygons, and collections.

Points

A GeoJSON point looks like this:

{
  "type": "Point",
  "coordinates": [-80.1347334, 25.7663562]
}

This point represents a park in Miami Beach, FL. One easy way to visualize this point on a map is using geojson.io.

It is important to note that coordinates is in the format [lng, lat]. Longitude comes before latitude in GeoJSON. That is because longitude represents east-west position (x axis on a typical map), and latitude represents north-south position (y axis on a typical map), and the authors of the GeoJSON spec wanted to keep x, y coordinate order.

A common use case for GeoJSON points is geocoding: converting an address like “429 Lenox Ave, Miami Beach, FL” to latitude and longitude coordinates. For example, suppose you use the Mapbox geocoding API. You would make an HTTP request to the below endpoint:

https://api.mapbox.com/geocoding/v5/mapbox.places/429%20lenox%20ave%20miami.json?access_token=pk.eyJ1IjoibWF0dGZpY2tlIiwiYSI6ImNqNnM2YmFoNzAwcTMzM214NTB1NHdwbnoifQ.Or19S7KmYPHW8YjRz82v6g&cachebuster=1581993735895&autocomplete=true

And get the below result:

{"type":"FeatureCollection","query":["429","lenox","ave","miami"],"features":[{"id":"address.8052276751051244","type":"Feature","place_type":["address"],"relevance":1,"properties":{"accuracy":"rooftop"},"text":"Lenox Avenue","place_name":"429 Lenox Avenue, Miami Beach, Florida 33139, United States","center":[-80.139145,25.77409],"geometry":{"type":"Point","coordinates":[-80.139145,25.77409]}, ...}

If you look closely, features[0].geometry in the above JSON output is a GeoJSON Point:

{"type":"Point","coordinates":[-80.139145,25.77409]}

#node #javascript #web-development #programming #developer

A Introduction to GeoJSON with Node.js
2.05 GEEK