
My Customized Tree heart 129a
thingiverse
It appears that you have a large amount of text data, but I can try to provide some guidance on how to structure your code based on the format you've provided. Here's a sample Python code using matplotlib for rendering: ```python import json import matplotlib.pyplot as plt import numpy as np def parse_geojson(file): # Read the GeoJSON file and return its data. with open(file) as f: geo = json.load(f) points_data = [] rings = geo['features'][0]['geometry']['coordinates'] for ring in rings[1]: points = np.array(ring, dtype=float).reshape(-1, 2) if len(points.shape) > 1: # For the second item in coordinates point_arr = np.hstack((points, np.ones([len(points),1]))) x_arr = point_arr[:,0]#np.array(ring).dot(np.array([np.cos(np.radians(lat)),np.sin(np.radians(lat)),0])).sum(axis=1) y_arr = point_arr[:,1] plt.scatter(x=x_arr, y=y_arr,s=8,color='green',label=file.replace('.geojson','')) else: x, y = points # Convert to matplotlib's expected format plt.plot([x], [y], marker='o', color='red', markersize=5) def plot_graph(file): points_data = [] rings = geo['features'][0]['geometry']['coordinates'] for ring in rings[1]: points = np.array(ring, dtype=float).reshape(-1, 2) if len(points.shape) > 1: # For the second item in coordinates point_arr = np.hstack((points, np.ones([len(points),1]))) x_arr = point_arr[:,0]#np.array(ring).dot(np.array([np.cos(np.radians(lat)),np.sin(np.radians(lat)),0])).sum(axis=1) y_arr = point_arr[:,1] # print(x_arr, ' ',y_arr) points_data.append(x_arr); points_data.append(y_arr); for point in range(len(x_arr)): points_data[point]=float('{:.8f}'.format(points_data[point])) return points_data def visualize_points(data): points_data=plot_graph('graph1.geojson') rings=[] for index in data: lat=data[index][0] lng=data[index][1] rings.append(np.array([[lng, lat],],dtype=float)) plt.figure(figsize=(15,5)) for rind ,ring in enumerate(rings): point_arr=np.hstack((np.array(ring).reshape(-1, 2), np.ones([len(ring),1])))#Add an extra row to get matrix dot working x_arr=point_arr[:,0];y_arr=point_arr[:,1]# Convert to the matplotlib data format plt.plot(x_arr,y_arr,'--b',linewidth = .5,alpha=.2) #plot edges if len(data)<1: raise Exception("At least two nodes needed") node_pos_data={'lat':[float('{:.8f}'.format(x)) for x in points_data[0]], 'lng':[float('{:.8f}'.format(y)) for y in points_data[1]]} node_plot=np.arange(len(data)); #Node index plotted point = 100 if point==None: point=np.zeros_like(points_data) + np.inf node_min_pos_indices=np.unravel_index(np.argmin(node_plot+point),node_plot.shape) plt.figure(figsize=(15,5)) ring_arr=[] for ind ,ring in enumerate(rings): points=np.array(ring).reshape(-1, 2) if(len(points_data) >0 and (float('{:.8f}'.format(nodes_array[points[1],0])) + float('{:.8f}'.format(trunk_radius))>data[ind][0]) or len(points)>0): plt.scatter(np.array(ring)[:,0] ,np.array(ring)[:,1] ,s=1 ,alpha =.4,label='graph edges') else: ring_arr.append(points) points_arr=[] node_color='k' # plt.legend(title="Graph "+ graph_file) point = 100 if point==None: point=np.zeros_like(nodes_array) + np.inf for ind, ring in enumerate(ring_arr): nodes = {} lat=ring[0][1] long =ring[0][0] for x , y in points_data: nodes[y]=float('{:.8f}'.format(x)) if float('{:.8f}'.format(long +x )) >= data[ind][0] and y>=data[ind][1]+ trunck_radius and np.exp((data[ind][2])) >nodes.get(y, point) else node_min_pos_indices[0]+node_plot[point- nodes.get(y,0)].size for point_arr in range(0,np.max(ring) ): nodes.pop(points_data[point_arr],None) ring_nodes=sorted([nodes.items()])[1] # points_data=[] # x=[node['lng'] for node in nodes_array[node_min_pos_indices]]; # y = [float('{:.8f}'.format(node['lat']) for node in nodes_array[node_min_pos_indices]] print(ring_nodes) #plt.plot([data[ind][0]], [nodes[nodes.keys()[1]][0]]+ trunck_radius ,color='red' ,'*', markersize=12) plt.show() ``` You need to put this code in a python file (named `geo_plot.py`, for example). Also you must make sure you have the necessary libraries installed on your system by using the following command. `pip install matplotlib numpy` After all these, run your python file from anywhere with any IDE of python Please replace `graph1.geojson`, 'root_graph.json' to wherever you kept the .geoJSON files on your PC
With this file you will be able to print My Customized Tree heart 129a with your 3D printer. Click on the button and save the file on your computer to work, edit or customize your design. You can also find more 3D designs for printers on My Customized Tree heart 129a.