dougmccune / shp2stl Goto Github PK
View Code? Open in Web Editor NEWUtility for converting a shapefile to a 3D model.
License: MIT License
Utility for converting a shapefile to a 3D model.
License: MIT License
I heard about this node package from your excellent blog post. I haven't, however, been able to replicate your approach with my own shapefile. My code and shapefile is over at:
https://github.com/amoeba/3dmaps
The output I get it this:
$ node convert.js
bounds: Infinity Infinity -Infinity -Infinity (spherical)
pre-quantization: 111.195km (1.00°) 111.195km (1.00°)
topology: 0 arcs, 0 points
topojson done
simplification: effective minimum area 0.00
simplification: retained 0 / 0 points (NaN%)
making top planes
making side planes
making bottom planes
done making 3D planes
And the resulting STL file only contains:
solid
endsolid
Is it because of my strange projection? Something else? I've poked around your source to the best of my ability but I can't seem to figure out where I'm messing up.
Hi @dougmccune
Thanks for the great library. I was wondering about submitting a pull request with some additional functionality so I thought I'd get some feedback.
I have a buildings dataset which contains
Using shp2stl currently I can use the attribute for the height using the extrudeBy
option which works great. However there is nothing that allows me to utilise the z value for ground elevation. So I was wondering if we could introduce a new option called getBaseHeightFromZ
. The other option might be to only support a single base height per building which could be derived from an attributed similar to how extrudeBy
works.
I've looked upstream and there are a few tweaks that would be required in the shapefile
library to support getting z vales into geojson. The topojson
conversion part works ok in retaining z values.
Are that any pitfalls that you could see in such an approach? I'm happy to submit a pull request if you're interested.
Regards,
Rowan
Hello, I am trying to use your library on this dataset. I have the following script:
var fs = require('fs');
var shp2stl = require('shp2stl');
var file = '3D_domy.shp';
shp2stl.shp2stl(file,
{
width: 100,
height: 10,
extraBaseHeight: 0,
extrudeBy: "REL_H",
simplification: .8,
binary: true,
cutoutHoles: false,
verbose: true,
extrusionMode: 'straight'
},
function(err, stl) {
fs.writeFileSync('brno.stl', stl);
}
);
However, it fails with the output:
bounds: -610515.495 -1169601.422 -588998.562 -1150146.302 (cartesian)
pre-quantization: 0.00021516933215169295 0.00019455120194551316
topology: 1704953 arcs, 3409907 points
topojson done
simplification: effective minimum area 0.00194
simplification: retained 3409907 / 3409907 points (100%)
making top planes
Duplicate point 75.87834675878348:45.606545977206764
Duplicate point 47.88109447881095:67.99900334326045
Duplicate point 47.72163847721639:68.22115425580363
Duplicate point 47.57133847571339:68.3893004726506
making side planes
making bottom planes
<pwdpath>/node_modules/three/three.js:32605
for ( i = 0, il = triangles.length; i < il; i ++ ) {
^
TypeError: Cannot read property 'length' of null
at Object.triangulateShape (<pwdpath>/node_modules/three/three.js:32605:31)
at THREE.ShapeGeometry.addShape (<pwdpath>/node_modules/three/three.js:35513:32)
at THREE.ShapeGeometry.addShapeList (<pwdpath>/node_modules/three/three.js:35458:8)
at new THREE.ShapeGeometry (<pwdpath>/node_modules/three/three.js:35442:7)
at THREE.Shape.makeGeometry (<pwdpath>/node_modules/three/three.js:32162:17)
at <pwdpath>/node_modules/shp2stl/src/topojson2threejs.js:377:33
at Array.forEach (<anonymous>)
at topojson2threeJSBottomPlanes (<pwdpath>/node_modules/shp2stl/src/topojson2threejs.js:374:13)
at topojson2threejs (<pwdpath>/node_modules/shp2stl/src/topojson2threejs.js:76:16)
at topojson2stl (<pwdpath>/node_modules/shp2stl/src/shp2stl.js:77:21)
What could be the reason for that?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.