5

I have a shapefile of a map that is the outline of a number of islands. I would like to convert the lines into polygons (ie all islands filled in) using GRASS. I searched on how to do this with GRASS but just got some very brief and vague suggestions ... but I gave it a go anyway ....

use v.in.ogr to import the shapefile into grass And view the result (I'm using QGIS to do this): Looks good.

v.clean input=g_hwp_p1 output=g_hwp_p1_clean tool=break,snap thresh=10,10
v.type input=g_hwp_p1_clean output=g_hwp_p1_clean_type type=line,boundary
v.centroids input=g_hwp_p1_clean_type output=g_hwp_p1_clean_type_centroids 

This didn't work which is not surprising as I don't really understand what I'm doing.

V.info says that...

g_hwp_p1 has 892 lines
g_hwp_p1_clean has 892 lines
g_hwp_p1_clean_type has 892 boundaries
g_hwp_p1_clean_type_centroids has 892 boundaries (0 centroids, 0 areas, 0 islands)

Also v.type reports:

892 incorrect boundaries.

And v.centroids reports:

0 features modified.

The final output looks much like the input (just an outline).

Can anyone spot what I'm doing wrong? Does anyone know what the correct parameters should be?

I also tried this in QGIS using the lines-to-polygon fTool but this didn't do a very good job of it (it didn't fill in the whole islands but just seemed to add little polygons round the edge).

Shapefile is here... https://docs.google.com/leaf?id=0B93lksnTC7_cYWIxNTlmNzEtYTcwYi00YmZlLTlhZmEtZDViYmE1MmYxNDk2&hl=en_US

Screenshoy of hwp_p1 .... https://docs.google.com/leaf?id=0B93lksnTC7_cN2Q5YTNiMjEtZjY4OS00ZTYwLWIxMDAtYzBlNmY1M2U1MGRl&hl=en_US

And a close-up of a small Island - it forms a closed loop.. https://docs.google.com/leaf?id=0B93lksnTC7_cZjQ1ZDU4ZGQtMWNmMC00ZjNiLWFiZmEtM2MyMDE0MmYzODQ5&hl=en_US

Thanks.

  • could you post a screenshot? – Pablo May 28 '11 at 14:47
  • Have you checked if the lines really form closed circles? – underdark May 28 '11 at 14:47
  • @Pablo. screenshot link added above. – spiderplant0 May 28 '11 at 15:01
  • @underdark I've visually checked several of the smaller islands and they looks closed. The larger ones cant really be checked manually (and this is just a cut down test for a bigger map). Is there a GRASS tool to check all lines form closed loops? – spiderplant0 May 28 '11 at 15:04
  • 1
    thats a very complex shape, I had no success in cleaning it here. My suggestion is to manually draw a polygon over it. – Pablo May 30 '11 at 14:39
3

This is an old question, but I ran into a similar problem today and found a way to do it. I have a shp of city blocks, but each "block" is actually a set of 4 street lines. This is the way to convert them into areas:

  1. v.build.polylines will convert connected lines to a polyline.

  2. v.type to convert the polylines to boundaries.

  3. Finally v.centroids to add centroids to the closed boundaries and thus create areas

1

Lines to Polygon tries to create one polygon for every line. It does that well. The tiny islands along the cost are created correctly. What it cannot do is recognize that your big island is formed by multiple lines.

Same seems to be true for the GRASS tools you tried to use.

PostGIS ST_BuildArea would do the trick but I couldn't get it work for the whole dataset yet.

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.