polygonization of lines in OJ results in one polygon but should be two

74 views
Skip to first unread message

Stefan Steiniger

unread,
May 16, 2012, 1:55:33 AM5/16/12
to openjum...@googlegroups.com, Martin Davis
Hi all & Martin,

any idea what is going wrong?

I attach a jml file with 2 linestrings.
I wish to polygonize them with receiving 2 polygons. However, the
polygonization function and the planar graph function return only one
polygon.
I assume that the problem is, that i would need to split the outer
linestring so that the dataset contains 3 linestrings? How to do that
automatically? I could not find the appropriate function in (Open)JUMP.
(Do I need to write a plugin?)

Note, if I actually use the Line Noder with Snap Rounding (2 Decimals) I
get lots of very short line segments, but from those the wished 2
polygons. weired. Hence, do I have a precision problem?

cheers,
stefan

PS: for the context: I am trying to extract the sidewalks from a line
dataset. The outer line is the lip of gutter of a road and the inner
line is the back of walk for a sidewalk - for one neighborhood block (as
we have a grided street network).

to_polygonize.jml

Michaël Michaud

unread,
May 16, 2012, 2:38:12 AM5/16/12
to openjum...@googlegroups.com
Hi Stefan,
> any idea what is going wrong?
>
> I attach a jml file with 2 linestrings.
> I wish to polygonize them with receiving 2 polygons. However, the
> polygonization function and the planar graph function return only one
> polygon.
> I assume that the problem is, that i would need to split the outer
> linestring so that the dataset contains 3 linestrings? How to do that
> automatically? I could not find the appropriate function in
> (Open)JUMP. (Do I need to write a plugin?)
Anything you need is in OpenJUMP.
Your dataset just miss one node.

With noder (new plugin), add intersection, choose snap rounding with two
decimals.
The process adds exactly 1 point to your dataset (from 1116 to 1117 points)
After that, two click with the new "Create Polygon from Closed Area"
should do the trick.
(I think polygonize needs your linestrings to be split first, what you
can also do with new noder)

One drawback is that all your coordinates are changed (rounded to
nearest centimeter grid node)

Another solution would be to use Extension > Topology > Network cleaning
Unfortunately, the plugin creates a spike (I think this is not possible
to get something
cleaner except using snarounding method as for the noder plugin)

Micha�l

>
> Note, if I actually use the Line Noder with Snap Rounding (2 Decimals)
> I get lots of very short line segments, but from those the wished 2
> polygons. weired. Hence, do I have a precision problem?
>
> cheers,
> stefan
>
> PS: for the context: I am trying to extract the sidewalks from a line
> dataset. The outer line is the lip of gutter of a road and the inner
> line is the back of walk for a sidewalk - for one neighborhood block
> (as we have a grided street network).
>
> -- You received this message because you are subscribed to the Google
> Groups openjump-users group. To post to this group, send email to
> openjum...@googlegroups.com. To unsubscribe from this group, send
> email to openjump-user...@googlegroups.com. For more
> options, visit this group at
> https://groups.google.com/d/forum/openjump-users?hl=en

edgar....@web.de

unread,
May 16, 2012, 4:01:16 AM5/16/12
to openjum...@googlegroups.com
How about simply converting them with the geometry converter? Works, for one linestring you still need to add the closing segment with geomconv beforehand though.

..ede

edgar....@web.de

unread,
May 16, 2012, 4:32:43 AM5/16/12
to openjum...@googlegroups.com
you can even use the inner linestring to cut a hole into the outer by using geomconv by
1. append closing segment on both (only appends if ring is open)
2. merge features into one
3. convert the multigeometry of this feature to polygon (it intelligently detects inner rings)

et voila.. ede

Stefan Steiniger

unread,
May 16, 2012, 9:55:39 AM5/16/12
to openjum...@googlegroups.com, Martin Davis
Hi Michael, Ede, Martin

ok - I will have a look again at the new noder plugin.
Half of your suggestions involves actually some suggestion for manual
work. Which is quite impossible, as the dataset contains couple of
hundred linestrings (= need to extract some hundred sidewalk polys).
Though - only a few have the problem described, of a missing node (maybe
20?).

stefan

Am 16.05.12 04:32, schrieb edgar....@web.de:

edgar....@web.de

unread,
May 16, 2012, 10:05:26 AM5/16/12
to openjum...@googlegroups.com
On 16.05.2012 15:55, Stefan Steiniger wrote:
> Hi Michael, Ede, Martin
>
> ok - I will have a look again at the new noder plugin.
> Half of your suggestions involves actually some suggestion for manual work. Which is quite impossible, as the dataset contains couple of hundred linestrings (= need to extract some hundred sidewalk polys). Though - only a few have the problem described, of a missing node (maybe 20?).
>

select the layer and in geomconv
1. add closing segment
2. convert to polygon
done

..ede

edgar....@web.de

unread,
May 16, 2012, 10:21:58 AM5/16/12
to openjum...@googlegroups.com
to be clear:

select layer in layer tree
and
rightclick in layerview or use tools menu entry.

..ede

Stefan Steiniger

unread,
May 16, 2012, 10:40:34 AM5/16/12
to openjum...@googlegroups.com
Hey ede,

of course.
I did what you suggested (i-close all lines, ii-merge all lines to multi
geom, iii-convert to polygon) - but this results also in a new polygon
segment that comes from the closing of the one line (on right side in
the example). So, I am not sure if that's the right way and I need to
check what happens in other cases. But an interesting approach I haven't
thought off.

I also will investigate further the line nodding.

thanks
stefan

Am 16.05.12 10:21, schrieb edgar....@web.de:

edgar....@web.de

unread,
May 16, 2012, 10:47:18 AM5/16/12
to openjum...@googlegroups.com
On 16.05.2012 16:40, Stefan Steiniger wrote:
> Hey ede,
>
> of course.
> I did what you suggested (i-close all lines, ii-merge all lines to multi geom,

you can skip ii as it as well works on the whole layer

>iii-convert to polygon) - but this results also in a new polygon segment that comes from the closing of the one line (on right side in the example).

you can only have a polygon from a closed linearring/linestring .. so it is actually an issue of missing samples ;)

>So, I am not sure if that's the right way and I need to check what happens in other cases. But an interesting approach I haven't thought off.

from this tool you can see i come from a background of desktop publishing where you can convert your vector graphic shapes as you please :)

..ede

Stefan Steiniger

unread,
May 16, 2012, 11:38:11 AM5/16/12
to openjum...@googlegroups.com
Hei Michael,

ok.. using the line noder with snap round and then polygonize the
generated dataset works - as you did say.
However I would like to know if it fine that the the second layer
produced, called something like "nodes", is an empty layer. Should this
layer contain the newly created nodes? or what should it contain? Is it
a bug?

stefan

Am 16.05.12 02:38, schrieb Michaël Michaud:
> Michaël

Michaël Michaud

unread,
May 16, 2012, 3:16:14 PM5/16/12
to openjum...@googlegroups.com
Hi Stefan,

> ok.. using the line noder with snap round and then polygonize the
> generated dataset works - as you did say.
> However I would like to know if it fine that the the second layer
> produced, called something like "nodes", is an empty layer. Should
> this layer contain the newly created nodes? or what should it contain?
> Is it a bug?
Yes, more or less.
To keep things simple, the first option "find intersections" always use
a basic noder (using floating points arithmetic).
This noder does not find this intersection only found by snap-rounding
noder.

I realize that it would be more consistent to use the same noder for
finding and for noding,
I'll try to fix that if it is not too complex.

Micha�l

>
> stefan
>
> Am 16.05.12 02:38, schrieb Micha�l Michaud:
>> Micha�l
Reply all
Reply to author
Forward
0 new messages