Giter Club home page Giter Club logo

map-image-preview's Introduction

Features

Reads vector format map polygons and renders into to a bitmap file

  • Automatically detect minimal bounding box
    • Adjustable margin as a percentage
  • Selectable colors
  • Selectable outline stroke

Usage

map-image-preview v1.6.4

Usage: node map-image-preview <options> [mapfile]

mapfile    GeoJSON map source file for the preview

Options:
   -W  --width [0..]         Set the output image width in pixels
   -S  --strokeWidth [0.0..] Set the outline line width in pixels
   -SC --strokeColor #222    Set the outline color (hex code)
   -C  --color #f84          Set the fill color (hex code)
   -B  --bboxscale [0.0..]   Set the bounding box scaling factor, 1.1 = 10% margin
   -M  --meta [file.json]    Optional file containing map layer colors
   -CP --colorProperty [key] GeoJSON property to use for color lookup.  Metadata must have keys with same name.
   -O  --output [file]       Filename of output files, file extension will be added.
   -X  --maxbounds {left:1,bottom:2,right:3,top:4}  The maximum bounds for limiting image extents.

Example

node map-image-preview.js --width 600 --strokeColor "rgba(0,0,255,0.7)" \
  --fillColor "#ff6" --strokeWidth 0.5 example/world.geojson

Sample

Arguments

Color property

node map-image-preview.js --width 600 --colorProperty admin \
  --meta example/world.json example/world.geojson

Scale 0.8

Scale factor

The default scale factor of 1 will fit the map data precisely inside the target raster.

Scale factor 80%

npx map-image-preview --bboxscale 0.8 --width 300 example/world.geojson

Scale 0.8

Scale factor 120%

npx map-image-preview --bboxscale 1.2 --width 300 example/world.geojson

Scale 1.2

Metafile

Optionally a metadata json file can be used to specify colors to be used in the map. To use this the GeoJSON currently must have a property named "kode", matching with the "kode" value set in the accompanying meta.json file.

npx map-image-preview --meta meta.json example/world.geojson

Format

{
  "barn": [
    { "kode": "water", "farge": "#00f" },
    { "kode": "land", "farge": "#0f0" }
  ]
}

Composing background map

The app wms-save-image may be used to download background maps from any WMS server for use in combination with images from this program. It will read the generated JSON file.

Compose single image

Using convert program from Imagemagick to composite the images. To install Imagemagick:

sudo apt install imagemagick

To compose images:

convert thumbnail_back.png thumbnail.32633.png -compose Multiply -composite thumbnail.png

Composed example

Compose images recursively

find . -type d -exec sh -c "cd \"{}\" && pwd && \
  [ -f thumbnail.json ] && \
  convert thumbnail_back.png thumbnail.32633.png -compose Multiply -composite thumbnail.png" \;

map-image-preview's People

Contributors

bjornreppen avatar dependabot[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

bjornreppen

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.