Skip to main content
Solved

Mapping of territory codes

  • November 4, 2025
  • 5 replies
  • 32 views

Hello

When I add a territory for a dataset, and retrieve the dataset through the API, then I get a random code (e.g. ch_80_2477 ). It is quite cumbersome to map these by hand, but I’ve done it for ~10 cities and regions.

 

Now, we have a new dataset with a lot more territories, and it would be cumbersome (and unnecessary, honestly), to map these by hand. Where can I find a list with all of these codes, so that I can import them and use them in my code? Do these follow a public standard?

Thank you!

Best answer by dgaraud

Hi ​@RenatoF 

Good point about using the Explore API endpoint to get some info about this territory code :)

Depending on your dataset and the country that contains the geographic data of your dataset, the retrieval of territory metadata is done via our reference geographic data. For instance these datasets are used when you use the Retrieve Admin Divisions Processor.

You have correctly guessed the breakdown of this code into three elements:

  • country ISO code, CH for Switzerland
  • an integer between 40 and 90 most of the time
  • the unique identifier of the territory found as a field in the reference geographic dataset

The integer between ch and 2477 corresponds to the typology of the territory concerned, or in other words the administrative level. For example, it could be a territory at the scale of a city, department, district, region, etc. This is a convention inspired by the different levels in OpenStreetMap but remains an internal Huwise convention.

For Switzerland specifically, we have:

  • 40 for Kanton
  • 60 for Bezirk
  • 80 for Gemeinde
  • 81 for postal codes (4 digits)
  • 82 for postal codes (6 digits)

The "largest" levels, i.e. those that encompass other levels, will have smaller numbers. And the finer the granularity, the larger the number will be. Depending on the country, this “admin level digit” don’t have the same meaning.

 

Hope this has been clear enough :)

Damien

5 replies

yier.wu
Community Manager
  • Community Manager
  • 30 replies
  • November 10, 2025

Hi, 

Could it be possible to share a link to the dataset if it’s a public one? 

Thanks. 

Yier


  • Author
  • Harbinger
  • 9 replies
  • November 11, 2025

Hi, 

Could it be possible to share a link to the dataset if it’s a public one? 

Thanks. 

Yier

Sure, it’s this one:https://data.bs.ch/explore/dataset/100396/information/ 


  • Author
  • Harbinger
  • 9 replies
  • November 11, 2025

Alright, I think I solved it. First of all, I should use the Explore API. In there, I should not use the “geographic_reference” field, but the “territory” field.

If anyone needs the mapping regardless in the future, there are datasets, such as: https://hub.huwise.com/explore/assets/georef-switzerland-gemeinde/

They map the third part, e.g. 2477 in ch_80_2477 . The first part is the country, obviously. I could not figure out what the “80” refers to.


dgaraud
Huwise Team
  • Huwise Team
  • 1 reply
  • Answer
  • November 12, 2025

Hi ​@RenatoF 

Good point about using the Explore API endpoint to get some info about this territory code :)

Depending on your dataset and the country that contains the geographic data of your dataset, the retrieval of territory metadata is done via our reference geographic data. For instance these datasets are used when you use the Retrieve Admin Divisions Processor.

You have correctly guessed the breakdown of this code into three elements:

  • country ISO code, CH for Switzerland
  • an integer between 40 and 90 most of the time
  • the unique identifier of the territory found as a field in the reference geographic dataset

The integer between ch and 2477 corresponds to the typology of the territory concerned, or in other words the administrative level. For example, it could be a territory at the scale of a city, department, district, region, etc. This is a convention inspired by the different levels in OpenStreetMap but remains an internal Huwise convention.

For Switzerland specifically, we have:

  • 40 for Kanton
  • 60 for Bezirk
  • 80 for Gemeinde
  • 81 for postal codes (4 digits)
  • 82 for postal codes (6 digits)

The "largest" levels, i.e. those that encompass other levels, will have smaller numbers. And the finer the granularity, the larger the number will be. Depending on the country, this “admin level digit” don’t have the same meaning.

 

Hope this has been clear enough :)

Damien


  • Author
  • Harbinger
  • 9 replies
  • November 12, 2025

Hi ​@RenatoF 

Good point about using the Explore API endpoint to get some info about this territory code :)

Depending on your dataset and the country that contains the geographic data of your dataset, the retrieval of territory metadata is done via our reference geographic data. For instance these datasets are used when you use the Retrieve Admin Divisions Processor.

You have correctly guessed the breakdown of this code into three elements:

  • country ISO code, CH for Switzerland
  • an integer between 40 and 90 most of the time
  • the unique identifier of the territory found as a field in the reference geographic dataset

The integer between ch and 2477 corresponds to the typology of the territory concerned, or in other words the administrative level. For example, it could be a territory at the scale of a city, department, district, region, etc. This is a convention inspired by the different levels in OpenStreetMap but remains an internal Huwise convention.

For Switzerland specifically, we have:

  • 40 for Kanton
  • 60 for Bezirk
  • 80 for Gemeinde
  • 81 for postal codes (4 digits)
  • 82 for postal codes (6 digits)

The "largest" levels, i.e. those that encompass other levels, will have smaller numbers. And the finer the granularity, the larger the number will be. Depending on the country, this “admin level digit” don’t have the same meaning.

 

Hope this has been clear enough :)

Damien

Thanks for the clarification, Damien! I’ll probably come back to this thread in the future.