npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

gus-api

v0.1.0

Published

Convert Google Spreadsheets to GeoJSON

Downloads

4

Readme

GUS API

G eoJSON
U r
S preadsheet
:smile:

API for converting a Google Spreadsheet into a GeoJSON object. Inspired by the GUS map project, but made to be a more generic tool to enable any type of map rendering library. Have a look at the example spreadsheet and an example request to the API.

Prepare your spreadsheet

The main endpoint is GET /{spreadsheet id} which gets your Google Spreadsheet and converts it into a GeoJSON response.

Spreadsheet structure

The format of your spreadsheet requires the first row to be headers and two columns representing longitude and latitude. Each of these columns must be in WGS84 coordinates and can only represent points. The name of these columns MUST match the following formats:

  • longitude, latitude or LONGITUDE, LATITUDE
  • long, lat or LONG, LAT
  • lng, lat or LNG, LAT
  • lon, lat or LON, LAT
  • x, y or X, Y

Publish your spreadsheet

In order to make the spreadsheet available to the API, you must "publish to the web" by selecting File > Publish to the web... > Press Publish. This will make your spreadsheet publicly available. Once this is complete, grab the ID of the spreadsheet in the URL. It will look similar to this 1ctA2wUBHGjrBRhQlma_x2Q5oRsC5L85XALfhkezsQMY. Use this ID to pass into the following endpoint

Usage

The conversion can happen in three ways:

API

Use the following URL to make a request (replace {id} with your spreadsheet ID)

https://e53r0f186h.execute-api.us-west-2.amazonaws.com/production/{id}

You'll see four possible responses:

  • 200 - successful request with a GeoJSON object
  • 400 - missing ID parameter
  • 404 - could not find the spreadsheet, either it hasn't been published or the ID is incorrect
  • 5xx - an unexpected failure with the application

Node.js module

Install the module

npm install gus-api

Require it

const toGeojson = require('gus-api').toGeojson;
const spreadsheetID = 'my-id';

toGeojson(id, (err, geojson) => {
  // ...
});

Copy and paste

Or just copy and paste the toGeojson function directly from index.js!

Develop

GUS API is deployed with AWS API Gateway and a Lambda Proxy. If you have the proper development keys, make your changes and commit, and deploy the code by running npm run deploy which will install node modules using the --production flag and zip up the directory to save on AWS s3 for the lambda to use.

Test

npm test