7

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.

4 Answers 4

6

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.

4

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.

N.

1
  • No matter how I tried to get v.clean to work it always made the result worse.
    – ljbade
    Commented Sep 24, 2012 at 2:01
0

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.

1
  • 1
    That would be useful.
    – ljbade
    Commented Sep 25, 2012 at 17:59
0

LINZ have now added the topo250 and topo500 polygon layers.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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