Code Monkey home page Code Monkey logo

shapefile-simplify's Introduction

shapefile-simplify

Simplify shapefiles programmatically for mapbox Tileset/DataSource uploads using mapshaper.

Weighted Visvalingam simplification is used by default.

Prerequisites

The following dependencies are used for this project. Feel free to use other dependency versions as needed.

  1. Windows 10 OS
  2. NVM for Windows
    • v1.1.9
  3. NodeJS
    • node version 10.16.3
    • npm v6.9.0
    • (installed via nvm)

Core Libraries and Frameworks

(See package.json for more information.)

  1. mapshaper v0.5.28

Installation

  1. Clone this repository.
    git clone https://github.com/ciatph/shapefile-simplify.git

  2. Install dependencies.
    npm install

  3. Create a .env file from the .env.example file. Update its defined variables in accordance with your personnal mapshaper cli command reference settings.

    Variable Name Description
    PERCENTAGE Percentage of removable points to retain on the shapefile.
    INPUT_FORMAT input file format (i.e., .shp for shapefile, .geojson for GeoJSON)
    OUTPUT_FORMAT file format of the simplified (i.e., shapefile for Shapefiles and geojson for GeoJSON)
    • The example .env file below will create a simplified GeoJSON file (small file size) from a (hi-resolution, big file size) shapefile:
      PERCENTAGE=1.5%
      INPUT_FORMAT=shp
      OUTPUT_FORMAT=geojson
      
    • The example .env file below will create a simplified shapefile from a (hi-resolution, big file size) shapefile:
      PERCENTAGE=4.0%
      INPUT_FORMAT=shp
      OUTPUT_FORMAT=shapefile
      

Usage

  1. Create an INPUT directory named "shapefiles" inside the project's root directory. Put all shapefile-related input (.shp, .cpg, .dbf, .pfj and .shx) inside it.
  2. Create an OUTPUT directory named "formatted" inside the project's root directory.
  3. Run the npm script.
    npm start
  4. Wait for the simplification process to finish. Simplified files will be generated in the /formatted directory.

@ciatph
20200120

shapefile-simplify's People

Contributors

ciatph avatar

Stargazers

 avatar

Watchers

 avatar

shapefile-simplify's Issues

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.