---
title: Extract a geo reference from an EPSG code or WKT
summary: Derive a geo reference from the coordinates in the model, given the CRS they are in as an EPSG code or a WKT definition, or from IfcSite and IfcMapConversion; nothing is stored until you set it.
order: 20
languages: [javascript, java]
terms: [geo-reference, crs, wkt, version]
see-also: [how-to/geo/set-the-geo-reference, how-to/geo/get-the-geo-reference, how-to/using-bimworks/set-a-geo-reference, explanation/geo-referencing-in-ifc]
notion: https://app.notion.com/p/50ded66cdddc4f9da43a12ed5cdb75c0
---

# Extract a geo reference from an EPSG code or WKT

Extraction computes a geo reference from what the IFC file contains and returns it; it changes nothing in the repository. When the result is right, store it with [[page:how-to/geo/set-the-geo-reference]].

## Before you start

You need a client with the `gis:read` scope, the [[term:vid|Vid]] of a processed version and, for the EPSG and WKT methods, the coordinate reference system the model's `IfcSite` placement is expressed in. The methods, most reliable first:

| Method | JavaScript | Java | Reads |
|---|---|---|---|
| IfcMapConversion (IFC4 and later) | `extractGeoReferenceFromIfcMapConversion(vid)` | — | The `IfcMapConversion` with its projected [[term:crs|CRS]]; the recommended method when the model has one. |
| IfcMapConversion property set (IFC2X3) | `extractGeoReferenceFromIfcMapConversionPset(vid)` | — | The same information from the property set some IFC2X3 exporters write. |
| EPSG code | `extractGeoReferenceUsingEpsg(vid, "EPSG:28992")` | `extractGeoReference(uuid, "EPSG:28992")` | The x and y of the `IfcSite` placement, interpreted in the given system. |
| WKT | `extractGeoReferenceUsingWkt(vid, wkt)` | — | The same, for a system that is not in the EPSG registry, given as a [[term:wkt|WKT]] definition. |
| IfcSite attributes | `extractGeoReferenceUsingIfcSite(vid)` | — | `RefLatitude`, `RefLongitude` and `RefElevation` of `IfcSite`; rarely accurate. |

## Steps

1. **Extract.** The result is `{geo_reference, anchor_point, original_epsg}`: the geo reference converted to WGS84 (`EPSG:4326`), the anchor point in model coordinates and, for the EPSG and map-conversion methods, the code of the system the model was in.

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

   const extraction = await client.gis.extractGeoReferenceUsingEpsg(BIM_WORKS_FIRST_MODEL, "EPSG:28992");
   console.log(extraction.geo_reference, extraction.anchor_point, extraction.original_epsg);

   // A system outside the EPSG registry
   const wkt = `PROJCS["…", GEOGCS["…", …], PROJECTION["…"], …]`;
   const fromWkt = await client.gis.extractGeoReferenceUsingWkt(BIM_WORKS_FIRST_MODEL, wkt);
   ```
   ```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);
   	GeoReferenceExtraction extraction = client.gis.extractGeoReference(version, "EPSG:28992");
   	System.out.println(extraction.getGeoReference() + " at " + extraction.getAnchorPoint());
   }
   ```
   ````

2. **Judge the result.** Compare `geo_reference.latitude` and `longitude` with where the building stands; a model whose `IfcSite` sits at the local origin comes out at the origin of the projected system, which is the sign that the placement does not hold projected coordinates and another method is needed.
3. **Store it** with `setGeoReference(vid, extraction.geo_reference, extraction.anchor_point, extraction.original_epsg)` ([[page:how-to/geo/set-the-geo-reference]]). In the BIM.works UI the *Location* section does both in one click ([[page:how-to/using-bimworks/set-a-geo-reference]]).

## Over HTTP

[[openapi:ExtractGeoReference]] takes the method by name: `map_conversion`, `map_conversion_pset`, `ifc_site`, or `epsg` with an `epsg` code or a `wkt` definition. With `auto` the server chooses: it tries the map conversion, then its property set, then the `IfcSite` attributes, and answers the first that gives a geo reference, with `method` saying which one did. The answer has the same `geo_reference`, `anchor_point` and `original_epsg` as above.

```try-it
operation: ExtractGeoReference
method: POST
path: /openapi/gis/ExtractGeoReference
body: |
  {
    "model": {"type": "VersionModelIdentifier", "uuid": BIM_WORKS_FIRST_MODEL},
    "method": "epsg",
    "epsg": "EPSG:28992"
  }
```

## Errors

The EPSG code must start with `EPSG:`, otherwise the call fails with [[error:INVALID_EPSG]]. A version that has not been processed fails with [[error:MODEL_NOT_FOUND]]. Over HTTP, a method that finds no geo reference, or `auto` when none of its methods does, fails with [[error:NO_GEO_REFERENCE]].

## Check

Set the extracted reference, then open the model in the BIM.works *Map* view: the footprint lies on the site.
