Spatial reference systems are a key component of writing spatial applications. A spatial reference helps describe where features are located in the real world. Different spatial reference systems are used for different purposes. You may also hear spatial reference and coordinate system used interchangeably although they are slightly different.

Consider the two examples below. 102003 is commonly used by news organizations because it presents the continental United States in a more realistic way, preserving the states' areas relative to each other. 3857 is used by many mapping applications because it preserves a consistent direction for north and preserves the scale of the map at any given zoom level.

102003 - Albers Equal Area

3857 - Web Mercator

The data for both these maps comes from the same source. ArcGIS Server handles reprojecting the data (converting it to the requested spatial reference) 'on the fly'.

ArcGIS allows you to use thousands of different spatial references and offers many tools for working with spatial references because many governments, militaries, and other organizations mandate that a specific one be used.

Most spatial references fall into two categories, geographic and projected.

Geographic coordinate systems

A geographic coordinate system (GCS) uses a ellipsoidal surface to define locations on the Earth. There are three parts to a geographic coordinate system:

  1. A datum - an ellipsoidal (spheroid) model of the Earth to use. Common datums include WGS84 (used in GPS) and NAD83 (used in surveying and mapping in North America).
  2. A prime meridian
  3. Angular unit of measure

You can see these three parts in the well-known text for the 4326 spatial reference.

GEOGCS["GCS_WGS_1984",
  DATUM["D_WGS_1984",
    SPHEROID["WGS_1984",6378137,298.257223563]],
  PRIMEM["Greenwich",0],
  UNIT["Degree",0.017453292519943295]]

You can clearly see the three parts of a geographic coordinate system in the DATUM, PRIMEM and UNIT sections.

Projected coordinate systems

Projected coordinate systems define a flat 2D Cartesian surface. Unlike a geographic coordinate system, a projected coordinate system has constant lengths, angles, and areas across the two dimensions. A projected coordinate system is always based on a geographic coordinate system that references a specific datum.

You can see these various parts in the well-known text of the spatial reference for 3857 spatial reference:

PROJCS["WGS_1984_Web_Mercator_Auxiliary_Sphere",
  GEOGCS["GCS_WGS_1984",
    DATUM["D_WGS_1984",
      SPHEROID["WGS_1984",6378137.0,298.257223563]],
    PRIMEM["Greenwich",0.0],
    UNIT["Degree",0.017453292519943295]],
  PROJECTION["Mercator_Auxiliary_Sphere"],
  PARAMETER["False_Easting",0.0],
  PARAMETER["False_Northing",0.0],
  PARAMETER["Central_Meridian",0.0],
  PARAMETER["Standard_Parallel_1",0.0],
  PARAMETER["Auxiliary_Sphere_Type",0.0],
  UNIT["Meter",1.0]]

You can see that EPSG:3857 references the same DATUM, SPHEROID, PRIMEM and UNIT as the 4236 projection and also defines a PROJECTION (Mercator_Auxiliary_Sphere) that defines how to project the GEOGCS coordinates into 2D coordinates.

Using spatial references

Generally when using ArcGIS APIs and SDKs, conversions between different spatial references are automatically made for you. However, in some cases, you do need to supply the spatial reference. The spatial reference is usually defined with a JSON object:

{
  wkid: 4326
}

wkid represents the "Well-known ID" of the spatial reference you would like to use. Spatial references are generally defined as part of a geometry.

require([
  "esri/Map",
  "esri/views/MapView",
  "esri/geometry/Point",
  "esri/Graphic"
], function(Map, MapView, Point, Graphic) {

  // Create a new map with the Streets Navigation vector basemap.
  // The basemap is published in 3857, which is commonly known as Web Mercator
  var map = new Map({
    basemap: "streets-navigation-vector"
  });

  // now we create a new view of our map
  var view = new MapView({
    container: "map",
    map: map,
    zoom: 15,
    center: [ -118.24354, 34.05389 ]
  });

  // now we can create a graphic to add to our map. Notice that we have
  // to supply the spatial reference of our new point to tell the API how to
  // map this point onto our map. This conversion happens automatically.
  var graphic = new Graphic({
    geometry: new Point({
      x: -118.24354,
      y: 34.05389,
      spatialReference: {
        wkid: 4326
      }
    })
  });

  view.graphics.add(graphic);
});

Commonly used coordinate reference systems

4326 - GPS

4326 is the most common spatial reference for storing a referencing data across the entire world. It serves as the default for both the PostGIS spatial database and the GeoJSON standard. It is also used by default in most web mapping libraries.

Because of its use in GPS, 4326 is generally assumed to be the spatial reference when talking about "latitude" or "longitude".

3857 - Web Mercator

The Web Mercator coordinate reference system is the default in most web mapping libraries. Web Mercator preserves a consistent direction and north is always "up" on a Web Mercator map. Angles are also depicted accurately, so a 90-degree turn on a Web Mercator map will actually look like a right angle. That said, the projection distorts both shape and size as distance from the equator increases.

Web Mercator is ideal for generating map tiles since it will project the world into a square that can be subdivided evenly across zoom levels. For example one tile at zoom level 1, four tiles at zoom level 2 and so on.