{"id":6515,"date":"2023-10-09T20:12:07","date_gmt":"2023-10-09T20:12:07","guid":{"rendered":"https:\/\/handandmachine.org\/classes\/computational_fabrication\/?p=6515"},"modified":"2023-10-10T02:59:41","modified_gmt":"2023-10-10T02:59:41","slug":"lins-assignment-3-3d-bar-chart-map-physicalization","status":"publish","type":"post","link":"https:\/\/handandmachine.org\/classes\/computational_fabrication\/2023\/10\/09\/lins-assignment-3-3d-bar-chart-map-physicalization\/","title":{"rendered":"Lin&#8217;s 3D bar chart map physicalization"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">This dataset physicalization project is inspired by this website: <a href=\"https:\/\/pudding.cool\/2018\/10\/city_3d\/\">https:\/\/pudding.cool\/2018\/10\/city_3d\/<\/a>; on this website; the worldwide population density is shown on the map by a 3D bar chart. I am highly impressed by the final presentation results. When we talked about data physicalizaiton with 3D printers, I know this is something I will do for this assignment.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The data I got is from New Mexico Economic Development Department; https:\/\/edd.newmexico.gov\/. From there, I got the map data including the area for each county of New Mexico in square miles, the county-wise population data, the county-wise income data, the population change data from 2010 to 2020. I felt more comfortable dealing with data in MATLAB and I found there are ways to generate STL files in MATLAB too. So, I used MATLAB to deal with the 3D printing. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Here is the workflow: <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">read in the map picture-&gt;read in county data-&gt;clean the map picture-&gt;merge map data and county data in the matrix-&gt;generate the STL file-&gt;print the data physicalization products, the whole process is pretty smooth. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The reuslts are here:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/handandmachine.org\/classes\/computational_fabrication\/wp-content\/uploads\/2023\/10\/Screenshot-2023-10-09-133740-1024x732.png\" alt=\"\" class=\"wp-image-6615\" style=\"width:1100px;height:786px\" width=\"1100\" height=\"786\" srcset=\"https:\/\/handandmachine.org\/classes\/computational_fabrication\/wp-content\/uploads\/2023\/10\/Screenshot-2023-10-09-133740-1024x732.png 1024w, https:\/\/handandmachine.org\/classes\/computational_fabrication\/wp-content\/uploads\/2023\/10\/Screenshot-2023-10-09-133740-300x214.png 300w, https:\/\/handandmachine.org\/classes\/computational_fabrication\/wp-content\/uploads\/2023\/10\/Screenshot-2023-10-09-133740-768x549.png 768w, https:\/\/handandmachine.org\/classes\/computational_fabrication\/wp-content\/uploads\/2023\/10\/Screenshot-2023-10-09-133740-920x657.png 920w, https:\/\/handandmachine.org\/classes\/computational_fabrication\/wp-content\/uploads\/2023\/10\/Screenshot-2023-10-09-133740-575x411.png 575w, https:\/\/handandmachine.org\/classes\/computational_fabrication\/wp-content\/uploads\/2023\/10\/Screenshot-2023-10-09-133740-380x272.png 380w, https:\/\/handandmachine.org\/classes\/computational_fabrication\/wp-content\/uploads\/2023\/10\/Screenshot-2023-10-09-133740.png 1132w\" sizes=\"auto, (max-width: 1100px) 100vw, 1100px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">For a little bit more discussions: The only problem I encountered is to determine how thick the data column should be. Thinner columns are hard to be well printed. Here is an example of badly printed result.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"768\" src=\"https:\/\/handandmachine.org\/classes\/computational_fabrication\/wp-content\/uploads\/2023\/10\/\u5fae\u4fe1\u56fe\u7247_20231009135806-1024x768.jpg\" alt=\"\" class=\"wp-image-6619\" srcset=\"https:\/\/handandmachine.org\/classes\/computational_fabrication\/wp-content\/uploads\/2023\/10\/\u5fae\u4fe1\u56fe\u7247_20231009135806-1024x768.jpg 1024w, https:\/\/handandmachine.org\/classes\/computational_fabrication\/wp-content\/uploads\/2023\/10\/\u5fae\u4fe1\u56fe\u7247_20231009135806-300x225.jpg 300w, https:\/\/handandmachine.org\/classes\/computational_fabrication\/wp-content\/uploads\/2023\/10\/\u5fae\u4fe1\u56fe\u7247_20231009135806-768x576.jpg 768w, https:\/\/handandmachine.org\/classes\/computational_fabrication\/wp-content\/uploads\/2023\/10\/\u5fae\u4fe1\u56fe\u7247_20231009135806-1536x1152.jpg 1536w, https:\/\/handandmachine.org\/classes\/computational_fabrication\/wp-content\/uploads\/2023\/10\/\u5fae\u4fe1\u56fe\u7247_20231009135806-1140x855.jpg 1140w, https:\/\/handandmachine.org\/classes\/computational_fabrication\/wp-content\/uploads\/2023\/10\/\u5fae\u4fe1\u56fe\u7247_20231009135806-920x690.jpg 920w, https:\/\/handandmachine.org\/classes\/computational_fabrication\/wp-content\/uploads\/2023\/10\/\u5fae\u4fe1\u56fe\u7247_20231009135806-575x431.jpg 575w, https:\/\/handandmachine.org\/classes\/computational_fabrication\/wp-content\/uploads\/2023\/10\/\u5fae\u4fe1\u56fe\u7247_20231009135806-380x285.jpg 380w, https:\/\/handandmachine.org\/classes\/computational_fabrication\/wp-content\/uploads\/2023\/10\/\u5fae\u4fe1\u56fe\u7247_20231009135806.jpg 1702w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Another issue is that bars are normally colored in data visualizations, but it is hard to make different colors in data phsicalization by 3D printers, one possible solution is to use colored 3D printer like this one: <a href=\"https:\/\/us.store.bambulab.com\/products\/a1-mini\">https:\/\/us.store.bambulab.com\/products\/a1-mini<\/a>. The other problem is I have not figured out a way to represent negative values yet. Such as the population increase rates for each county from 2010 to 2020, the most counties&#8217; population is decreasing. It should be pits for these counties on the data physicalization products. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The data files is here: https:\/\/handandmachine.org\/classes\/computational_fabrication\/wp-content\/uploads\/2023\/10\/NM_data.xlsx<br>The MATLAB file cannot be uploaded for some reason, I write the code in the following blocks.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">I = imread(&#8220;NM blank map.png&#8221;);<br>data = readtable(&#8220;NM_data.xlsx&#8221;);<br>I = rgb2gray(I);<br>imshow(I);<br>map_data = zeros(size(I,1),size(I,2));<br>for i=1:size(I,1)<br>for j=1:size(I,2)<br>if(I(i,j)&gt;128)<br>map_data(i,j) = 1; % 1 means there is no line<br>else<br>map_data(i,j) = 0; % 0 means there is a line<br>end<br>end<br>end<br>imshow(map_data);<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">%%make sure it is a closed shape<br>for i=2:size(map_data,1)-1<br>for j=2:size(map_data,2)-2<br>if(map_data(i,j)==0)<br>%if(map_data(i+1,j)<em>map_data(i-1,j)<\/em>map_data(i,j+1)<em>map_data(i,j-1)<\/em>map_data(i+1,j+1)<em>map_data(i-1,j-1)<\/em>map_data(i+1,j-1)<em>map_data(i-1,j+1)&gt;0) if(map_data(i+1,j)<\/em>map_data(i-1,j)<em>map_data(i,j+1)<\/em>map_data(i,j-1)&gt;0)<br>&#8220;oh no, fill a hole here!&#8221;<br>%[i,j]<br>%[map_data(i+1,j),map_data(i-1,j),map_data(i,j+1),map_data(i,j-1)]<br>%[map_data(i+2,j),map_data(i-2,j),map_data(i,j+2),map_data(i,j-2)]<br>map_data(i,j)=1;<br>end<br>end<br>end<br>end<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">%for visualization<br>for i=1:size(map_data,1)<br>for j=1:size(map_data,2)<br>if(map_data(i,j)==1)<br>map_data(i,j) = H; % 50 means this is not an edge<br>else<br>map_data(i,j) = H*1.1; % 6 means there is an edge<br>end<br>end<br>end<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">%fill in the height value for each county<br>H = 30;<br>for i = 1:33<br>%set_value = 5+log(3+table2array(data(i,&#8221;popuDensity&#8221;)));<br>set_value = H + table2array(data(i,&#8221;popuDensity&#8221;)); %used in 3D print<br>%set_value = log(table2array(data(i,&#8221;perCapitalIncome&#8221;)));<br>%set_value = H+table2array(data(i,&#8221;perCapitalIncome&#8221;))\/1000; %used in 3D print<br>%set_value = 5+table2array(data(i,&#8221;populationChange_10_20_&#8221;))\/10;<br>x = table2array(data(i,&#8221;center_x&#8221;));<br>y = table2array(data(i,&#8221;center_y&#8221;));<br>for j = x-5:x+5<br>for k = y-5:y+5<br>map_data(j,k) = set_value;<br>end<br>end<br>end<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">%writematrix(map_data, &#8216;map_countour.csv&#8217;)<br>mesh(map_data);<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">%this this the base with height of H<br>width = size(map_data,1);<br>height = size(map_data,2);<br>[P,T] = generate_Cuboid(0,0,width,height,H);<br>allVertices = [P];<br>allFaces = [T];<br>offset = 8;<br>%these are the data columns<br>for i = 1:33<br>x = table2array(data(i,&#8221;center_x&#8221;));<br>y = table2array(data(i,&#8221;center_y&#8221;));<br>[P,T] = generate_Cuboid(x,y,30,30,map_data(x,y));<br>allVertices = [P;allVertices];<br>allFaces = [T+offset;allFaces];<br>offset = offset + 8;<br>end<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">%these are the map edges<br>for i=1:size(map_data,1)<br>for j=1:size(map_data,2)<br>if(map_data(i,j)== H<em>1.1) [P,T] = generate_Cuboid(i,j,10,10,H<\/em>1.2); %edges have heights of H*1.1<br>allVertices = [P;allVertices];<br>allFaces = [T+offset;allFaces];<br>offset = offset + 8;<br>end<br>end<br>end<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">% allVertices = zeros(8<em>size(map_data,1)<\/em>size(map_data,2),3);<br>% allFaces = zeros(12<em>size(map_data,1)<\/em>size(map_data,2),3);<br>% offset = 0;<br>% count_v = 1;<br>% count_f = 1;<br>% for i=1:size(map_data,1)<br>% for j=1:size(map_data,2)<br>% [P,T] = generate_Cuboid(i,j,1,1,map_data(i,j));<br>% allVertices(count_v:count_v+7,:) = P;<br>% allFaces(count_f:count_f+11,:) = T+offset;<br>% offset = offset+8;<br>% count_f = count_f+12;<br>% end<br>% end<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">% [P1,T1] = generate_Cuboid(0,0,5,5,3);<br>% [P2,T2] = generate_Cuboid(2.5,2.5,1,1,7);<br>% [P3,T3] = generate_Cuboid(-4,-4,3,3,12);<br>%<br>% allVertices = [P1; P2];<br>% T2_offset = T2+8;<br>% allFaces = [T1; T2_offset];<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">% [P1,T1] = generate_Cuboid(0,0,5,5,3);<br>% [P2,T2] = generate_Cuboid(2.5,2.5,1,1,7);<br>% [P3,T3] = generate_Cuboid(-4,-4,3,3,12);<br>%<br>% allVertices = [];<br>% allVertices = [P1; allVertices];<br>% allVertices = [P2; allVertices];<br>%<br>% allFaces = [];<br>% offset = 0;<br>% allFaces = [allFaces; T1+offset];<br>% offset = offset + 8;<br>% allFaces = [allFaces; T2+offset];<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">% Create a triangulation object<br>triangulationObject = triangulation(allFaces, allVertices);<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">stlwrite(triangulationObject,&#8221;cuboid.stl&#8221;);<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">function [P,T] = generate_Cuboid(x, y, length, width, height)<br>P = [x, y, 0;<br>length+x, y, 0;<br>length+x, width+y, 0;<br>x, width+y, 0;<br>x, y, height;<br>x+length, y, height;<br>x+length, width+y, height;<br>x, width+y, height];<br>T = [1, 2, 6;<br>6, 5, 1;<br>2, 3, 7;<br>7, 6, 2;<br>3, 4, 8;<br>8, 7, 3;<br>4, 1, 5;<br>5, 8, 4;<br>1, 2, 3;<br>3, 4, 1;<br>5, 6, 7;<br>7, 8, 5];<br>%TR = triangulation(T,P);<br>end<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">function flood_fill(x,y,arr2D,set_value)<br>if(arr2D(x,y)&gt;5)<br>return;<br>else<br>arr2D(x,y) = set_value;<br>arr2D(x,y)<br>flood_fill(x+1,y,arr2D,set_value);<br>flood_fill(x-1,y,arr2D,set_value);<br>flood_fill(x,y+1,arr2D,set_value);<br>flood_fill(x,y-1,arr2D,set_value);<br>end<br>end<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>This dataset physicalization project is inspired by this website: https:\/\/pudding.cool\/2018\/10\/city_3d\/; on this website; the worldwide population density is shown on the map by a 3D bar chart. I am highly impressed by the final presentation results. When we talked about data physicalizaiton with 3D printers, I know this is something I will do for this assignment. The data I got [&hellip;]<\/p>\n","protected":false},"author":29,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[24],"tags":[],"class_list":["post-6515","post","type-post","status-publish","format-standard","hentry","category-studentwork23"],"_links":{"self":[{"href":"https:\/\/handandmachine.org\/classes\/computational_fabrication\/wp-json\/wp\/v2\/posts\/6515","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/handandmachine.org\/classes\/computational_fabrication\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/handandmachine.org\/classes\/computational_fabrication\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/handandmachine.org\/classes\/computational_fabrication\/wp-json\/wp\/v2\/users\/29"}],"replies":[{"embeddable":true,"href":"https:\/\/handandmachine.org\/classes\/computational_fabrication\/wp-json\/wp\/v2\/comments?post=6515"}],"version-history":[{"count":15,"href":"https:\/\/handandmachine.org\/classes\/computational_fabrication\/wp-json\/wp\/v2\/posts\/6515\/revisions"}],"predecessor-version":[{"id":6745,"href":"https:\/\/handandmachine.org\/classes\/computational_fabrication\/wp-json\/wp\/v2\/posts\/6515\/revisions\/6745"}],"wp:attachment":[{"href":"https:\/\/handandmachine.org\/classes\/computational_fabrication\/wp-json\/wp\/v2\/media?parent=6515"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/handandmachine.org\/classes\/computational_fabrication\/wp-json\/wp\/v2\/categories?post=6515"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/handandmachine.org\/classes\/computational_fabrication\/wp-json\/wp\/v2\/tags?post=6515"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}