Spatial references are important when building applications that use geographic data. A spatial reference defines the coordinate system used to locate the geometry for a feature. It controls how and where features are displayed in a map or scene. When building an application, all geographic data must either use a common spatial reference or be projected to a spatial reference in order to accurately display features and perform spatial analyses.

Video: Understanding spatial references.

There are many different types of spatial references for defining geographic data. To simplify accessing and referencing them, they are commonly referred to by a well-known ID (WKID) — an integer value. Two of the most common WKIDs are 4326 (also known as WGS84), and 3857 (also known as Web Mercator). For a complete description, see Spatial reference specifications in this topic.

Consider the two examples below. `102003`

, or Albers Equal Area, is commonly used by news organizations because it preserves the relative area for each state in the continental United States. However, `3857`

, or Web Mercator, is used by many mapping applications because it preserves both a consistent direction for north and 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'.

## Why spatial references are important

ArcGIS allows you to use thousands of different spatial references and offers many tools for working with spatial references. Many governments, militaries, and other organizations mandate that a specific one be used. To integrate spatial data together into a map or when performing analysis, ArcGIS must know where things are located on the Earth's surface. This is done using coordinates, which are expressed relative to a coordinate system, or an accepted frame of reference around a model of the Earth's surface. Not all coordinates and their associated coordinate systems are alike: they can use different units (for example degrees minutes seconds, decimal degrees, or meters) and they can be based on different types of models. ArcGIS uses mathematical transformations to reproject coordinates from one coordinate system to another. A spatial reference provides all the information needed for reprojection.

## Coordinate systems and projections

Data is defined in both horizontal and vertical coordinate systems. Horizontal coordinate systems locate data across the surface of the earth, and are split into categories:

**Geographic coordinate systems**(GCSs)**Projected coordinate systems**(PCSs)**Local coordinate systems****Vertical coordinate systems**(VCSs)

### Geographic coordinate systems

A geographic coordinate system (GCS) uses a three-dimensional ellipsoidal surface to define locations on the Earth. These coordinates are based on angles from the center of the Earth to the surface. Typically GCSs use latitude and longitude specified in degrees. There are three parts to a geographic coordinate system:

- A datum, which is an ellipsoidal (spheroid) model of the Earth
- A prime meridian
- An angular unit of measure

Common datums include WGS84 (used in GPS, WKID=4326) and NAD83 (used in surveying and mapping in North America).

You can see these three parts in the well-known text for the `4326`

spatial reference in the `DATUM`

, `PRIMEM`

and `UNIT`

sections:

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

### Projected coordinate systems

Projected coordinate systems (PCS) are described as *planar* (two-dimensional), *Cartesian*, or *flat*.
They define a flat 2D Cartesian coordinate system projected onto a flat surface for display.
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.

There are various projections with different desirable characteristics: some preserve accuracy in particular areas of the Earth, others are better at maintaining the shape of features, while others favor accurate area or distance measurements.
Coordinates are identified by x, y coordinates on a grid. Most basemaps from ArcGIS Online, Google, and OpenStreetMap use the same projected coordinate system named Web Mercator Auxiliary Sphere (`WKI`

).

```
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`

references the same `DATUM`

, `SPHEROID`

, `PRIMEM`

and `UNIT`

fields as the `4326`

projection. It also defines a `PROJECTION`

(Mercator_Auxiliary_Sphere) which defines how to project the 3D `GEOGCS`

coordinates into 2D coordinates.

### Local coordinate systems

Local coordinate systems are often unrelated to any other coordinate system. The origin and the x,y coordinate units correspond to a local point of reference. Because the relationship of a local coordinate system to another coordinate system cannot be established easily, these are sometimes referred to as unknown coordinate systems.

### Vertical coordinate systems

Vertical coordinate systems (VCSs) are significant when working with 3D data. A VCS defines vertical linear units of measure, the origin of z-values, and whether z-values are "positive up" (representing heights above a surface) or "positive down" (representing depths below a surface). There are two main types of VCS: Ellipsoidal systems measure z-values from a mathematically-defined three-dimensional ellipsoidal surface. Most data collected via Global Navigation Satellite System receivers, for example GPS, are in an ellipsoidal VCS. Gravity based systems measure z-values from an analytical surface that represents mean sea level. Gravity based VCSs are more commonly used to display and work with 3D data. A spatial reference may or may not have a VCS set. Any particular vertical coordinate system may be used with different horizontal coordinate systems.

## Using spatial references

When using ArcGIS APIs, coordinate conversions for geographic data with different spatial references are typically made for you automatically. However, in some cases, you will need to supply the spatial reference. ArcGIS APIs will attempt to reproject geometries or request data in the appropriate spatial reference from services whenever possible. In some cases, however, you have to specify the spatial reference with a WKID for data used in function calls or as parameters.

The spatial reference is usually defined with a JSON object:

```
{
wkid: 4326
}
```

Here, the `wkid`

field 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

For more in-depth information, including lists of Projected, Geographic, and Vertical coordinate systems, refer to Using Spatial References in the ArcGIS REST API documentation.

### 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 look like a true right angle. That said, the projection can distort both shape and size as distance from the equator increases.

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

## Spatial reference specifications

To define a spatial reference, you can use either a Well-Known ID (WKID) integer value or a text string definition referred to as Well-Known Text (WKT). WKIDs are defined by standards bodies or organizations, with each value representing a specific spatial reference. ArcGIS supports a variety of WKIDs, typically those defined by the European Petroleum Survey Group (EPSG), Esri, and other commonly used WKIDs. You could also, optionally, define a vertical coordinate system for a spatial reference using a second WKID. In contrast, WKT text describes all of the parameters of a spatial reference. Linear, angular, and area units can also be defined by WKID or WKT, and are used by many spatial reference and geometry related API members.

Exactly how coordinates should be transformed is defined by agencies such as the US National Geodetic Survey. Esri's Projection Engine supports many predefined transformations, and more than one transformation may be available for a given datum change. Each transformation is identified by a WKID integer number and WKT text string definition, similarly to how spatial references are identified. Transformations vary in accuracy, and using the most suitable transformation for your specific case ensures the best possible accuracy for the reprojection.

To see a list of supported WKIDs and their WKT definitions for geographic coordinate systems, projected coordinate systems, vertical coordinate systems, and transformations, see Supplemental ArcGIS Data or visit the GitHub repository.