Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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
add comment

4 Answers 4

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
add comment

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.

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

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
1  
That would be useful. –  Leith Sep 25 '12 at 17:59
add comment

LINZ have now added the topo250 and topo500 polygon layers.

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

Your Answer

 
discard

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.