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

open-data-jp-prefectures-geojson

v1.1.0

Published

GeoJSON of Japanese prefectures

Downloads

5

Readme

GeoJSON of Japanese prefectures

Reason

When you look online for GeoJSON of Japanese prefectures, most results are approximate. The best resource out there is probably this gist but the files are already split by prefectures.

This module provides a single high definition GeoJSON file and some utility methods to interact with it

Source

Source data is from the National Land Information Division which is a high resolution GeoJSON file containing all administrative areas. All features are merged by prefectures and the resulting file is simplified with a Visvalingam simplification keeping lines within 5 meters of the original location.

Usage

You can use the GeoJSON file directly or the following utilities

npm install open-data-jp-prefectures-geojson

getPrefectures

const { getPrefectures } = require('open-data-jp-prefectures-geojson');

const shinjuku = [35.6877109,139.6919347];
const yoyogi = [35.6877109,139.6919347];
const point = { type: 'Feature', geometry: { type: 'Point', coordinates: shinjuku } };
const line = { type: 'Feature', geometry: { type: 'LineString', coordinates: [shinjuku, yoyogi] } };

console.log(await getPrefectures(point)); // [13]
console.log(await getPrefectures(line)); // [13]

Note that getPrefectures returns an array of Japanese prefectures.

Single points fully contained inside a prefecture will only have one value. Single points right at the border or lines crossing multiple prefectures will have multiple values.

If you're sure your LineStrings are short and don't overlap multiple prefectures, you can pass the option skipIntersect to speed up resolution.

await getPrefectures(line, { skipIntersect: true });

The default behaviour (skipIntersect: false) checks that the line crosses any prefecture at any point, so for instance if you're checking a straight line from Hokkaido to Tokyo, you'll get all the prefectures inbetween, but if you know your lines are small (for instance local streets, or railway station platforms) you can pass skipIntersect: false to only check the prefectures of the edges inside the line (for a straight line it'll be start and end, for more complex lines it's where the lines bend).

Development

  1. Clone the repo
  2. Download the source zip file into input/
  3. Run ./setup.sh to generate the output geojson file

If you want to generate a smaller GeoJSON file at lower resolution, call ./setup.sh 50 (50 is going to be the simplification interval, defaults to 5)