Dear All,
Is there a way to pull facility geo coordinates using the API or any other method in DHIS2?
Would appreciate your help.
Thank you.
Dear All,
Is there a way to pull facility geo coordinates using the API or any other method in DHIS2?
Would appreciate your help.
Thank you.
Hi Dr. Okoye,
You can use the below api to pull facility geo coordinates:
baseUrl+“api/organisationUnits.json?fields=id,code,name,latitude,longitude,coordinates”
In React JS you can fetch:
const fetchOptions = {
headers: {
Accept: ‘application/json’,
Authorization: Basic ${btoa('admin:district')}
}
};
return new Promise( (resolve, reject) => {
fetch(baseUrl+“api/organisationUnits.json?fields=id,code,name,latitude,longitude,coordinates”, fetchOptions)
.then(r => resolve(r.json()))
.catch(err => reject(err));
});
Thanks
Thank you. Will get back to you on this.
Hi Dr Okoye,
It might also be helpful to add ‘featureType’, which helps you distinguish points from polygons/areas. See a similar discussion here.
Cheers, Sam.
Sure, just add ‘,level’ to the list of fields. To see a full list of all fields available, you can do ?fields=* - this will return every available field (but I’d remove ‘&paging=false’ before you do that, as otherwise it will return a lot of data!).