# Manually Create PolyData in vtk.js

**URL:** https://discourse.vtk.org/t/manually-create-polydata-in-vtk-js/885
**Category:** Web
**Created:** [May 1, 2019, 1:17am UTC](https://discourse.vtk.org/t/manually-create-polydata-in-vtk-js/885 "2019-05-01T01:17:36Z")
**Posts on this page:** 1
**Showing post:** 7

<div class="post-metadata">

### Author: ![PBrockmann](https://discourse.vtk.org/user_avatar/discourse.vtk.org/pbrockmann/32/524_2.png) [@PBrockmann](https://discourse.vtk.org/u/PBrockmann)
#### Post date: [June 17, 2019, 6:00pm UTC](https://discourse.vtk.org/t/manually-create-polydata-in-vtk-js/885/7 "2019-06-17T18:00:24Z")

</div>

Relative to this topic ‘Create polydata in vtk.js’, I am struggling with coding a polyData from a JSON file that represents continents.

Easy to read with d3.js, I cannot create a vtk.vtkAppendPolyData correctly.  
Any help would be appreciated.

```

```

```
d3.queue()
        .defer(d3.json, "https://unpkg.com/world-atlas@1/world/50m.json")
	.awaitAll(function(error, data) {
        	if (error) throw error;
        	console.log('continents ---> Read');
        	console.log('################### finished');

               multilinestring = topojson.mesh(data[0], data[0].objects.land);

              var polydata = vtk({
		  vtkClass: 'vtkPolyData',
		  points: {
		    vtkClass: 'vtkPoints',
		    dataType: 'Float32Array',
		    numberOfComponents: 3
		  },
		  lines: {
		    vtkClass: 'vtkCellArray',
		    dataType: 'Uint16Array'
		  }
	       });

               appendPolydata = vtk.Filters.General.vtkAppendPolyData.newInstance();
	       for (var p=0; p < multilinestring.coordinates.length; p++) {
        	       line = multilinestring.coordinates[p];
  		       polygonpoints = [];
  		       polygonlines = [];
                       for (var i=0; i<line.length; i++) {
			    xyz = vertex(line[i], 1.001); // calculate a projection (return xyz)
        		    polygonpoints.push(xyz[0], xyz[1], xyz[2]);
        		    polygonlines.push(i);
		     }
                     polydata.getPoints().setData(polygonpoints);
  		     polydata.getLines().setData(polygonlines);
                     appendPolydata.addInputConnection(polydata);	
                }

         // add mapper
        // add actor

         ); //await
```

I have done this in python and this was much easier. What am I missing ?

---

_[View the full topic](https://discourse.vtk.org/t/manually-create-polydata-in-vtk-js/885)._
