Skip to content

converts multiple formats (SHP, KML, GeoJSON) to TopoJSON

Notifications You must be signed in to change notification settings

Georeactor/to-topojson

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

to-topojson

Most geo converters stop at GeoJSON, so you need to multiple codes together to convert to TopoJSON. This eliminates the extra step.

Helps with:

  • Detecting file formats
  • Best TopoJSON settings (including: keeping GeoJSON properties)
  • Adding labels (using MapBox Turf.js)

Supports:

  • GeoJSON using Mike Bostock's topojson module
  • KML and GPX using MapBox's togeojson module
  • Shapefiles using Calvin Metcalf's shpjs module

Functions

// detect file format and output TopoJSON
convertFile(input_file, tj_file, function (err) {
}, optional_logger);

// optional_logger can be console.log or another function for updates

// set format and output TopoJSON
convertFileWithFormat(input_file, 'GeoJSON', tj_file, function (err) {
}, optional_logger);
// acceptable strings: GeoJSON, SHP, KML, GPX (default is GeoJSON)

convertObject(geojson_object, function (err, topojson_object) {
  // returns error or TopoJSON object
}, optional_logger);

labelGeoJSON(geojson_object_or_filename, label_filename, function (err) {
  // returns error or null
});

License

MIT License

About

converts multiple formats (SHP, KML, GeoJSON) to TopoJSON

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published