Skip to content

Load spatial extension in JavaScript #1621

Answered by parkerziegler
kbatchu asked this question in Q&A
Discussion options

You must be logged in to vote

Hey @kbatchu! You load the spatial extension via db.query. Beneath your code above you can do:

await db.query(`
  INSTALL spatial;
  LOAD spatial;
  ... // Your SQL query here. 
`);

For example, to load the spatial extension and read in a remote GeoJSON file, you can do something like this:

await db.query(`
  INSTALL spatial;
  LOAD spatial;
  CREATE TABLE tableName as SELECT * FROM 'https://somedomain.com/file.geojson');
`);

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by kbatchu
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants