Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to convert a dataset of lines that contains the coast of New Zealand into a big polygon.

However using the vector -> geometry tools -> lines to polygon command in Quantum GIS results in a mess with lots of holes and lines outside of the coast.

How can I do the conversion successfully?

It worked on the 1:500k data, the 1:250k data, but not the 1:50k data.

I have a screenshot of the problem here - before and after: before after

The dataset is from here.

share|improve this question

I eventually fixed it by using PostGIS (since this was the eventual target of my fixed polygon layer anyway).

Here is the SQL I used:

ST_MakePolygon(ST_LineMerge(ST_Collect(ST_SnapToGrid(geom, 0.001))))

It basically rounds the vertex coordinates to remove any gaps in the coastline, then zips all the lines into a single line which is used as the boundary for the polygon.

share|improve this answer

A couple of points. Firstly, I think that there are problems with the original line shapefile. These can be put right using GRASS v.clean using the "snap" option. Try with a threshold of 5 to start with, but just 1 might do. GRASS v.clean can be run from the Sextante toolbox (it's very easy to use).

Secondly, for polygonising I should try the excellent "Polygonizer" plug-in. This needs the Shapely (python-shapely) package to be installed, which can be done using the OSGeo4W Installer or in Ubuntu using the package manager.


share|improve this answer
No matter how I tried to get v.clean to work it always made the result worse. – ljbade Sep 24 '12 at 2:01
polygonizer works like a charm! thanks – dof1985 Mar 28 '13 at 23:24

Have you seen the Topo50 LDS dataset which is already in polygon form?

We can build 250 and 500 versions if you need those as well.

share|improve this answer
That would be useful. – ljbade Sep 25 '12 at 17:59

LINZ have now added the topo250 and topo500 polygon layers.

share|improve this answer
Awesome!........ – ljbade Oct 5 '12 at 13:01

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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