You can find information about two different APIs, which are based on the open data of the Latvian State Land Service's Cadastre Information System and Estonian Land Board (Maa-amet). Information about the cadastral information layer WMS can be found here here.

Parcel and building search

Autocomplete search, that allows to find specific parcel (in Latvia or Estonia) or building (only in Latvia) by its cadastral number, and get their geometry.

API URL

The request URL should match the following pattern:

https://api.kartes.lv/v3//search?layers=cadastral

By default, the response is given in JSON (JSONP and XML are also available).

The HTTP GET request method is used.

Query parameters

The request consists of the following GET parameters:

Parameter Description Available values
q Following formats for cadastral number queries:
  • Latvian parcels (11 digits),
  • Latvian buildings (14 digits)
  • Estonian parcels (#####:###:####, where # represents a digit)
limit Maximum number of returned objects. Up to 50 objects can be returned.
layers
  • cadastral - cadastral parcel
  • cadastral_building - cadastral building
format
  • standart
  • (JSON; default value)
  • geojson
geometry
fields Fields that should be in the response (comma separated).
  • name - cadastral number
  • iso_code - country ISO CODE
  • the_geom - geometry in WKT
cs Coordinate system (optional parameter). By default, the WGS-84 (EPSG:4326) coordinates are used. The parameter allows to set other CRS.
  • wgs84 - WGS-84 (EPSG:4326)
  • lks - TM Baltic93 (EPSG:25884)

Response parameters

The response consists of the queried cadastral number, its properties, CRS, with an array of objects with parameters defined by the fields parameter.

Error codes

Status code Description
200 Wrong input data. Server can’t respond due to client error.
404 No location found. The URL is not recognized; the resource does not exist.
5xx Server error.

Examples

Input:

https://api.kartes.lv/v3//search?q=01000242161&fields=name,the_geom&format=geojson&layers=cadastral

Output:

{
   "cadastral":{
      "type":"FeatureCollection",
      "name":"cadastral",
      "crs":{
         "type":"name",
         "properties":{
            "name":"urn:ogc:def:crs:EPSG::4326"
         }
      },
      "features":[
         {
            "type":"Feature",
            "geometry":{
               "type":"Polygon",
               "coordinates":[
                  [
                     [
                        24.121745,
                        56.973326
                     ],
                     [
                        24.123015,
                        56.973876
                     ],
                     [
                        24.123056,
                        56.973848
                     ],
                     [
                        24.12386,
                        56.973294
                     ],
                     [
                        24.12267,
                        56.972794
                     ],
                     [
                        24.121791,
                        56.9733
                     ],
                     [
                        24.121745,
                        56.973326
                     ]
                  ]
               ]
            },
            "properties":{
               "name":"01000242161",
               "iso_code":"LVA"
            }
         }
      ]
   }
}

Use examples

Defining a cadastral API class in JavaScript code:

class CadastreApi {
    constructor() {
        this.apiKey = 'your_api_key_here'; // Replace with your actual API key
        this.baseUrl = 'https://api.kartes.lv/v3';
    }

    // Method to fetch cadastral data
    async getCadastralData(query) {
        const searchParams = new URLSearchParams({
            q: query,
            fields: 'name,the_geom',
            format: 'geojson',
            layers: 'cadastral'
        });
        const url = `${this.baseUrl}/${this.apiKey}/search?${searchParams}`;

        try {
            const response = await fetch(url);

            // Check if the response is ok (status code 200-299)
            if (!response.ok) {
                throw new Error(`Error fetching data: ${response.statusText}`);
            }

            const data = await response.json();
            return { success: true, data };
        } catch (error) {
            console.error('Fetch error:', error);
            return { success: false, error: error.message };
        }
    }
}

Using the cadastral API class:

const api = new CadastreAPI();

api.getCadastralData('01000242161')
    .then(result => {
        if (!result.success) {
            console.error('Error:', result.error); // Handle the error
            return;
        }

        console.log(result.data);
        // Use the data
    });

Cadastral (parcel) reverse geocoding

Returns parcel number and extra properties for the given coordinates (location information).

API URL

The request URL should match the following pattern:

https://api.kartes.lv/v3//reverse_geocoding?type=cadastral

By default, the response is given in JSON (JSONP and XML are also available).

The HTTP GET request method is used.

Query parameters

The request consists of the following GET parameters:

Parameter Description Possible values
x x-coordinate in the TM Baltic93 CRS (EPSG:25884).
y y-coordinate in the TM Baltic93 CRS (EPSG:25884).
lat Latitude coordinate in the WGS-84 projection (EPSG:4326)
lon Longitude coordinate in the WGS-84 projection (EPSG:4326)
type cadastral
result_data_type Output format. JSON is the default option.
  • json
  • jsonp
  • xml
callback Use it if you use result_data_type=jsonp.

Response parameter

The response consists of a single element. It has following parameters:

Parameter Description
code Parcel number.
ownership_status Parcel ownership status (only for Latvian parcels).
area Parcel area (in hectares).

Examples

Input:

https://api.kartes.lv/v3//reverse_geocoding?lat=56.952327646236431&lon=23.90430271953273&type=cadastral

Output:

{
    "code":"80480030366",
    "ownership_status":"Juridiska persona"
}

Use examples

Defining a cadastral reverse geocoding API class in JavaScript code:

class CadastreApi {
    constructor() {
        this.apiKey = 'your_api_key_here'; // Replace with your actual API key
        this.baseUrl = 'https://api.kartes.lv/v3';
    }

    // Method to fetch cadastral parcel data using reverse geocoding
    async getCadastralParcel(lat, lon) {
        const searchParams = new URLSearchParams({
            lat: lat,
            lon: lon,
            type: 'cadastral'
        });
        const url = `${this.baseUrl}/${this.apiKey}/reverse_geocoding?${searchParams}`;

        try {
            const response = await fetch(url);

            // Check if the response is ok (status code 200-299)
            if (!response.ok) {
                throw new Error(`Error fetching data: ${response.statusText}`);
            }

            const data = await response.json();
            return { success: true, data };
        } catch (error) {
            console.error('Fetch error:', error);
            return { success: false, error: error.message };
        }
    }
}

Using the cadastral reverse geocoding API class:

const api = new CadastreAPI();

api.getCadastralParcel(56.952327646236431, 23.90430271953273)
    .then(result => {
        if (!result.success) {
            console.error('Error:', result.error); // Handle the error
            return;
        }

        console.log(result.data);
        // Use the data
    });