I have a list of coordinates in Lambert Conformal Conic projection. Those coordinates draw the border of specific area.


I need to create a topojson file to use this as a map in D3.js

I found how to insert them in QGIS but after that I do not understand how to generate my topojson.

Can I do it directly in QGIS or is there an other way ?


I've just done a quick google and found this blog that converts shp to topojson. By the looks of it, it can all be done through the command line.

  • And how can I get this shapefile ? With my coordinates ? – Weedoze Sep 8 '16 at 14:51
  • If your coordinates are in a csv you can load them straight into QGIS using 'Add delimited text layer'. Else create a csv in excel with two columns (x, y) and split out the coordinates in your list into their respective columns, then load into qgis and save that out as a shapefile – Knightshound Sep 8 '16 at 14:55
  • I have multiple csv file (1 by polygon) - When importing in QGIS I got multiple layers. Should I export them one by one ? – Weedoze Sep 9 '16 at 6:08
  • It could be a pain if you have many files to import into QGIS but save each one out as a shp and under 'Vector > Data Management Tools > Merge Vector Layers' you can create a single shapefile. – Knightshound Sep 9 '16 at 7:16

Convert points (from a delimited layer) to polygons

If your data is in a spreadsheet, you can import it directly with the XYTools plugin, without needing to export as CSV.

Then use the Points2One plugin on your points layer. If your points are arranged in order around the boundary you should be okay.

Export to TopJSON

There's no direct export in QGIS to TopoJSON at the moment (as of 2.16), just GeoJSON.

But there are a couple of Options open to you...

  • The D3 Map Renderer Plugin. This lets you export TopoJSON. However it has a couple of prerequisites which you'll need to install yourself (npm, javascript topojson, a local http server). It's used to build D3 web pages, if you're comfortable with JavaScript this should give you a good start.

  • Another option is MapShaper. This is a site that lets you load in shapefiles and export topoJSON. Got some useful features like the ability to tweak the detail level (simplification) to get file sizes down further, and can attempt to fix geometries too :)

  • Points2One seems to work well if I do it polygon by polygon but then how can I concatenate it ? If I first concatenate all my csv files in one it will draw the polygons + some random lines – Weedoze Sep 9 '16 at 6:40

You can use the command line tool here: https://github.com/mbostock/topojson/wiki/Command-Line-Reference

That's what I'd do:

  1. Create the polygon in QGIS (see other answers)
  2. Export as SHP
  3. Use topojson command line tool to change from SHP to TopoJSON (play with quantisation to optimise file size.

You could try directly reading the CSV using TopoJSON, but I'm not sure if it handles your list of coordinates as a polygon.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.