@allmaps/cli
Installation
With pnpm:
pnpm add -g @allmaps/cli
Documentation
Run Allmaps CLI:
allmaps
Show help:
allmaps --help
Commands
All CLI commands accept one or more files as input. You can supply these files in two ways:
- With their full or relative paths. In the CLI's help output, this is shown as
[files...]
. - Using the standard input (stdin). You can pipe the contents of the input files to the Allmaps CLI. Commands that require SVG input only accept one file, commands that require JSON input accept multiple files.
Parse and generate Georeference Annotations
Show help:
allmaps annotation --help
Generate Georeference Annotations from input files:
allmaps annotation generate [files...]
Parse input files and output them in the format used internally by Allmaps:
allmaps annotation parse [files...]
Convert the resource mask from the input files to SVG polygons:
allmaps annotation svg [files...]
For all the commands above, the input files can be either Georeference Annotations or parsed Georeference Annotations
Transform resource coordinates to geospatial coordinates (and vice versa)
Show help:
allmaps transform --help
Transform SVG to GeoJSON using a Georeference Annotation:
allmaps transform svg -a <filename> [files...]
Transform GeoJSON to SVG using a Georeference Annotation:
allmaps transform geojson -a <filename> [files...]
The filename of the Georeference Annotation must be supplied with the -a
or --annotation
option.
Transform resource masks to GeoJSON:
allmaps transform resource-mask [files...]
All the commands above accept the following options:
Option | Description | Default |
---|
-p, --max-offset-ratio <number> | Maximum offset ratio between original and transformed midpoints | 0 |
-d, --max-depth <number> | Maximum recursion depth | 6 |
Parse and generate IIIF resources
Show help:
allmaps iiif --help
Parse IIIF resources and output them in the format used internally by Allmaps:
allmaps iiif parse [files...]
Generate IIIF Manifest from IIIF Image Services from one or more IIIF resources:
allmaps manifest -d <id> [files...]
The ID of the IIIF Manifest can be supplied with the -i
or --id
option.
Examples
Turn masks of georeferenced maps into GeoJSON
Manifest URL:
Use Allmaps API to find Georeference Annotations:
Fetch a Georeference Annotation with cURL, pipe to Allmaps CLI and transform resource mask to GeoJSON:
curl -L "https://annotations.allmaps.org/?url=https://collections.leventhalmap.org/search/commonwealth:4t64k3596/manifest" \
| allmaps transform resource-mask
You can pipe as multiple Georeference Annotations to Allmaps CLI:
Manifest URLs:
Georef Annotations:
Concatenate these two Georeference Annotations with Bash and transform resource masks to GeoJSON:
cat \
<(curl -L "https://annotations.allmaps.org/?url=https://collections.leventhalmap.org/search/commonwealth:4t64k3596/manifest") \
<(curl -L "https://annotations.allmaps.org/?url=https://collections.leventhalmap.org/search/commonwealth:6108xt43s/manifest") \
| allmaps transform resource-mask
Combine multiple Georeference Annotations
Allmaps CLI can combine multiple Georeference Annotations and output them as a single AnnotationPage:
cat \
<(curl https://annotations.allmaps.org/manifests/f2aa771c7d0ae1e8) \
<(curl https://annotations.allmaps.org/images/813b0579711371e2) \
| allmaps annotation generate
If you have a directory containing multiple Georeference Annotations, you can run:
cat *.json | allmaps annotation generate
If you're running MacOS, you can use pbcopy to copy the generated Georeference Annotation to your clipboard:
cat *.json | allmaps annotation generate | pbcopy