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

esri-query

v1.2.1

Published

`esri-query` is a command-line tool that extracts data from ESRI REST endpoints when nothing else will.

Downloads

22

Readme

esri-query

esri-query is a command-line tool that extracts data from ESRI REST endpoints when nothing else will.

Table of Contents

Installation

To install esri-query, you need to have Node.js installed.

You will then need to build it:

git clone https://github.com/jimmyrocks/esri-query.git
cd ./esri-query
npm run build

Usage

To use esri-query, run the following command in your terminal:

esri-query --url <URL>

The <URL> should be the URL of the ESRI REST endpoint, for example https://sampleserver6.arcgisonline.com/arcgis/rest/services/LocalGovernment/Recreation/FeatureServer/2.

By default, the output is printed to the console in GeoJSON format. You can specify other options using flags, as shown in the Options section.

Options

| Flag | Description | | ------------------------| --------------------------------------------------------------------------------------------------- | | -h, --help | Display this usage guide. | | -u, --url | The URL of the ESRI Rest Endpoint. MapServer or Feature Server (ex. https://.../FeatureServer/0) | | -w, --where string | ESRI Style Where (Defaults to 1=1) | | -f, --format string | [gpkg, geojson, geojsonseq] | | -o, --output string | The file to write out (if set, type becomes file) | | -y, --pretty | Pretty Print JSON (geojsonseq will override this) | | -c, --feature-count num | Features per query, reduce this number if you're seeing a lot of bad requests from the server (Default is server default) | | -j, --json | Use ESRI json to download data (otherwise it will try to use the esri protobuf format) | | -p, --progress | Show progress during the process | | -l, --layer-name | For GPKG files, specifies the layer-name, if unset, it will use the filename | | -b, --no-bbox | Does not calculate a bbox for each feature. (Bboxs are slower to generate, but may speed up calculations on the resulting file) |

Examples

Simplest GeoJSON Example

npm run start -- --url "https://sampleserver6.arcgisonline.com/arcgis/rest/services/LocalGovernment/Recreation/FeatureServer/2"

to GeoJSONSeq File Example

GeoJSONSeq allows parallel processing in Tippecanoe

npm run start -- \
--url "https://sampleserver6.arcgisonline.com/arcgis/rest/services/LocalGovernment/Recreation/FeatureServer/2" \
--format geojsonseq \
--output ./example.geojsonseq

to GeoPackage File Example

GeoPackages load into PostgreSQL much faster than GeoJSON or GeoJSONSeq

npm run start -- \
--url "https://sampleserver6.arcgisonline.com/arcgis/rest/services/LocalGovernment/Recreation/FeatureServer/2" \
--format gpkg \
--output ./example.gpkg

Testing

To test esri-query, run the following command in your terminal:

npm run test

Formats

Input

ESRI Protobuf (PBF)

No, this isn't the same as MapBox Vector Tiles Protobuf schema, although both use the same underlying Protobuf format.

ESRI Protobuf format provides "zig-zag encoded" points on a quantized grid that are stored in a binary format (Google Protobuf). (You can read all about quantization parameters). The format is very similar to the ESRI JSON format, which is why this library uses the Terraformer JS library under the hood to convert the Protobuf data to GeoJSON.

This format is much faster than the ESRI JSON format, but is not compatible with all ArcGSI REST Servers/

ESRI JSON

ESRI has their own spatial format that provides some more information than standard GeoJSON. All ESRI ArcGIS REST Vector Endpoints support from form of ESRI JSON, so when PBF is not supported or a query is run with --json, this is the source format that is used. You can find more information about the ESRI JSON format in the ArcGIS REST API Documentation.

Output

GeoJSON

GeoJSON is a standard GeoSpatial format that has the most interoperability. This is the "native" geospatial format used by esri-query, so all projection conversions are done on the server.

GeoJSONSeq

This is a format creates individual GeoJSON Features into a format that is more useful for parallel processing. The features are separated by a newline (LF), which makes it Newline Delimited JSON. It is useful for Tippecanoe.

You can read more abot the format on the ogr2ogr page. There is also RS delimited version, but it's not supported by this tool since I don't have a use for it, but if you do, open an issue.

GeoPackage

GeoPackages are sqlite files that follow a standard for spatial data storage. In esri-query, these GeoPackage files are created with the better-sqlite3 library, they do not use spatialite, and do not have a spatial index. GeoPackage uses the Well-Known-Binary format, so these files are very performant for importing to PostGIS (which uses its own version of WKB).

Since the output GeoPackages aren't spatialite files or spatially indexed, they may be a little slower in tools like QGIS. You can use a tool like ogr2ogr or QGIS to convert this GeoPackage to one with a spatial index if needed.