All Projects → placemark → togeojson

placemark / togeojson

Licence: BSD-2-Clause license
convert KML, TCX, and GPX to GeoJSON, without the fuss

Projects that are alternatives of or similar to togeojson

GeoConvert
Converting between Geojson and GIS file formats
Stars: ✭ 32 (-89.84%)
Mutual labels:  gpx, geojson, kml
GpsPrune
GpsPrune is a map-based application for viewing, editing and converting coordinate data from GPS systems.
Stars: ✭ 46 (-85.4%)
Mutual labels:  gpx, geojson
Android Maps Utils
Maps SDK for Android Utility Library
Stars: ✭ 3,330 (+957.14%)
Mutual labels:  geojson, kml
garmin-connect-export
Downloads gpx, tcx or original fit files from your Garmin Connect Account.
Stars: ✭ 42 (-86.67%)
Mutual labels:  gpx, tcx
LocationMapViewer
Android App to view Locations in a map with support for gpx, kml and kmz data
Stars: ✭ 31 (-90.16%)
Mutual labels:  gpx, kml
pentaho-gis-plugins
🗺 GIS plugins for Pentaho Data Integration
Stars: ✭ 42 (-86.67%)
Mutual labels:  gpx, geojson
geojsoncontour
Convert matplotlib contour plots to geojson
Stars: ✭ 78 (-75.24%)
Mutual labels:  geojson
Excel-Timesheet
⏰ This Add-In is used to produce a timesheet file with functionality to import your Google Timeline. The standard timesheet has options for start and end dates, day of week and default start, end and break times. The Google timeline options are start and end dates, UTC selection, daylight savings time parameters and title filter for timeline ent…
Stars: ✭ 25 (-92.06%)
Mutual labels:  kml
echarty
Minimal R/Shiny Interface to ECharts.js
Stars: ✭ 49 (-84.44%)
Mutual labels:  geojson
GPXParser.js
GPX file parser javascript library
Stars: ✭ 58 (-81.59%)
Mutual labels:  gpx
gc-gpx-viewer
Geocaching GPX Viewer is a web app to display caches from a gpx file on a map.
Stars: ✭ 24 (-92.38%)
Mutual labels:  gpx
rain-geojson-sg
Straight-forward API server to convert rain area radar images (Singapore) to GeoJSON
Stars: ✭ 15 (-95.24%)
Mutual labels:  geojson
gjf
A tool in Python to fix invalid GeoJSON objects and files
Stars: ✭ 94 (-70.16%)
Mutual labels:  geojson
mapollage
Mapollage is a photo kml generator for Google Earth
Stars: ✭ 15 (-95.24%)
Mutual labels:  kml
contour-rs
Contour polygon creation in Rust (using marching squares algorithm)
Stars: ✭ 33 (-89.52%)
Mutual labels:  geojson
strava-uploader
utility to migrate Runkeeper data (GPX and CSV) to Strava
Stars: ✭ 72 (-77.14%)
Mutual labels:  gpx
winnow
Deprecated
Stars: ✭ 89 (-71.75%)
Mutual labels:  geojson
Strava-local-heatmap
Python script to generate a high resolution heatmap from Strava GPX files
Stars: ✭ 102 (-67.62%)
Mutual labels:  gpx
wp-plugin-trackserver
A WordPress plugin for GPS tracking and publishing
Stars: ✭ 34 (-89.21%)
Mutual labels:  gpx
krawler
A minimalist (geospatial) ETL
Stars: ✭ 51 (-83.81%)
Mutual labels:  geojson

Convert KML, GPX, and TCX to GeoJSON.

togeojson development is supported by 🌎 placemark.io

This converts KML, TCX, & GPX to GeoJSON, in a browser or with Node.js.

  • Dependency-free
  • Tiny
  • Tested
  • Node.js + Browsers

📕 API Documentation

This is a JavaScript library that lets projects convert KML and GPX to GeoJSON. If you're looking for a command line too, use @tmcw/togeojson-cli. If you want to convert one KML or GPX file, use my online tool. If you want to convert another format, consider GDAL.

Property conversions

In addition to converting KML’s <ExtendedData> verbatim, @tmcw/togeojson also encodes parts of KML, GPX, and TCX files that otherwise would be lost.

KML

  • Style properties: fill-color, fill-opacity, stroke, stroke-opacity, icon-color, icon-opacity, label-color, label-opacity, icon-scale, icon-heading, icon-offset, icon-offset-units

GPX

  • Style properties: stroke, stroke-opacity, stroke-width

TCX

  • Line properties: totalTimeSeconds, distanceMeters, maxSpeed, avgHeartRate, maxHeartRate, avgSpeed, avgWatts, maxWatts

This also emits the geojson-coordinate-properties format to include time and other attributes that apply to each coordinate of a LineString.

Ground overlays

Example of working with Ground Overlays in Mapbox GL JS

KML GroundOverlays are now supported, and transformed into Features with Polygon geometries. They have two defined properties:

{
  "@geometry-type": "groundoverlay",
  "icon": "https://url.to.image…"
}

Both gx:LatLonQuad and LatLonBox-based ground overlays are supported.

CLI

Use @tmcw/togeojson-cli to use this software as a command-line tool.

Node.js

Install it into your project with npm install --save @tmcw/togeojson.

// using togeojson in nodejs

const tj = require("@tmcw/togeojson");
const fs = require("fs");
// node doesn't have xml parsing or a dom. use xmldom
const DOMParser = require("xmldom").DOMParser;

const kml = new DOMParser().parseFromString(fs.readFileSync("foo.kml", "utf8"));

const converted = tj.kml(kml);

ES Modules

// The ES Module provides named exports, to import kml, gpx,
// and other parts of the module by name.
import { kml } from "@tmcw/togeojson";

Browser

<script type="module">
  import { kml } from "https://unpkg.com/@tmcw/togeojson?module";

  fetch("test/data/linestring.kml")
    .then(function (response) {
      return response.text();
    })
    .then(function (xml) {
      console.log(kml(new DOMParser().parseFromString(xml, "text/xml")));
    });
</script>

KML Feature Support

  • Point
  • Polygon
  • LineString
  • name & description
  • ExtendedData
  • SimpleData
  • MultiGeometry -> GeometryCollection
  • Styles
  • Tracks & MultiTracks with gx:coords, including altitude
  • TimeSpan
  • TimeStamp
  • Folders (with kmlWithFolders)
  • GroundOverlays
  • NetworkLinks

GPX Feature Support

  • Line Paths
  • Line styles
  • Properties
    • 'name', 'cmt', 'desc', 'link', 'time', 'keywords', 'sym', 'type' tags
    • gpxx Garmin extensions on tracks and routes
    • 'author', 'copyright' tags

FAQ

How does this differ from mapbox/togeojson?

  • This repository is maintained.
  • It’s available as an ES Module. If you're using a modern JavaScript bundler or using ES Modules in the browser, this makes it a bit more efficient and sometimes easier to use.
  • Conversion methods are available as generators, which makes the conversion of big files more efficient.
  • The command line utility was moved to tmcw/togeojson-cli, which lets this module enjoy reduced dependencies: installing @tmcw/togeojson doesn’t require any other dependencies.

Why doesn't toGeoJSON support NetworkLinks?

The NetworkLink KML construct allows KML files to refer to other online or local KML files for their content. It's often used to let people pass around files but keep the actual content on servers.

In order to support NetworkLinks, toGeoJSON would need to be asynchronous and perform network requests. These changes would make it more complex and less reliable in order to hit a limited usecase - we'd rather keep it simple and not require users to think about network connectivity and bandwith in order to convert files.

NetworkLink support could be implemented in a separate library as a pre-processing step if desired.

Should toGeoJSON support feature X from KML?

This module should support converting all KML and GPX features that have commonplace equivalents in GeoJSON.

Protips:

Have a string of XML and need an XML DOM? There are two main options:

  • Use xmldom, a JavaScript module that contains its own XML parser
  • Use DOMParser, the native platform XML parser

We recommend that you use xmldom, not the platform. DOMParser requires XML to be valid, which means that any XML namespaces that a KML, GPX, or TCX file contains are valid. A lot of existing data is invalid XML, and will be parsed only in part by DOMParser, but can be fully parsed by xmldom.

Using xmldom (recommended):

const xmldom = require("@xmldom/xmldom");
const dom = new xmldom.DOMParser().parseFromString(xmlStr, "text/xml");

Using DOMParser:

var dom = new DOMParser().parseFromString(xmlStr, "text/xml");

Maintainability Test Coverage

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].