https://github.com/perliedman/geojson2obj
Convert GeoJSON into Wavefront OBJ format
https://github.com/perliedman/geojson2obj
Last synced: over 1 year ago
JSON representation
Convert GeoJSON into Wavefront OBJ format
- Host: GitHub
- URL: https://github.com/perliedman/geojson2obj
- Owner: perliedman
- License: isc
- Created: 2015-09-27T14:10:17.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2021-06-11T11:42:13.000Z (about 5 years ago)
- Last Synced: 2025-03-27T13:46:22.350Z (over 1 year ago)
- Language: JavaScript
- Size: 24.4 KB
- Stars: 19
- Watchers: 2
- Forks: 8
- Open Issues: 9
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
GeoJSON to OBJ
==============
A converter from [GeoJSON](http://geojson.org) to
[Wavefront OBJ](https://en.wikipedia.org/wiki/Wavefront_.obj_file) format.
## Unmaintained
This project has been archived and is not maintained, since it's been a long time since I had reason to work on it.

## Trying it out
There's a small command line example in the `examples` directory, which you can use to try out the library.
Sample command line:
```
cd examples
./cli.js norway-coastline.geo.json
```
It should write an OBJ file to your stdout.
## API
### toObj(geojson, stream, callback, options)
Converts the `geojson` to an OBJ, that is written to the `stream`.
When done, the callback is called; `callback` is a normal Node.js callback
accepting an error as the first argument.
Note that the `geojson` must be a `Feature` or `FeatureCollection`.
Available options:
* `featureBase`: function `f(feature, callback)` that returns the height of
a feature's base; by default, a function that always returns 0.
* `featureHeight`: function `f(feature, callback)` that returns the height of
a feature; by default, a function that returns 10 for polygons and
0.3 for linestrings.
* `lineWidth`: for line geometries, returns the width of the generated
geometry; defaults to 2.
* `featureName`: a function `f(feature, callback)` that returns the OBJ group
name used for a feature; by default a function that numbers the
features
* `featureMaterial`: a function `f(feature, callback)` that returns the name
of the material for a feature; if undefined, the material is
not changed for this feature; see `mtllib` option below
* `coordToPoint` a function `f(coordinate)` that returns the
OBJ vertex point (X and Z) for a GeoJSON coordinate, needed to
convert from GeoJSON's WGS84 coordinates to a cartesian coordinate;
see the `findLocalProj` method below
* `mtllib` a string or array of paths that will be added as material
libraries to the resulting OBJ