---
title: GISApi
summary: .NET SDK: the GIS - Geographic Information Systems operations, 6 methods, each with its parameters, result and a complete example.
order: 15
languages: [csharp]
sdk-package: .NET SDK · BIMworks.Sdk
link-terms: true
---

# GISApi

[[page:reference/sdk/dotnet|.NET SDK]] · `BIMworks.Sdk.Api` · class · 6 methods

GIS related calls, for example to export to CityGML

Construct it with the client of [[page:reference/sdk/dotnet#connect|the connect step]]: `client.GetRequiredService<IGISApi>()`. Each method is one operation of the [[page:api|API part]], where it runs on its page.

<table class="dense">
<thead><tr><th>Method</th><th>Operation</th><th>Description</th></tr></thead>
<tbody>
<tr><td><code>[[page:reference/sdk/dotnet/gisapi#copygeoreference|CopyGeoReferenceAsync]]</code></td><td>[[openapi:CopyGeoReference]]</td><td>Give a Version the georeference of another</td></tr>
<tr><td><code>[[page:reference/sdk/dotnet/gisapi#exportcitygml3|ExportCityGML3Async]]</code></td><td>[[openapi:ExportCityGML3]]</td><td>Export one or more IFC models to CityGML 3 or CityJSON 2</td></tr>
<tr><td><code>[[page:reference/sdk/dotnet/gisapi#extractgeoreference|ExtractGeoReferenceAsync]]</code></td><td>[[openapi:ExtractGeoReference]]</td><td>Compute a georeference from the model</td></tr>
<tr><td><code>[[page:reference/sdk/dotnet/gisapi#generate3dtilesurl|Generate3DTilesUrlAsync]]</code></td><td>[[openapi:Generate3DTilesUrl]]</td><td>Create a signed 3D Tiles tileset URL for a folder or a set of versions</td></tr>
<tr><td><code>[[page:reference/sdk/dotnet/gisapi#getgeoreference|GetGeoReferenceAsync]]</code></td><td>[[openapi:GetGeoReference]]</td><td>Read or convert a georeference</td></tr>
<tr><td><code>[[page:reference/sdk/dotnet/gisapi#setgeoreference|SetGeoReferenceAsync]]</code></td><td>[[openapi:SetGeoReference]]</td><td>Store a Version's georeference</td></tr>
</tbody>
</table>

## `CopyGeoReferenceAsync` {#copygeoreference}

```csharp
Task<ICopyGeoReferenceApiResponse> CopyGeoReferenceAsync(CopyGeoReferenceRequest copyGeoReferenceRequest, CancellationToken cancellationToken = default)
```

Give a Version the georeference of another. Copies the georeference of `from` onto `model`: the latitude, longitude, elevation and rotation, `rotation_north` and `original_epsg` as they are, and the anchor point converted to the target's length unit, so it is the same point. A georeference places a Version's aligned coordinates, so a drawing (PDF, DWG) aligned onto an IFC model and given that model's georeference is shown on the earth where the model is: in GEO mode, next to GIS layers, on the map. The answer says where it came from (`geo_reference_source`, with the target's alignment at the time) and warns when the target has no alignment. Needs write rights on `model` and read rights on `from`.

<table class="dense">
<tbody>
<tr><th>Operation</th><td>[[openapi:CopyGeoReference]] · <code>POST /openapi/gis/CopyGeoReference</code></td></tr>
<tr><th>Scope</th><td>[[scope:gis:write]]</td></tr>
</tbody>
</table>

### Parameters

<table class="dense">
<thead><tr><th>Name</th><th>Type</th><th>Description</th></tr></thead>
<tbody>
<tr><td><code>copyGeoReferenceRequest</code></td><td><code>[[page:reference/sdk/dotnet/models#CopyGeoReferenceRequest|CopyGeoReferenceRequest]]</code><span class="req">required</span></td><td>The request: its properties are those of the model, its JSON that of [[openapi:CopyGeoReference]]'s request body.</td></tr>
</tbody>
</table>

### Returns

<code>[[page:reference/sdk/dotnet/models#CopiedGeoReference|CopiedGeoReference]]</code> — The georeference as stored on <code>model</code>

### Example

```csharp
using System.Text.Json;
using BIMworks.Sdk.Api;
using BIMworks.Sdk.Client;
using BIMworks.Sdk.Extensions;
using BIMworks.Sdk.Model;
using Microsoft.Extensions.DependencyInjection;

// 1. Connect to BIM.works and log in with your API token
IServiceProvider Connect(string bearer)
{
    var services = new ServiceCollection();
    services.AddApi(options =>
    {
        options.AddTokens(new BearerToken(bearer));
        options.AddApiHttpClients(http =>
        {
            http.BaseAddress = new Uri("BIM_WORKS_ADDRESS" + "/openapi");
            http.Timeout = Timeout.InfiniteTimeSpan;
        });
    });
    return services.BuildServiceProvider();
}
var login = await Connect("").GetRequiredService<IAuthApi>().LoginWithApiTokenAsync(new LoginWithApiTokenRequest("BIM_WORKS_API_TOKEN"));
var auth = login.Ok()?.Auth ?? throw new HttpRequestException(login.RawContent, null, login.StatusCode);
var client = Connect(auth.Base64);
var json = client.GetRequiredService<JsonSerializerOptionsProvider>().Options;

// 2. The request
var request = JsonSerializer.Deserialize<CopyGeoReferenceRequest>("""
    {
      "model": {
        "type": "UrlModelIdentifier"
      },
      "from": {
        "type": "UrlModelIdentifier"
      }
    }
    """, json);

// 3. The call
var response = await client.GetRequiredService<IGISApi>().CopyGeoReferenceAsync(request);

// 4. The result
var result = response.Ok() ?? throw new HttpRequestException(response.RawContent, null, response.StatusCode);
Console.WriteLine(JsonSerializer.Serialize(result, json));
```

## `ExportCityGML3Async` {#exportcitygml3}

```csharp
Task<IExportCityGML3ApiResponse> ExportCityGML3Async(ExportCityGML3Request exportCityGML3Request, CancellationToken cancellationToken = default)
```

Export one or more IFC models to CityGML 3 or CityJSON 2. Export one or more IFC models into one city model, using per-LOD export settings that select objects and geometry via BQL. `format` chooses the encoding; it wins over the Accept header, which is only read when `format` is absent.

<table class="dense">
<tbody>
<tr><th>Operation</th><td>[[openapi:ExportCityGML3]] · <code>POST /openapi/gis/ExportCityGML3</code></td></tr>
<tr><th>Scope</th><td>[[scope:model:read]]</td></tr>
</tbody>
</table>

### Parameters

<table class="dense">
<thead><tr><th>Name</th><th>Type</th><th>Description</th></tr></thead>
<tbody>
<tr><td><code>exportCityGML3Request</code></td><td><code>[[page:reference/sdk/dotnet/models#ExportCityGML3Request|ExportCityGML3Request]]</code><span class="req">required</span></td><td>The request: its properties are those of the model, its JSON that of [[openapi:ExportCityGML3]]'s request body.</td></tr>
</tbody>
</table>

### Returns

<code>Stream</code> — The exported city model, in the requested format

### Example

```csharp
using System.Text.Json;
using BIMworks.Sdk.Api;
using BIMworks.Sdk.Client;
using BIMworks.Sdk.Extensions;
using BIMworks.Sdk.Model;
using Microsoft.Extensions.DependencyInjection;

// 1. Connect to BIM.works and log in with your API token
IServiceProvider Connect(string bearer)
{
    var services = new ServiceCollection();
    services.AddApi(options =>
    {
        options.AddTokens(new BearerToken(bearer));
        options.AddApiHttpClients(http =>
        {
            http.BaseAddress = new Uri("BIM_WORKS_ADDRESS" + "/openapi");
            http.Timeout = Timeout.InfiniteTimeSpan;
        });
    });
    return services.BuildServiceProvider();
}
var login = await Connect("").GetRequiredService<IAuthApi>().LoginWithApiTokenAsync(new LoginWithApiTokenRequest("BIM_WORKS_API_TOKEN"));
var auth = login.Ok()?.Auth ?? throw new HttpRequestException(login.RawContent, null, login.StatusCode);
var client = Connect(auth.Base64);
var json = client.GetRequiredService<JsonSerializerOptionsProvider>().Options;

// 2. The request
var request = JsonSerializer.Deserialize<ExportCityGML3Request>("""
    {
      "models": [
        {
          "type": "UrlModelIdentifier"
        }
      ],
      "settings": {},
      "format": "citygml3"
    }
    """, json);

// 3. The call
var response = await client.GetRequiredService<IGISApi>().ExportCityGML3Async(request);

// 4. The result
var result = response.Ok() ?? throw new HttpRequestException(response.RawContent, null, response.StatusCode);
using var output = File.Create("export-city-gml3.gml");
await result.CopyToAsync(output);
```

## `ExtractGeoReferenceAsync` {#extractgeoreference}

```csharp
Task<IExtractGeoReferenceApiResponse> ExtractGeoReferenceAsync(ExtractGeoReferenceRequest extractGeoReferenceRequest, CancellationToken cancellationToken = default)
```

Compute a georeference from the model. Computes a georeference from what the IFC file says, without storing it: call SetGeoReference with the answer to keep it. `method`:

<table class="dense">
<tbody>
<tr><th>Operation</th><td>[[openapi:ExtractGeoReference]] · <code>POST /openapi/gis/ExtractGeoReference</code></td></tr>
<tr><th>Scope</th><td>[[scope:gis:read]]</td></tr>
</tbody>
</table>

### Parameters

<table class="dense">
<thead><tr><th>Name</th><th>Type</th><th>Description</th></tr></thead>
<tbody>
<tr><td><code>extractGeoReferenceRequest</code></td><td><code>[[page:reference/sdk/dotnet/models#ExtractGeoReferenceRequest|ExtractGeoReferenceRequest]]</code><span class="req">required</span></td><td>The request: its properties are those of the model, its JSON that of [[openapi:ExtractGeoReference]]'s request body.</td></tr>
</tbody>
</table>

### Returns

<code>[[page:reference/sdk/dotnet/models#ExtractedGeoReference|ExtractedGeoReference]]</code> — The georeference that was found

### Example

```csharp
using System.Text.Json;
using BIMworks.Sdk.Api;
using BIMworks.Sdk.Client;
using BIMworks.Sdk.Extensions;
using BIMworks.Sdk.Model;
using Microsoft.Extensions.DependencyInjection;

// 1. Connect to BIM.works and log in with your API token
IServiceProvider Connect(string bearer)
{
    var services = new ServiceCollection();
    services.AddApi(options =>
    {
        options.AddTokens(new BearerToken(bearer));
        options.AddApiHttpClients(http =>
        {
            http.BaseAddress = new Uri("BIM_WORKS_ADDRESS" + "/openapi");
            http.Timeout = Timeout.InfiniteTimeSpan;
        });
    });
    return services.BuildServiceProvider();
}
var login = await Connect("").GetRequiredService<IAuthApi>().LoginWithApiTokenAsync(new LoginWithApiTokenRequest("BIM_WORKS_API_TOKEN"));
var auth = login.Ok()?.Auth ?? throw new HttpRequestException(login.RawContent, null, login.StatusCode);
var client = Connect(auth.Base64);
var json = client.GetRequiredService<JsonSerializerOptionsProvider>().Options;

// 2. The request
var request = JsonSerializer.Deserialize<ExtractGeoReferenceRequest>("""
    {
      "model": {
        "type": "UrlModelIdentifier"
      },
      "method": "map_conversion",
      "epsg": "",
      "wkt": ""
    }
    """, json);

// 3. The call
var response = await client.GetRequiredService<IGISApi>().ExtractGeoReferenceAsync(request);

// 4. The result
var result = response.Ok() ?? throw new HttpRequestException(response.RawContent, null, response.StatusCode);
Console.WriteLine(JsonSerializer.Serialize(result, json));
```

## `Generate3DTilesUrlAsync` {#generate3dtilesurl}

```csharp
Task<IGenerate3DTilesUrlApiResponse> Generate3DTilesUrlAsync(Generate3DTilesUrlRequest generate3DTilesUrlRequest, CancellationToken cancellationToken = default)
```

Create a signed 3D Tiles tileset URL for a folder or a set of versions. Mints a URL to a Cesium 3D Tiles tileset.json of the models of a folder node (followed recursively at request time) or of a fixed set of versions. The settings — which objects, in which colours, with which batch-table columns — are signed into the URL and cannot be changed by whoever holds it. The URL is valid for 90 days.

<table class="dense">
<tbody>
<tr><th>Operation</th><td>[[openapi:Generate3DTilesUrl]] · <code>POST /openapi/gis/Generate3DTilesUrl</code></td></tr>
<tr><th>Scope</th><td>[[scope:geometry:read]]</td></tr>
</tbody>
</table>

### Parameters

<table class="dense">
<thead><tr><th>Name</th><th>Type</th><th>Description</th></tr></thead>
<tbody>
<tr><td><code>generate3DTilesUrlRequest</code></td><td><code>[[page:reference/sdk/dotnet/models#Generate3DTilesUrlRequest|Generate3DTilesUrlRequest]]</code><span class="req">required</span></td><td>The request: its properties are those of the model, its JSON that of [[openapi:Generate3DTilesUrl]]'s request body.</td></tr>
</tbody>
</table>

### Returns

<code>[[page:reference/sdk/dotnet/models#Generate3DTilesUrl200Response|Generate3DTilesUrl200Response]]</code> — The tileset URL

### Example

```csharp
using System.Text.Json;
using BIMworks.Sdk.Api;
using BIMworks.Sdk.Client;
using BIMworks.Sdk.Extensions;
using BIMworks.Sdk.Model;
using Microsoft.Extensions.DependencyInjection;

// 1. Connect to BIM.works and log in with your API token
IServiceProvider Connect(string bearer)
{
    var services = new ServiceCollection();
    services.AddApi(options =>
    {
        options.AddTokens(new BearerToken(bearer));
        options.AddApiHttpClients(http =>
        {
            http.BaseAddress = new Uri("BIM_WORKS_ADDRESS" + "/openapi");
            http.Timeout = Timeout.InfiniteTimeSpan;
        });
    });
    return services.BuildServiceProvider();
}
var login = await Connect("").GetRequiredService<IAuthApi>().LoginWithApiTokenAsync(new LoginWithApiTokenRequest("BIM_WORKS_API_TOKEN"));
var auth = login.Ok()?.Auth ?? throw new HttpRequestException(login.RawContent, null, login.StatusCode);
var client = Connect(auth.Base64);
var json = client.GetRequiredService<JsonSerializerOptionsProvider>().Options;

// 2. The request
var request = JsonSerializer.Deserialize<Generate3DTilesUrlRequest>("""
    {
      "node_uuid": "00000000-0000-0000-0000-000000000000",
      "version_uuids": [
        "BIM_WORKS_FIRST_MODEL"
      ],
      "settings": {},
      "link_account": false
    }
    """, json);

// 3. The call
var response = await client.GetRequiredService<IGISApi>().Generate3DTilesUrlAsync(request);

// 4. The result
var result = response.Ok() ?? throw new HttpRequestException(response.RawContent, null, response.StatusCode);
Console.WriteLine(JsonSerializer.Serialize(result, json));
```

## `GetGeoReferenceAsync` {#getgeoreference}

```csharp
Task<IGetGeoReferenceApiResponse> GetGeoReferenceAsync(Option<GetGeoReferenceRequest> getGeoReferenceRequest = default, CancellationToken cancellationToken = default)
```

Read or convert a georeference. With `model`: the georeference stored on the Version (null when it has none), in `target_epsg`, with its anchor point in model coordinates, the grid convergence and how its rotation is measured (`rotation_north`). `include_map_conversion` adds what the model's own IfcMapConversion says, for a comparison.

<table class="dense">
<tbody>
<tr><th>Operation</th><td>[[openapi:GetGeoReference]] · <code>POST /openapi/gis/GetGeoReference</code></td></tr>
<tr><th>Scope</th><td>[[scope:gis:read]]</td></tr>
</tbody>
</table>

### Parameters

<table class="dense">
<thead><tr><th>Name</th><th>Type</th><th>Description</th></tr></thead>
<tbody>
<tr><td><code>getGeoReferenceRequest</code></td><td><code>[[page:reference/sdk/dotnet/models#GetGeoReferenceRequest|GetGeoReferenceRequest]]</code><span class="opt">optional</span></td><td>The request: its properties are those of the model, its JSON that of [[openapi:GetGeoReference]]'s request body.</td></tr>
</tbody>
</table>

### Returns

<code>[[page:reference/sdk/dotnet/models#GeoReferenceResult|GeoReferenceResult]]</code> — The georeference

### Example

```csharp
using System.Text.Json;
using BIMworks.Sdk.Api;
using BIMworks.Sdk.Client;
using BIMworks.Sdk.Extensions;
using BIMworks.Sdk.Model;
using Microsoft.Extensions.DependencyInjection;

// 1. Connect to BIM.works and log in with your API token
IServiceProvider Connect(string bearer)
{
    var services = new ServiceCollection();
    services.AddApi(options =>
    {
        options.AddTokens(new BearerToken(bearer));
        options.AddApiHttpClients(http =>
        {
            http.BaseAddress = new Uri("BIM_WORKS_ADDRESS" + "/openapi");
            http.Timeout = Timeout.InfiniteTimeSpan;
        });
    });
    return services.BuildServiceProvider();
}
var login = await Connect("").GetRequiredService<IAuthApi>().LoginWithApiTokenAsync(new LoginWithApiTokenRequest("BIM_WORKS_API_TOKEN"));
var auth = login.Ok()?.Auth ?? throw new HttpRequestException(login.RawContent, null, login.StatusCode);
var client = Connect(auth.Base64);
var json = client.GetRequiredService<JsonSerializerOptionsProvider>().Options;

// 2. The request
var request = JsonSerializer.Deserialize<GetGeoReferenceRequest>("""
    {
      "model": {
        "type": "UrlModelIdentifier"
      },
      "geo_reference": {},
      "target_epsg": "EPSG:4326",
      "include_map_conversion": false,
      "include_source": false
    }
    """, json);

// 3. The call
var response = await client.GetRequiredService<IGISApi>().GetGeoReferenceAsync(request);

// 4. The result
var result = response.Ok() ?? throw new HttpRequestException(response.RawContent, null, response.StatusCode);
Console.WriteLine(JsonSerializer.Serialize(result, json));
```

## `SetGeoReferenceAsync` {#setgeoreference}

```csharp
Task<ISetGeoReferenceApiResponse> SetGeoReferenceAsync(SetGeoReferenceRequest setGeoReferenceRequest, CancellationToken cancellationToken = default)
```

Store a Version's georeference. Stores where the model is on earth: the georeference (a point in a coordinate system with a rotation) and the anchor point in model coordinates that it applies to. `rotation_north` says whether the rotation is to grid north (GRID) or true north (TRUE); without it the rotation is to grid north of `original_epsg` when there is one, else to true north. Needs write rights on the Version. To compute one from the model first, see ExtractGeoReference.

<table class="dense">
<tbody>
<tr><th>Operation</th><td>[[openapi:SetGeoReference]] · <code>POST /openapi/gis/SetGeoReference</code></td></tr>
<tr><th>Scope</th><td>[[scope:gis:write]]</td></tr>
</tbody>
</table>

### Parameters

<table class="dense">
<thead><tr><th>Name</th><th>Type</th><th>Description</th></tr></thead>
<tbody>
<tr><td><code>setGeoReferenceRequest</code></td><td><code>[[page:reference/sdk/dotnet/models#SetGeoReferenceRequest|SetGeoReferenceRequest]]</code><span class="req">required</span></td><td>The request: its properties are those of the model, its JSON that of [[openapi:SetGeoReference]]'s request body.</td></tr>
</tbody>
</table>

### Returns

Nothing: the operation answers without a body (Stored).

### Example

```csharp
using System.Text.Json;
using BIMworks.Sdk.Api;
using BIMworks.Sdk.Client;
using BIMworks.Sdk.Extensions;
using BIMworks.Sdk.Model;
using Microsoft.Extensions.DependencyInjection;

// 1. Connect to BIM.works and log in with your API token
IServiceProvider Connect(string bearer)
{
    var services = new ServiceCollection();
    services.AddApi(options =>
    {
        options.AddTokens(new BearerToken(bearer));
        options.AddApiHttpClients(http =>
        {
            http.BaseAddress = new Uri("BIM_WORKS_ADDRESS" + "/openapi");
            http.Timeout = Timeout.InfiniteTimeSpan;
        });
    });
    return services.BuildServiceProvider();
}
var login = await Connect("").GetRequiredService<IAuthApi>().LoginWithApiTokenAsync(new LoginWithApiTokenRequest("BIM_WORKS_API_TOKEN"));
var auth = login.Ok()?.Auth ?? throw new HttpRequestException(login.RawContent, null, login.StatusCode);
var client = Connect(auth.Base64);
var json = client.GetRequiredService<JsonSerializerOptionsProvider>().Options;

// 2. The request
var request = JsonSerializer.Deserialize<SetGeoReferenceRequest>("""
    {
      "model": {
        "type": "UrlModelIdentifier"
      },
      "geo_reference": {},
      "anchor_point": {
        "x": 0.0,
        "y": 0.0,
        "z": 0.0
      },
      "rotation_north": "GRID",
      "original_epsg": ""
    }
    """, json);

// 3. The call
var response = await client.GetRequiredService<IGISApi>().SetGeoReferenceAsync(request);

// 4. The result
// (SetGeoReference answers no content: the call returns once it succeeded and throws an HttpRequestException otherwise)
if (!response.IsSuccessStatusCode) throw new HttpRequestException(response.RawContent, null, response.StatusCode);
Console.WriteLine("Done");
```
