gistda-sphere-react

Population

Estimate how many people live in an area

population.get estimates the population inside an area, from Meta's high-resolution population density maps.

const result = await services.population.get(
  "POLYGON((100.49 13.76, 100.52 13.76, 100.52 13.73, 100.49 13.73, 100.49 13.76))",
  { year: 2020 }
);
console.log(result.data, result.meta);
ParameterTypeDescription
wktstringThe area as well-known text (WKT), up to 1,000 km².
yearnumberYear of the estimate.

From a drawn shape

Shapes drawn on the map can be turned into WKT. For a polygon ref:

import { type GeoJSONFeature, type GeoJSONPolygon } from "gistda-sphere-react";

const feature = polygonRef.current?.toGeoJSON() as GeoJSONFeature<GeoJSONPolygon>;
const ring = feature.geometry.coordinates[0];
const wkt = `POLYGON((${ring.map(([lon, lat]) => `${lon} ${lat}`).join(", ")}))`;
const result = await services.population.get(wkt);

Large polygons make long requests, so the client sends them as POST automatically.

On this page