Retrieve Geometries for a Postcode using the Atlas API
The Atlas API enables businesses to visualize and analyze geographical data on interactive maps. Follow these steps to retrieve geometries for a specific postcode via the Atlas API:
Before you start
Before proceeding, ensure you have an API key and access to Atlas. If you haven't obtained these credentials yet, please contact us at [email protected] or learn more about Atlas zoning features on Atlas zoning features.
Determine Area Containing Postcode
First, find out in which area the postcode is located by making the following API call.
curl --request POST \
--url 'https://app-api.geposit.se/v2.0/container/postcode?api_key={API_TOKEN}' \
--header 'accept: application/json' \
--header 'content-type: application/json' \
--data '
{
"map_id": "{map_id}",
"postcode": "11120",
"region": "se"
}
Try this out in the sandbox.
Get all areas containing postcode
Below is an example response.
[
{
"id": "jjPx5CiVsirUCk3Ulnp1",
"user_id": "uoGS8kUIVid8cRtzJR3RAiKHEuu2",
"tenant_id": "eb0a12c097774d0cb0b051dbaa735fd7",
"map_id": "OgscuSgxcYtbFUOMndie",
"layer_id": "toaJJQ25U09GZ67b726c",
"created_at": "2024-04-03T11:53:47.542856Z",
"updated_at": "2024-04-03T11:54:24.612108Z",
"name": "nnn",
"color": "",
"description": "",
"visible": true,
"updated_by": "uoGS8kUIVid8cRtzJR3RAiKHEuu2"
}
]
Get Feature ID and Ref ID
Next, retrieve the feature ID and ref ID for the area containing the postcode using the following API call:
curl --request GET \
--url 'https://app-api.geposit.se/v2.0/container/jjPx5CiVsirUCk3Ulnp1?with_geo_names=true&api_key={API_TOKEN}' \
--header 'accept: application/json'
Try this out in the sandbox.
Below is an example response. From the response, extract the relevant ref ID and feature ID for the desired postcode.
{
"id": "jjPx5CiVsirUCk3Ulnp1",
"map_id": "OgscuSgxcYtbFUOMndie",
"layer_id": "toaJJQ25U09GZ67b726c",
"name": "nnn",
"color": "",
"description": "",
"visible": true,
"created_at": "2024-04-03T11:53:47.542856Z",
"updated_at": "2024-04-03T11:54:24.612108Z",
"user_id": "uoGS8kUIVid8cRtzJR3RAiKHEuu2",
"updated_by": "uoGS8kUIVid8cRtzJR3RAiKHEuu2",
"geo_ids_ref_groups": [
{
"ref_id": "3f4623758663c4564d514711cd32e5a5",
"geo_type": "postalcode_5",
"country": "se",
"geo_ids": [
{
"polygon_id": "HzjonsUJHwSfMfWrOEwx",
"feature_id": "24541aa1017796ea4ae52745a328af46",
"geo_name": "11120",
"geo_code": "11120"
},
{
"polygon_id": "OyXEwoiLFNeFNvKqzZjk",
"feature_id": "3e5c147d0811ebe6f18c1dea7f94083d",
"geo_name": "11121",
"geo_code": "11121"
},
{
"polygon_id": "ipWGuyBCLzzVKgSPpUAU",
"feature_id": "80e0c9434ed40fcf74f42e3777b1bdb4",
"geo_name": "11122",
"geo_code": "11122"
},
{
"polygon_id": "ASagmpVbRYdLpzxbrUbM",
"feature_id": "c9d3aba5f1cd496233d56b261f8583b4",
"geo_name": "11164",
"geo_code": "11164"
},
{
"polygon_id": "CAGzjumfVcAUYoGGHroa",
"feature_id": "e20566457e44672b7bc6bd2d042f5629",
"geo_name": "11137",
"geo_code": "11137"
}
],
"custom_ids": null
}
],
"custom_polygons": [],
"area_sq.km": 0.6066129786435276
}
Retrieve Geometry
Finally, retrieve the geometry for the postcode using the following API call:
curl --request GET \
--url 'https://app-api.geposit.se/v2.0/datasets/ref/se/3f4623758663c4564d514711cd32e5a5/feature/24541aa1017796ea4ae52745a328af46/geojson?api_key={API_TOKEN}' \
--header 'accept: application/json'
Replace {API_TOKEN} with your actual API token.
You can use the ref ID and feature ID obtained in step 2 as parameters in this call.
Try this out in the sandbox.
Final Result
The response will contain the geometry information for the specified postcode, including coordinates in GeoJSON format.
{
"region": "se",
"ref_id": "3f4623758663c4564d514711cd32e5a5",
"feature_id": "24541aa1017796ea4ae52745a328af46",
"type": "postalcode_5",
"code": "11120",
"name": "11120",
"extra": "",
"the_geom": "{\"type\":\"Polygon\",\"coordinates\":[[[18.061297,59.3343415],[18.0612272,59.3343058],[18.0608383,59.3342835],[18.0607375,59.3342592],[18.0597686,59.3340256],[18.0587627,59.3337931],[18.058753,59.3336855],[18.0584151,59.3336414],[18.0570055,59.333713],[18.0559207,59.3334234],[18.0552016,59.3332464],[18.0549153,59.3335019],[18.05508,59.3337178],[18.0557998,59.3338986],[18.0566267,59.3339017],[18.0569844,59.3341629],[18.0563678,59.334739],[18.0554714,59.3346477],[18.055411,59.3344649],[18.0544845,59.334235],[18.0542015,59.3345112],[18.0556232,59.3348688],[18.0569778,59.3352141],[18.0566736,59.3354013],[18.056431,59.3353441],[18.0558298,59.3359457],[18.0551714,59.3357812],[18.0546891,59.3356638],[18.0534204,59.335349],[18.0531455,59.3352863],[18.0528467,59.3344494],[18.0540603,59.333526],[18.0547279,59.3334205],[18.0549035,59.3330255],[18.0570858,59.3312804],[18.0582852,59.3305378],[18.0571621,59.3301732],[18.0582918,59.3290194],[18.0586218,59.3290945],[18.0589235,59.3291387],[18.0593158,59.3290915],[18.059531,59.3290249],[18.0598118,59.3287406],[18.0599576,59.3285035],[18.0615256,59.3287318],[18.060574,59.3298819],[18.0599194,59.3306435],[18.0594996,59.3307429],[18.05944,59.33096],[18.0592519,59.3311172],[18.0591822,59.3313208],[18.0589516,59.3315915],[18.0585731,59.3320767],[18.0580523,59.3326416],[18.0580247,59.3330829],[18.0585581,59.3334217],[18.0587672,59.3335545],[18.05904,59.3333527],[18.0595573,59.3334375],[18.0599516,59.3336169],[18.059801,59.3338002],[18.0603756,59.3339484],[18.0605033,59.3339814],[18.0609758,59.33415],[18.0613425,59.3342326],[18.0619497,59.3343694],[18.0620095,59.3344687],[18.061902,59.3345693],[18.061513,59.3344519],[18.061297,59.3343415]]]}"
}
Note: By assigning attribute lists and attribute values to your areas you can increase the query possibilities and filter your areas based on specific attributes. See the API explorer for more information on the API support.
Updated 5 months ago