For the complete documentation index, see llms.txt. This page is also available as Markdown.

Load Spatial Data

jsgeoda supports reading geojson file. The file could be fed using URL or File object (e.g. via drag-and-drop). The content of the geojson file needs to be read in binary format: ArrayBuffer. Then, you can call read_geojson() function to load geojson into jsgeoda.

const jsgeoda = require('jsgeoda');
const fs = require('fs');

// create jsgeoda instance
const geoda = await jsgeoda.New();

// print out "Hello jsgeoda 0.0.8"
console.log("Hello jsgeoda", geoda.version);

// read a geojson file into ArrayBuffer using fs
const data = fs.readFileSync('./data/natregimes.geojson').buffer;

// load geojson in jsgeoda, an unique id (string) will be returned for further usage
const nat_uid = geoda.readGeoJSON(data);

const num_obs = geoda.getNumObs(nat_uid);
console.log("number of observations:", num_obs);

const col_names = geoda.getColNames(nat);
console.log("column names:", col_names);

const hr60 = geoda.getCol(nat, "HR60");
console.log("hr60:", hr60);

Try it yourself in the playground

Last updated