---
title: Set the geo reference
summary: Store a geo reference and its anchor point on a version from JavaScript or Java, and refresh the loaded model in the viewer.
order: 30
languages: [javascript, java]
terms: [geo-reference, version, vid]
see-also: [how-to/geo/get-the-geo-reference, how-to/geo/extract-from-epsg-or-wkt, how-to/using-bimworks/set-a-geo-reference, how-to/viewer3d/geo-mode]
notion: https://app.notion.com/p/50ded66cdddc4f9da43a12ed5cdb75c0
---

# Set the geo reference

Setting a [[term:geo-reference]] writes metadata on the [[term:version]]; the IFC file is untouched. The values usually come from an extraction ([[page:how-to/geo/extract-from-epsg-or-wkt]]) or from a survey.

## Before you start

You need a client with the `gis:write` scope, the [[term:vid|Vid]] of a processed version, and:

- `latitude`, `longitude` in WGS84 degrees, `elevation` in metres, `rotation` in degrees (0–360, counter-clockwise, applied around the anchor point), and `epsg`, which is `"EPSG:4326"` for those values;
- which north the rotation is from: `"TRUE"`, or `"GRID"` for a rotation measured against the grid of the projected system it came from, as an extraction's is. Without it the rotation counts as grid-relative when the version has an original EPSG, and as true north otherwise;
- the **anchor point** `{x, y, z}` in the model's coordinates: the point the latitude and longitude describe. `{x: 0, y: 0, z: 0}` means the model's local origin; an extraction returns the anchor it used.

The OpenAPI has no operation for this call.

## Steps

1. **Store it.** In JavaScript, `originalEpsg` is optional and records the projected system the values were derived from, and `rotationNorth` says which north the rotation is from; the Java call has neither argument.

   ````code-group
   ```javascript
   const factory = new BimWorksClientFactory(BIM_WORKS_ADDRESS);
   const client = await factory.createClientWithApiToken(BIM_WORKS_API_TOKEN);

   const geoReference = {
   	epsg: "EPSG:4326",
   	latitude: 48.858222,     // the Eiffel tower
   	longitude: 2.294500,
   	elevation: 0,
   	rotation: 0
   };
   const anchorPoint = {x: 0, y: 0, z: 0};

   await client.gis.setGeoReference(BIM_WORKS_FIRST_MODEL, geoReference, anchorPoint, undefined, "TRUE");

   // From an extraction, keeping the system it came from: its rotation is against that grid
   const extraction = await client.gis.extractGeoReferenceUsingEpsg(BIM_WORKS_FIRST_MODEL, "EPSG:28992");
   await client.gis.setGeoReference(BIM_WORKS_FIRST_MODEL, extraction.geo_reference, extraction.anchor_point, extraction.original_epsg, "GRID");
   ```
   ```java
   try (BimWorksClientFactory factory = new BimWorksClientFactory(BIM_WORKS_ADDRESS);
        BimWorksClient client = factory.createClientWithApiToken(BIM_WORKS_API_TOKEN)) {
   	UUID version = UUID.fromString(BIM_WORKS_FIRST_MODEL);

   	GeoReference geoReference = new GeoReference(48.858222, 2.294500, 0, 0);   // latitude, longitude, elevation, rotation
   	geoReference.setEpsg("EPSG:4326");
   	client.gis.setGeoReference(version, geoReference, new Vector3d(0, 0, 0));

   	// From an extraction
   	GeoReferenceExtraction extraction = client.gis.extractGeoReference(version, "EPSG:28992");
   	client.gis.setGeoReference(version, extraction.getGeoReference(), extraction.getAnchorPoint());
   }
   ```
   ````

2. **Refresh what is loaded.** A viewer that already shows the version does not notice the change: call `viewer.updateModel(versionUuid)` and, in GEO mode, the model moves to its new place.

## Copy the geo reference of another version {#copy}

A geo reference places a version's *aligned* coordinates: the alignment applies first. So a drawing (PDF, DWG) aligned onto an IFC model lies on the earth where that model is once it has the model's geo reference. `copyGeoReference` stores it: the same latitude, longitude, elevation, rotation, north and original EPSG, and the same anchor point converted to the drawing's length unit. It needs `gis:write` and write access to the target, and read access to the source. The OpenAPI operation is [[openapi:CopyGeoReference]].

```javascript {#copy-call}
const copied = await client.gis.copyGeoReference(BIM_WORKS_SECOND_MODEL, BIM_WORKS_FIRST_MODEL);
// copied.geo_reference_source: {version_uuid, alignment}, the source and the target's alignment at the time;
// copied.warnings: for example that the target has no alignment, so the location places its raw coordinates
const stored = await client.gis.getGeoReference(BIM_WORKS_SECOND_MODEL, null, {includeSource: true});
```

`getGeoReference` with `includeSource` answers where a copied geo reference came from (`geo_reference_source`, with the source's node name) and its `original_epsg`. `setGeoReference(versionUuid, null)` removes a version's geo reference. In the app the same is the *Use the location of …* option of *Align models* and *Copy from another model…* on the Location section ([[page:how-to/using-bimworks/place-a-drawing-on-the-map]]).

The server normalises the reference before storing it in `EPSG:4326`; read it back with [[page:how-to/geo/get-the-geo-reference]].

## Check

`getGeoReference` returns the values you stored, and the *Map* view of BIM.works shows the footprint at the new position.
