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

geojson-data-link

v0.3.2

Published

A tool to match GeoJSON point coordinates (or a polygon centroid) to a polygon and copy over properties

Downloads

3

Readme

GeoJSON Data Link

A NodeJS library to link properties on two different GeoJSON files by determining if a geographic point is within a larger geographic region and linking the metadata. This project is sponsored by The Data Center of Southeast Louisiana

Installation

npm install geojson-data-link

or

yarn install geojson-data-link

About The Data Center

The Data Center of Southeast Louisiana is a fully independent, data-focused non-profit with a mission to build prosperous, inclusive, and sustainable communities by making informed decisions possible. If you find this tool useful, please visit our web site to learn more about our work and consider supporting us in our mission.

Usage

Command Line Interface

The command line version accepts as arguments the two geojson files, the fields you want to merge, and some formatting options. It returns your new, merged file to stdout. (If you don't work with the CLI often, you can append > filename.geojson to the command to save the output to a file instead of display it in the terminal.)

The long example might be:

npx geojson-data-link --coordinatesfile ~/geography/library-locations.geojson --polyfile ~/geography/census-tracts.geojson --fields GEOID STATEFP > ~/geography/libraries-with-new-data.geojson

This is equivalent to:

npx geojson-data-link -c ~/geography/library-locations.geojson -p ~/geography/census-tracts.geojson -f GEOID STATEFP > ~/geography/libraries-with-new-data.geojson

Here's the options:

Link fields between a GeoJSON point file and a GeoJSON polygon file

Options:
  -p, --polyfile         GeoJSON file with Polygons [required]
  -c, --coordinatesfile  GeoJSON file with either Points or Polygons. (If matching has polygons, intersect will be used) [required]
  -o, --output           Output format; options include geojson (default) or just the metadata in csv or json format
  -r, --reverse          Copy the data from the coordinates file data to the polygon file instead [boolean]
  -b, --beautify         Beautify the output [boolean]
  -f, --fields           Fields to match, separated by a space [array] [required]
  --version, -v          Show version number [boolean]
  -h, --help             Show help [boolean]

As a Library

const match = require('./matchGEOID').matchGEOID;
const polyfile = '~/geography/census-track.geojson';
const coordinatesfile = '~/geography/library-locations.geojson';

match({
  polyfile: polyfile,
  coordinatesfile: coordinatesfile,
  fields: ["GEOID","STATEFP","COUNTYFP","TRACTCE"],
  sync: false,
  reverse: false
}, function(err, asyncCoordsFile) {
  if (err) console.error(err);
  else console.log(JSON.stringify(asyncCoordsFile));
});

Your options are:

  • polyfile: the geojson file with your polygon features (i.e., regions to check)
  • coordinatesfile: the geojson file with your point/coordinate features
  • fields: an array of fields to copy over after linking
  • sync: whether the command to get the files runs asynchronously or synchronously.

If you set sync: true, be warned that it will block I/O while it fetches the (potentially large) files. It's faster for one-off scripts but is not recommended for larger projects.