{"id":2061,"date":"2014-12-30T08:30:40","date_gmt":"2014-12-30T16:30:40","guid":{"rendered":"http:\/\/dougmccune.com\/blog\/?p=2061"},"modified":"2017-01-03T16:05:00","modified_gmt":"2017-01-04T00:05:00","slug":"using-shp2stl-to-convert-maps-to-3d-models","status":"publish","type":"post","link":"https:\/\/dougmccune.com\/blog\/2014\/12\/30\/using-shp2stl-to-convert-maps-to-3d-models\/","title":{"rendered":"Using shp2stl to Convert Maps to 3D Models"},"content":{"rendered":"<p>I&#8217;ve been working on a utility called <a href=\"https:\/\/github.com\/dougmccune\/shp2stl\">shp2stl<\/a> that converts geographic data in shapefiles to 3D models, suitable for 3D printing. The code is published as a NodeJS package, available on <a href=\"https:\/\/www.npmjs.org\/package\/shp2stl\">npm<\/a> and <a href=\"https:\/\/github.com\/dougmccune\/shp2stl\">GitHub<\/a>. <\/p>\n<p>You can control the height of each shape by specifying an attribute of your data to use. Each shape will be placed along the z-axis based on the shape&#8217;s value relative to the max range in the data. Additionally, if you want more detailed control you can specify a function to use to extrude each shape.<\/p>\n<h1>Examples<\/h1>\n<h2>South Napa Earthquake<\/h2>\n<p>Here&#8217;s an example using the recent South Napa earthquake, first as the source shapefile:<\/p>\n<div class=\"overlay\" onClick=\"style.pointerEvents='none'\" style=\"background:transparent; position:relative; width:696px; height:420px; top:420px; margin-top:-420px;\"><\/div>\n<p><script src=\"https:\/\/embed.github.com\/view\/geojson\/dougmccune\/3dmaps\/master\/napa2014Epicenter\/pgv.topojson?width=696\"><\/script><\/p>\n<p>Then converted to a 3D model using shp2stl:<\/p>\n<div class=\"overlay\" onClick=\"style.pointerEvents='none'\" style=\"background:transparent; position:relative; width:696px; height:420px; top:420px; margin-top:-420px;\"><\/div>\n<p><script src=\"https:\/\/embed.github.com\/view\/3d\/dougmccune\/3dmaps\/master\/napa2014Epicenter\/pgv.stl?width=696\"><\/script><\/p>\n<p>And finally printed with a 3D printer:<\/p>\n<p><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/dougmccune.com\/blog\/wp-content\/uploads\/2014\/12\/epicenter_angled-696x420.jpg?resize=696%2C420&#038;ssl=1\" alt=\"epicenter_angled-696x420\" width=\"696\" height=\"420\" class=\"alignnone size-full wp-image-2161\" srcset=\"https:\/\/i0.wp.com\/dougmccune.com\/blog\/wp-content\/uploads\/2014\/12\/epicenter_angled-696x420.jpg?resize=696%2C420&amp;ssl=1 696w, https:\/\/i0.wp.com\/dougmccune.com\/blog\/wp-content\/uploads\/2014\/12\/epicenter_angled-696x420.jpg?resize=300%2C181&amp;ssl=1 300w\" sizes=\"auto, (max-width: 696px) 100vw, 696px\" \/><\/p>\n<p><!--more--><\/p>\n<p>All the files and source code for generating the model above are <a href=\"https:\/\/github.com\/dougmccune\/3dmaps\/tree\/master\/napa2014Epicenter\">available on github<\/a>. See more about my <a href=\"https:\/\/dougmccune.com\/blog\/2014\/09\/09\/2014-south-napa-earthquake-3d-print\/\">3D print of the 2014 Napa earthquake<\/a>.<\/p>\n<h2>San Francisco Population<\/h2>\n<p>The map below shows the population of San Francisco broken down by census tract.<\/p>\n<div class=\"overlay\" onClick=\"style.pointerEvents='none'\" style=\"background:transparent; position:relative; width:696px; height:420px; top:420px; margin-top:-420px;\"><\/div>\n<p><script src=\"https:\/\/embed.github.com\/view\/geojson\/dougmccune\/3dmaps\/master\/sfPopulation\/SanFranciscoPopulation.topojson?width=696\"><\/script><\/p>\n<p>And the same data converted to a 3D model:<\/p>\n<div class=\"overlay\" onClick=\"style.pointerEvents='none'\" style=\"background:transparent; position:relative; width:696px; height:420px; top:420px; margin-top:-420px;\"><\/div>\n<p><script src=\"https:\/\/embed.github.com\/view\/3d\/dougmccune\/3dmaps\/master\/sfPopulation\/SanFranciscoPopulation.stl?width=696\"><\/script><\/p>\n<p>All the files and source code for generating the model above are <a href=\"https:\/\/github.com\/dougmccune\/3dmaps\/tree\/master\/sfPopulation\">available on github<\/a>.<\/p>\n<h1>How to use it<\/h1>\n<p>shp2stl is a NodeJS package you can install via npm. You can install it like any npm package by doing<\/p>\n<p>[js]npm install shp2stl[\/js]<\/p>\n<p>If you&#8217;re new to NodeJS then you&#8217;ll also have to <a href=\"http:\/\/nodejs.org\/\">download Node<\/a> (which comes bundled with npm). shp2stl is not a standalone program that you run, you have to use it in your own NodeJS code.<\/p>\n<p>The easiest way to understand how to use the package is via an example:<\/p>\n<p>[js]<br \/>\nvar fs = require(&#8216;fs&#8217;);<br \/>\nvar shp2stl = require(&#8216;shp2stl&#8217;);<\/p>\n<p>var file = &#8216;SanFranciscoPopulation.shp&#8217;;<\/p>\n<p>shp2stl.shp2stl(file,<br \/>\n    {<br \/>\n        width: 100, \/\/in STL arbitrary units, but typically 3D printers use mm<br \/>\n        height: 10,<br \/>\n        extraBaseHeight: 0,<br \/>\n        extrudeBy: &#8220;Pop_psmi&#8221;,<br \/>\n        simplification: .8,<\/p>\n<p>        binary: true,<br \/>\n        cutoutHoles: false,<br \/>\n        verbose: true,<br \/>\n        extrusionMode: &#8216;straight&#8217;<br \/>\n    },<br \/>\n    function(err, stl) {<br \/>\n        fs.writeFileSync(&#8216;SanFranciscoPopulation.stl&#8217;,  stl);<br \/>\n    }<br \/>\n);<br \/>\n[\/js]<\/p>\n<p>That will produce an STL model with each polygon sized by the <code>Pop_psmi<\/code> attribute. You should customize the example above to point to your own shapefile and specify a valid attribute within that shapefile to use for the height.<\/p>\n<p>More detailed documentation covering all the available options is in the <a href=\"https:\/\/github.com\/dougmccune\/shp2stl\">shp2stl README<\/a>.<\/p>\n<h1>How it works<\/h1>\n<p>The TLDR version: <strong>convert from shapefile to geojson, then to topojson, then to a threeJS model, then to STL<\/strong>. <\/p>\n<p>shp2stl takes advantage of the rich NodeJS ecosystem and uses a number of third party packages available on npm. The key packages that are used are <a href=\"https:\/\/www.npmjs.org\/package\/shapefile\">shapefile<\/a>, <a href=\"https:\/\/www.npmjs.org\/package\/topojson\">topojson<\/a>, and <a href=\"https:\/\/www.npmjs.org\/package\/three\">three<\/a> (in addition <a href=\"https:\/\/www.npmjs.org\/package\/deepcopy\">deepcopy<\/a>, <a href=\"https:\/\/www.npmjs.org\/package\/point-in-polygon\">point-in-polygon<\/a>, and <a href=\"https:\/\/www.npmjs.org\/package\/ogr2ogr\">ogr2ogr<\/a> are used).<\/p>\n<p>A brief word on manifold meshes: it&#8217;s especially important for 3D printing that all your 3D meshes are &#8220;manifold&#8221;. You can think about that in terms of producing a clean water-tight model that&#8217;s perfectly hollow on the inside. Here are some <a href=\"http:\/\/www.shapeways.com\/tutorials\/fixing-non-manifold-models\">good examples of non-manifold problematic meshes<\/a>. This becomes very important when we figure out how to covert the polygons in our shapefile to a 3D model.<\/p>\n<h2>Step 1: Convert to GeoJSON<\/h2>\n<p>The shapefile is first read with Mike Bostock&#8217;s <a href=\"https:\/\/www.npmjs.org\/package\/shapefile\">shapefile<\/a> package, which converts the geo data into GeoJSON. This will be converted in the shapefile&#8217;s source projection, but if you want to reproject the data before converting it you can using the sourceSRS and destSRS options, which uses the <a href=\"https:\/\/www.npmjs.org\/package\/ogr2ogr\">ogr2ogr<\/a> package to do the projection (this requires ogr2ogr already installed separately).<\/p>\n<h2>Step 2: Convert GeoJSON to TopoJSON<\/h2>\n<p>One of the key issues we encounter when trying to convert polygons to a 3D model has to do with shapes that share borders. Shapefiles (and GeoJSON) represent bordering shapes entirely independently. That means that two shapes that share a border have two distinct sets of line segments that define that border. You can certainly attempt to create a simple 3D model by treating each polygon separately like this, which will produce distinct 3D meshes for each poly. That&#8217;s likely fine for 3D rendering on a computer, but it&#8217;s not ideal for 3D printing. We need a single manifold mesh, not a bunch of distinct ones that are all touching each other. What we&#8217;re hoping to create is the full combined outer shell.<\/p>\n<p><strong>The key to converting to a single unified mesh is to convert the GeoJSON to <a href=\"https:\/\/github.com\/mbostock\/topojson\/wiki\">TopoJSON<\/a>.<\/strong> Mike Bostock&#8217;s TopoJSON format encodes topology, which means that it figures out all the <strong>unique<\/strong> line segments that make up the polys. If two shapes share a border that border only gets converted to a single line segment instead of two, and both shapes reference the same segment. This allows you to reconstruct each poly, but it also tells you an important piece of information: which line segments are shared between which polygons. That&#8217;s the key to creating a nice single outer shell for our polygon.<\/p>\n<h2>Step 3: Convert to ThreeJS<\/h2>\n<p><a href=\"http:\/\/threejs.org\/\">ThreeJS<\/a> is a full-featured 3D library for JavaScript. It can do a ton of stuff, but for my purposes I&#8217;m only really interested in a couple things: triangulating polygons (to convert the polys), creating simple faces (to make the sides of the model), and easily iterating over all triangles in a model (to convert to an STL file).<\/p>\n<p>shp2stl will create ThreeJS planes for each polygon in your shapefile, and extrude each based on an attribute you specify. The built-in triangulation method of ThreeJS is used to convert the shape polygons into triangle faces. <\/p>\n<p>The distinct planes are then connected by creating connecting faces along the z-axis. Since the TopoJSON format tells us which polygons share which borders, we&#8217;re able to connect the faces that touch by manually creating sides that start at the edge of the lower face and extend up to the height of the upper face.<\/p>\n<p><img data-recalc-dims=\"1\" height=\"412\" width=\"696\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/dougmccune.com\/blog\/wp-content\/uploads\/2014\/09\/model_4.png?resize=696%2C412&#038;ssl=1\" alt=\"\" \/><\/p>\n<h2>Step 4: Print!<\/h2>\n<p>You should now have a nice manifold mesh ready to be sent to your 3D printer of choice. I&#8217;ve had a lot of success printed the models created by shp2stl with the Afinia Series H.<\/p>\n<p><img data-recalc-dims=\"1\" height=\"463\" width=\"696\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/dougmccune.com\/blog\/wp-content\/uploads\/2014\/09\/all_tiles_angled1.jpg?resize=696%2C463&#038;ssl=1\" \/><\/p>\n<p>Grab <a href=\"https:\/\/github.com\/dougmccune\/shp2stl\">shp2stl on github<\/a> or from <a href=\"https:\/\/www.npmjs.com\/package\/shp2stl\">npm<\/a> and I&#8217;d love to hear about things you&#8217;ve printed.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;ve been working on a utility called shp2stl that converts geographic data in shapefiles to 3D models, suitable for 3D printing. The code is published as a NodeJS package, available on npm and GitHub. You can control the height of each shape by specifying an attribute of your data to use. Each shape will be [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":2040,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_post_was_ever_published":false},"categories":[94,34],"tags":[],"class_list":["post-2061","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-code-2","category-maps"],"aioseo_notices":[],"aioseo_head":"\n\t\t<!-- All in One SEO 4.9.8 - aioseo.com -->\n\t<meta name=\"description\" content=\"I&#039;ve been working on a utility called shp2stl that converts geographic data in shapefiles to 3D models, suitable for 3D printing. The code is published as a NodeJS package, available on npm and GitHub. You can control the height of each shape by specifying an attribute of your data to use. Each shape will be\" \/>\n\t<meta name=\"robots\" content=\"max-image-preview:large\" \/>\n\t<meta name=\"author\" content=\"Doug\"\/>\n\t<meta name=\"keywords\" content=\"code,maps\" \/>\n\t<link rel=\"canonical\" href=\"https:\/\/dougmccune.com\/blog\/2014\/12\/30\/using-shp2stl-to-convert-maps-to-3d-models\/\" \/>\n\t<meta name=\"generator\" content=\"All in One SEO (AIOSEO) 4.9.8\" \/>\n\t\t<meta property=\"og:locale\" content=\"en_US\" \/>\n\t\t<meta property=\"og:site_name\" content=\"Doug McCune | Sculptor\" \/>\n\t\t<meta property=\"og:type\" content=\"article\" \/>\n\t\t<meta property=\"og:title\" content=\"Using shp2stl to Convert Maps to 3D Models | Doug McCune\" \/>\n\t\t<meta property=\"og:description\" content=\"I&#039;ve been working on a utility called shp2stl that converts geographic data in shapefiles to 3D models, suitable for 3D printing. The code is published as a NodeJS package, available on npm and GitHub. You can control the height of each shape by specifying an attribute of your data to use. Each shape will be\" \/>\n\t\t<meta property=\"og:url\" content=\"https:\/\/dougmccune.com\/blog\/2014\/12\/30\/using-shp2stl-to-convert-maps-to-3d-models\/\" \/>\n\t\t<meta property=\"og:image\" content=\"https:\/\/dougmccune.com\/blog\/wp-content\/uploads\/2014\/09\/model_4.png\" \/>\n\t\t<meta property=\"og:image:secure_url\" content=\"https:\/\/dougmccune.com\/blog\/wp-content\/uploads\/2014\/09\/model_4.png\" \/>\n\t\t<meta property=\"og:image:width\" content=\"2574\" \/>\n\t\t<meta property=\"og:image:height\" content=\"1524\" \/>\n\t\t<meta property=\"article:published_time\" content=\"2014-12-30T16:30:40+00:00\" \/>\n\t\t<meta property=\"article:modified_time\" content=\"2017-01-04T00:05:00+00:00\" \/>\n\t\t<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n\t\t<meta name=\"twitter:title\" content=\"Using shp2stl to Convert Maps to 3D Models | Doug McCune\" \/>\n\t\t<meta name=\"twitter:description\" content=\"I&#039;ve been working on a utility called shp2stl that converts geographic data in shapefiles to 3D models, suitable for 3D printing. The code is published as a NodeJS package, available on npm and GitHub. You can control the height of each shape by specifying an attribute of your data to use. Each shape will be\" \/>\n\t\t<meta name=\"twitter:image\" content=\"https:\/\/dougmccune.com\/blog\/wp-content\/uploads\/2014\/09\/model_4.png\" \/>\n\t\t<script type=\"application\/ld+json\" class=\"aioseo-schema\">\n\t\t\t{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/dougmccune.com\\\/blog\\\/2014\\\/12\\\/30\\\/using-shp2stl-to-convert-maps-to-3d-models\\\/#article\",\"name\":\"Using shp2stl to Convert Maps to 3D Models | Doug McCune\",\"headline\":\"Using shp2stl to Convert Maps to 3D Models\",\"author\":{\"@id\":\"https:\\\/\\\/dougmccune.com\\\/blog\\\/author\\\/admin-2\\\/#author\"},\"publisher\":{\"@id\":\"https:\\\/\\\/dougmccune.com\\\/blog\\\/#person\"},\"image\":{\"@type\":\"ImageObject\",\"url\":\"https:\\\/\\\/i0.wp.com\\\/dougmccune.com\\\/blog\\\/wp-content\\\/uploads\\\/2014\\\/09\\\/model_4.png?fit=2574%2C1524&ssl=1\",\"width\":2574,\"height\":1524},\"datePublished\":\"2014-12-30T08:30:40-08:00\",\"dateModified\":\"2017-01-03T16:05:00-08:00\",\"inLanguage\":\"en-US\",\"commentCount\":3,\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/dougmccune.com\\\/blog\\\/2014\\\/12\\\/30\\\/using-shp2stl-to-convert-maps-to-3d-models\\\/#webpage\"},\"isPartOf\":{\"@id\":\"https:\\\/\\\/dougmccune.com\\\/blog\\\/2014\\\/12\\\/30\\\/using-shp2stl-to-convert-maps-to-3d-models\\\/#webpage\"},\"articleSection\":\"Code, Maps\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/dougmccune.com\\\/blog\\\/2014\\\/12\\\/30\\\/using-shp2stl-to-convert-maps-to-3d-models\\\/#breadcrumblist\",\"itemListElement\":[{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/dougmccune.com\\\/blog#listItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/dougmccune.com\\\/blog\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/dougmccune.com\\\/blog\\\/category\\\/maps\\\/#listItem\",\"name\":\"Maps\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/dougmccune.com\\\/blog\\\/category\\\/maps\\\/#listItem\",\"position\":2,\"name\":\"Maps\",\"item\":\"https:\\\/\\\/dougmccune.com\\\/blog\\\/category\\\/maps\\\/\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/dougmccune.com\\\/blog\\\/2014\\\/12\\\/30\\\/using-shp2stl-to-convert-maps-to-3d-models\\\/#listItem\",\"name\":\"Using shp2stl to Convert Maps to 3D Models\"},\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/dougmccune.com\\\/blog#listItem\",\"name\":\"Home\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/dougmccune.com\\\/blog\\\/2014\\\/12\\\/30\\\/using-shp2stl-to-convert-maps-to-3d-models\\\/#listItem\",\"position\":3,\"name\":\"Using shp2stl to Convert Maps to 3D Models\",\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/dougmccune.com\\\/blog\\\/category\\\/maps\\\/#listItem\",\"name\":\"Maps\"}}]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/dougmccune.com\\\/blog\\\/#person\",\"name\":\"Doug McCune\",\"image\":\"https:\\\/\\\/dougmccune.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/01\\\/tTL5uiW4_400x400.jpeg\",\"sameAs\":[\"https:\\\/\\\/instagram.com\\\/doug_mccune\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/dougmccune.com\\\/blog\\\/author\\\/admin-2\\\/#author\",\"url\":\"https:\\\/\\\/dougmccune.com\\\/blog\\\/author\\\/admin-2\\\/\",\"name\":\"Doug\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\\\/\\\/dougmccune.com\\\/blog\\\/2014\\\/12\\\/30\\\/using-shp2stl-to-convert-maps-to-3d-models\\\/#authorImage\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/1559cc79696919726297c735cddc893c8983709f55a8773bdc1d45aea8c79051?s=96&d=blank&r=x\",\"width\":96,\"height\":96,\"caption\":\"Doug\"}},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/dougmccune.com\\\/blog\\\/2014\\\/12\\\/30\\\/using-shp2stl-to-convert-maps-to-3d-models\\\/#webpage\",\"url\":\"https:\\\/\\\/dougmccune.com\\\/blog\\\/2014\\\/12\\\/30\\\/using-shp2stl-to-convert-maps-to-3d-models\\\/\",\"name\":\"Using shp2stl to Convert Maps to 3D Models | Doug McCune\",\"description\":\"I've been working on a utility called shp2stl that converts geographic data in shapefiles to 3D models, suitable for 3D printing. The code is published as a NodeJS package, available on npm and GitHub. You can control the height of each shape by specifying an attribute of your data to use. Each shape will be\",\"inLanguage\":\"en-US\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/dougmccune.com\\\/blog\\\/#website\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/dougmccune.com\\\/blog\\\/2014\\\/12\\\/30\\\/using-shp2stl-to-convert-maps-to-3d-models\\\/#breadcrumblist\"},\"author\":{\"@id\":\"https:\\\/\\\/dougmccune.com\\\/blog\\\/author\\\/admin-2\\\/#author\"},\"creator\":{\"@id\":\"https:\\\/\\\/dougmccune.com\\\/blog\\\/author\\\/admin-2\\\/#author\"},\"image\":{\"@type\":\"ImageObject\",\"url\":\"https:\\\/\\\/i0.wp.com\\\/dougmccune.com\\\/blog\\\/wp-content\\\/uploads\\\/2014\\\/09\\\/model_4.png?fit=2574%2C1524&ssl=1\",\"@id\":\"https:\\\/\\\/dougmccune.com\\\/blog\\\/2014\\\/12\\\/30\\\/using-shp2stl-to-convert-maps-to-3d-models\\\/#mainImage\",\"width\":2574,\"height\":1524},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/dougmccune.com\\\/blog\\\/2014\\\/12\\\/30\\\/using-shp2stl-to-convert-maps-to-3d-models\\\/#mainImage\"},\"datePublished\":\"2014-12-30T08:30:40-08:00\",\"dateModified\":\"2017-01-03T16:05:00-08:00\"},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/dougmccune.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/dougmccune.com\\\/blog\\\/\",\"name\":\"Doug McCune\",\"description\":\"Sculptor\",\"inLanguage\":\"en-US\",\"publisher\":{\"@id\":\"https:\\\/\\\/dougmccune.com\\\/blog\\\/#person\"}}]}\n\t\t<\/script>\n\t\t<!-- All in One SEO -->\n\n","aioseo_head_json":{"title":"Using shp2stl to Convert Maps to 3D Models | Doug McCune","description":"I've been working on a utility called shp2stl that converts geographic data in shapefiles to 3D models, suitable for 3D printing. The code is published as a NodeJS package, available on npm and GitHub. You can control the height of each shape by specifying an attribute of your data to use. Each shape will be","canonical_url":"https:\/\/dougmccune.com\/blog\/2014\/12\/30\/using-shp2stl-to-convert-maps-to-3d-models\/","robots":"max-image-preview:large","keywords":"code,maps","webmasterTools":{"miscellaneous":""},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/dougmccune.com\/blog\/2014\/12\/30\/using-shp2stl-to-convert-maps-to-3d-models\/#article","name":"Using shp2stl to Convert Maps to 3D Models | Doug McCune","headline":"Using shp2stl to Convert Maps to 3D Models","author":{"@id":"https:\/\/dougmccune.com\/blog\/author\/admin-2\/#author"},"publisher":{"@id":"https:\/\/dougmccune.com\/blog\/#person"},"image":{"@type":"ImageObject","url":"https:\/\/i0.wp.com\/dougmccune.com\/blog\/wp-content\/uploads\/2014\/09\/model_4.png?fit=2574%2C1524&ssl=1","width":2574,"height":1524},"datePublished":"2014-12-30T08:30:40-08:00","dateModified":"2017-01-03T16:05:00-08:00","inLanguage":"en-US","commentCount":3,"mainEntityOfPage":{"@id":"https:\/\/dougmccune.com\/blog\/2014\/12\/30\/using-shp2stl-to-convert-maps-to-3d-models\/#webpage"},"isPartOf":{"@id":"https:\/\/dougmccune.com\/blog\/2014\/12\/30\/using-shp2stl-to-convert-maps-to-3d-models\/#webpage"},"articleSection":"Code, Maps"},{"@type":"BreadcrumbList","@id":"https:\/\/dougmccune.com\/blog\/2014\/12\/30\/using-shp2stl-to-convert-maps-to-3d-models\/#breadcrumblist","itemListElement":[{"@type":"ListItem","@id":"https:\/\/dougmccune.com\/blog#listItem","position":1,"name":"Home","item":"https:\/\/dougmccune.com\/blog","nextItem":{"@type":"ListItem","@id":"https:\/\/dougmccune.com\/blog\/category\/maps\/#listItem","name":"Maps"}},{"@type":"ListItem","@id":"https:\/\/dougmccune.com\/blog\/category\/maps\/#listItem","position":2,"name":"Maps","item":"https:\/\/dougmccune.com\/blog\/category\/maps\/","nextItem":{"@type":"ListItem","@id":"https:\/\/dougmccune.com\/blog\/2014\/12\/30\/using-shp2stl-to-convert-maps-to-3d-models\/#listItem","name":"Using shp2stl to Convert Maps to 3D Models"},"previousItem":{"@type":"ListItem","@id":"https:\/\/dougmccune.com\/blog#listItem","name":"Home"}},{"@type":"ListItem","@id":"https:\/\/dougmccune.com\/blog\/2014\/12\/30\/using-shp2stl-to-convert-maps-to-3d-models\/#listItem","position":3,"name":"Using shp2stl to Convert Maps to 3D Models","previousItem":{"@type":"ListItem","@id":"https:\/\/dougmccune.com\/blog\/category\/maps\/#listItem","name":"Maps"}}]},{"@type":"Person","@id":"https:\/\/dougmccune.com\/blog\/#person","name":"Doug McCune","image":"https:\/\/dougmccune.com\/blog\/wp-content\/uploads\/2022\/01\/tTL5uiW4_400x400.jpeg","sameAs":["https:\/\/instagram.com\/doug_mccune"]},{"@type":"Person","@id":"https:\/\/dougmccune.com\/blog\/author\/admin-2\/#author","url":"https:\/\/dougmccune.com\/blog\/author\/admin-2\/","name":"Doug","image":{"@type":"ImageObject","@id":"https:\/\/dougmccune.com\/blog\/2014\/12\/30\/using-shp2stl-to-convert-maps-to-3d-models\/#authorImage","url":"https:\/\/secure.gravatar.com\/avatar\/1559cc79696919726297c735cddc893c8983709f55a8773bdc1d45aea8c79051?s=96&d=blank&r=x","width":96,"height":96,"caption":"Doug"}},{"@type":"WebPage","@id":"https:\/\/dougmccune.com\/blog\/2014\/12\/30\/using-shp2stl-to-convert-maps-to-3d-models\/#webpage","url":"https:\/\/dougmccune.com\/blog\/2014\/12\/30\/using-shp2stl-to-convert-maps-to-3d-models\/","name":"Using shp2stl to Convert Maps to 3D Models | Doug McCune","description":"I've been working on a utility called shp2stl that converts geographic data in shapefiles to 3D models, suitable for 3D printing. The code is published as a NodeJS package, available on npm and GitHub. You can control the height of each shape by specifying an attribute of your data to use. Each shape will be","inLanguage":"en-US","isPartOf":{"@id":"https:\/\/dougmccune.com\/blog\/#website"},"breadcrumb":{"@id":"https:\/\/dougmccune.com\/blog\/2014\/12\/30\/using-shp2stl-to-convert-maps-to-3d-models\/#breadcrumblist"},"author":{"@id":"https:\/\/dougmccune.com\/blog\/author\/admin-2\/#author"},"creator":{"@id":"https:\/\/dougmccune.com\/blog\/author\/admin-2\/#author"},"image":{"@type":"ImageObject","url":"https:\/\/i0.wp.com\/dougmccune.com\/blog\/wp-content\/uploads\/2014\/09\/model_4.png?fit=2574%2C1524&ssl=1","@id":"https:\/\/dougmccune.com\/blog\/2014\/12\/30\/using-shp2stl-to-convert-maps-to-3d-models\/#mainImage","width":2574,"height":1524},"primaryImageOfPage":{"@id":"https:\/\/dougmccune.com\/blog\/2014\/12\/30\/using-shp2stl-to-convert-maps-to-3d-models\/#mainImage"},"datePublished":"2014-12-30T08:30:40-08:00","dateModified":"2017-01-03T16:05:00-08:00"},{"@type":"WebSite","@id":"https:\/\/dougmccune.com\/blog\/#website","url":"https:\/\/dougmccune.com\/blog\/","name":"Doug McCune","description":"Sculptor","inLanguage":"en-US","publisher":{"@id":"https:\/\/dougmccune.com\/blog\/#person"}}]},"og:locale":"en_US","og:site_name":"Doug McCune | Sculptor","og:type":"article","og:title":"Using shp2stl to Convert Maps to 3D Models | Doug McCune","og:description":"I've been working on a utility called shp2stl that converts geographic data in shapefiles to 3D models, suitable for 3D printing. The code is published as a NodeJS package, available on npm and GitHub. You can control the height of each shape by specifying an attribute of your data to use. Each shape will be","og:url":"https:\/\/dougmccune.com\/blog\/2014\/12\/30\/using-shp2stl-to-convert-maps-to-3d-models\/","og:image":"https:\/\/dougmccune.com\/blog\/wp-content\/uploads\/2014\/09\/model_4.png","og:image:secure_url":"https:\/\/dougmccune.com\/blog\/wp-content\/uploads\/2014\/09\/model_4.png","og:image:width":2574,"og:image:height":1524,"article:published_time":"2014-12-30T16:30:40+00:00","article:modified_time":"2017-01-04T00:05:00+00:00","twitter:card":"summary_large_image","twitter:title":"Using shp2stl to Convert Maps to 3D Models | Doug McCune","twitter:description":"I've been working on a utility called shp2stl that converts geographic data in shapefiles to 3D models, suitable for 3D printing. The code is published as a NodeJS package, available on npm and GitHub. You can control the height of each shape by specifying an attribute of your data to use. Each shape will be","twitter:image":"https:\/\/dougmccune.com\/blog\/wp-content\/uploads\/2014\/09\/model_4.png"},"aioseo_meta_data":{"post_id":"2061","title":null,"description":null,"keywords":null,"keyphrases":null,"primary_term":null,"canonical_url":null,"og_title":null,"og_description":null,"og_object_type":"default","og_image_type":"default","og_image_url":null,"og_image_width":null,"og_image_height":null,"og_image_custom_url":null,"og_image_custom_fields":null,"og_video":null,"og_custom_url":null,"og_article_section":null,"og_article_tags":null,"twitter_use_og":false,"twitter_card":"default","twitter_image_type":"default","twitter_image_url":null,"twitter_image_custom_url":null,"twitter_image_custom_fields":null,"twitter_title":null,"twitter_description":null,"schema":{"blockGraphs":[],"customGraphs":[],"default":{"data":{"Article":[],"Course":[],"Dataset":[],"FAQPage":[],"Movie":[],"Person":[],"Product":[],"ProductReview":[],"Car":[],"Recipe":[],"Service":[],"SoftwareApplication":[],"WebPage":[]},"graphName":"","isEnabled":true},"graphs":[]},"schema_type":null,"schema_type_options":null,"pillar_content":false,"robots_default":true,"robots_noindex":false,"robots_noarchive":false,"robots_nosnippet":false,"robots_nofollow":false,"robots_noimageindex":false,"robots_noodp":false,"robots_notranslate":false,"robots_max_snippet":null,"robots_max_videopreview":null,"robots_max_imagepreview":"large","priority":null,"frequency":null,"location":null,"local_seo":null,"breadcrumb_settings":null,"limit_modified_date":false,"ai":null,"created":"2021-01-03 18:07:30","updated":"2025-06-03 20:24:20","seo_analyzer_scan_date":null},"aioseo_breadcrumb":"<div class=\"aioseo-breadcrumbs\"><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/dougmccune.com\/blog\" title=\"Home\">Home<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">\u00bb<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/dougmccune.com\/blog\/category\/maps\/\" title=\"Maps\">Maps<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">\u00bb<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\tUsing shp2stl to Convert Maps to 3D Models\n\t\t<\/span><\/div>","aioseo_breadcrumb_json":[{"label":"Home","link":"https:\/\/dougmccune.com\/blog"},{"label":"Maps","link":"https:\/\/dougmccune.com\/blog\/category\/maps\/"},{"label":"Using shp2stl to Convert Maps to 3D Models","link":"https:\/\/dougmccune.com\/blog\/2014\/12\/30\/using-shp2stl-to-convert-maps-to-3d-models\/"}],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/dougmccune.com\/blog\/wp-content\/uploads\/2014\/09\/model_4.png?fit=2574%2C1524&ssl=1","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/dougmccune.com\/blog\/wp-json\/wp\/v2\/posts\/2061","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dougmccune.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dougmccune.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dougmccune.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dougmccune.com\/blog\/wp-json\/wp\/v2\/comments?post=2061"}],"version-history":[{"count":35,"href":"https:\/\/dougmccune.com\/blog\/wp-json\/wp\/v2\/posts\/2061\/revisions"}],"predecessor-version":[{"id":2495,"href":"https:\/\/dougmccune.com\/blog\/wp-json\/wp\/v2\/posts\/2061\/revisions\/2495"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/dougmccune.com\/blog\/wp-json\/wp\/v2\/media\/2040"}],"wp:attachment":[{"href":"https:\/\/dougmccune.com\/blog\/wp-json\/wp\/v2\/media?parent=2061"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dougmccune.com\/blog\/wp-json\/wp\/v2\/categories?post=2061"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dougmccune.com\/blog\/wp-json\/wp\/v2\/tags?post=2061"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}