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

coshp

v2.0.2

Published

Cloud Optimized Shape File Reader

Downloads

15

Readme

cloud optimized shapefile

A library to optimize shapefiles to the cloud and then query them remotely via HTTP, like how cloud optimized geotiffs allow this for imagery. Provides tools to generate .qix geoindex files, sort shapefiles geographically based on their order in the .qix file, and query shapefiles remotely by bounding box. Based on the idea from Paul Ramsey.

Geoindexing algorithm based on flatbush by Volodymyr Agafonkin.

API

install via npm

npm install coshp
const coshp = new Coshp('https://example.biz/path/to/shapfile.shp');
const geojson = coshp.query([xmin, ymin, xmax, ymax]);

import directly into script:

import Coshp from 'https://unpkg.com/coshp@latest/coshp.js`

Bounding box should be in the same projection as your file is in, the result is always in WGS84.

You can as a 2nd parameter pass in a block size for the .qix file. It currently defaults to 4KiB but it may be changed in the future.

Command line tools

to add a .qix index file you can run the following command

npx coshp build ./path/to/shape.shp

then to reorder your shapefile to be queryable via the .qix file run

npx coshp reorder  ./path/to/shape.shp

and it will output the reordered file at ./path/to/shape-ordered.shp

questions

does it work?

YES!

why?

I was doing research for a talk and Paul Ramsey nerd sniped me with this blog post.

is this a good idea?

probably not

Versions

2.0.0

Version 2.0.0 corrects enough bugs in how .qix files are generated and handled that if you happened to actually be using this in production (you should not) I'd consider it a breaking change. The upside is that it's totally compatible with mapsever now. Changes include

  • correctly calculating .qix sibling node offsets, the .qix documentation had a bug implying they were calculated from the end of the mandatory part of the node, they are actually calculated from the end of the node.
  • zero indexing all ids in the .qix files, shp files are technically 1 indexed but since record ids are usually inferred from position the actual id values are rarely dealt with.
  • did you know there is a random byte between the header and the rest of the file in .dbf file? Yeah neither did I but it's now included in the .dbf files created when reordering your files with this tool.
  • fixed a bug where we were accidentally not grabbing the last record of any range we queried
  • .qix files are now loaded incrementally in user specified blocks defaulting to 4kb.
  • downloading rows from the remote .shp and .dbf file is now parallelized up to a limit.

2.0.1

Small bug fix as I didn't publish 2.0.0 quite right

2.0.2

Change the main file name so that you can easily import coshp directly.