I'm trying to convert a .shp
to .stl
in order to 3D-print the later as a model.
I am following guides described in "Shapefiles" and "Using shp2stl to Convert Maps to 3D Models".
Unfortunately shp2stl
, the tool described in both articles, doesn't work for me – I am trying to run an example from shp2stl
repository, but get an error during the process:
$ node index.js
bounds: 5979385.645656869 2085840.5000395626 6024741.001443654 2131293.9999859035 (cartesian)
pre-quantization: 0.00045355356240339045 0.0004545350040087592
topology: 1698 arcs, 37009 points
topojson done
simplification: effective minimum area 0.00000299
simplification: retained 29608 / 37009 points (80%)
making top planes
making side planes
making bottom planes
/Users/eugene/oss/shp2stl/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 (/Users/eugene/oss/shp2stl/node_modules/three/three.js:32605:30)
at THREE.ShapeGeometry.addShape (/Users/eugene/oss/shp2stl/node_modules/three/three.js:35513:32)
at THREE.ShapeGeometry.addShapeList (/Users/eugene/oss/shp2stl/node_modules/three/three.js:35458:8)
at THREE.ShapeGeometry (/Users/eugene/oss/shp2stl/node_modules/three/three.js:35442:7)
at THREE.Shape.makeGeometry (/Users/eugene/oss/shp2stl/node_modules/three/three.js:32162:17)
at /Users/eugene/oss/shp2stl/src/topojson2threejs.js:396:24
at Array.forEach (native)
at topojson2threeJSBottomPlanes (/Users/eugene/oss/shp2stl/src/topojson2threejs.js:392:20)
at topojson2threejs (/Users/eugene/oss/shp2stl/src/topojson2threejs.js:76:16)
at topojson2stl (/Users/eugene/oss/shp2stl/src/shp2stl.js:77:21)
What I might be missing? Is there a better way to get 3D-printable file out of .shp
?
I've prepared a docker image which help to replicate the issue. Steps to reproduce my issue:
pull the image:
docker pull gmile/shp2stl-fiasco
start bash inside the image:
docker exec -it gmile/shp2stl-fiasco bash
go into examples directory and try to run the script:
$ cd /shp2stl/examples/sfPopulationDensity/
run the script & see the issue:
$ node index.js
Alternatively, I've prepared a Dockerfile that can be used to build an image to reproduce the issue with minimal effort:
FROM ubuntu:18.04
RUN apt update; \
apt install git curl ca-certificates -y --no-install-recommends; \
git clone https://github.com/dougmccune/shp2stl.git
RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.1/install.sh | bash
WORKDIR /shp2stl/examples/sfPopulationDensity
# After building and entering a container, manually run the following:
#
# nvm install v6.17.1
# npm i
# node index.js