Subscribe to this thread
Home - General / All posts - update polygon geometry based on point layer
irfan3 post(s)
#25-Feb-11 14:32

<!--[if gte mso 9]> Normal 0 21 false false false DE KO AR-SA MicrosoftInternetExplorer4 <![endif]--><!--[if gte mso 9]> <![endif]--><!--[if gte mso 10]> /* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-priority:99; mso-style-qformat:yes; mso-style-parent:""; mso-padding-alt:0cm 5.4pt 0cm 5.4pt; mso-para-margin-top:0cm; mso-para-margin-right:0cm; mso-para-margin-bottom:10.0pt; mso-para-margin-left:0cm; line-height:115%; mso-pagination:widow-orphan; font-size:11.0pt; font-family:"Calibri","sans-serif"; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin;} <![endif]-->

hi every one,

I have two shape files.

  1. Polygon shape file
  2. Point file contains some points.

Now i want to delete all the vertex of polygon shape file which are available in point file.

Any ideas how can i do this in Manifold.

Mike Pelletier


1,602 post(s)
#25-Feb-11 15:52

This might work. Add a column called CODE and fill it with a unique value for each polygon. Load both layer components into a map (use a copy of the polygon layer). Use the Point function in the transform toolbar on the polygon layer. Cntl-I to invert selection and delete areas (polygons). Then use Select Touching on the transform toolbar to select the points that touch vertices in your other layer. If they don't line up exactly, you could buffer the points in your point layer first to ensure proper selection. Once selected these points can be selected. Then use the following SQL to convert the points back to areas using the CODE column to group them.

SELECT ConvexHull(AllBranches(GEOM([ID]))), [Code] FROM [drawing] GROUP by [Code]

tjhb

8,760 post(s)
#25-Feb-11 19:07

Or in all-SQL, you could use this. It assumes a drawing called Areas and another called Points.

If you enter a tolerance parameter, then any vertex within that radius of a point will be removed. If you just hit enter then the tolerance is 0, so that a vertex is removed only if it exactly coincides with a point.

PARAMETERS [Tolerance (0)] DOUBLE;

SELECT

    [T1].[ID],

    ConvertToArea(AllCoords([T1].[Coord])) AS [Area]

FROM

    (SELECT

        [T1].[ID][T1].[Coord],

        [T2].[ID]

    FROM

        (SELECT [ID][Geom (I)][Coord]

        FROM [Areas]

        WHERE IsArea([ID])

        SPLIT BY Coords([Geom (I)]AS [Coord]

        ) AS [T1]

        LEFT JOIN

        (SELECT [ID][Geom (I)] AS [Point]

        FROM [Points]

        WHERE IsPoint([ID])

        ) AS [T2]

    ON Distance([T1].[Coord][T2].[Point])

        <= Coalesce([Tolerance (0)], 0)

    )

WHERE [T2].[ID] IS NULL

GROUP BY [T1].[ID];

SPLIT BY extracts coordinates in their proper sequential order, and if nothing is done to change this, then they will retain the same order even after filtering, so that they can be joined back together again into an area. (This isn't a guarantee provided by SQL itself, but the way Manifold is designed to behave.) The new area will still be coherent—unless the vertices selected for removal were crucial to the shape of the metric.

Attachments:
Remove coincident vertices.txt

tjhb

8,760 post(s)
#25-Feb-11 19:20

The result of the SELECT query needs linking into a new drawing.

The UPDATE verson below changes the original metrics in the existing drawing (Areas).

PARAMETERS [Tolerance (0)] DOUBLE;

UPDATE

    (SELECT [D].[Geom (I)][T].[Area]

    FROM

        [Areas] AS [D]

        INNER JOIN

        (SELECT

            [T1].[ID],

            ConvertToArea(AllCoords([T1].[Coord])) AS [Area]

        FROM

            (SELECT

                [T1].[ID][T1].[Coord],

                [T2].[ID]

            FROM

                (SELECT [ID][Coord]

                FROM [Areas]

                WHERE IsArea([ID])

                SPLIT BY Coords([Geom (I)]AS [Coord]

                ) AS [T1]

                LEFT JOIN

                (SELECT [ID][Geom (I)] AS [Point]

                FROM [Points]

                WHERE IsPoint([ID])

                ) AS [T2]

            ON Distance([T1].[Coord][T2].[Point])

                <= Coalesce([Tolerance (0)], 0)

            )

        WHERE [T2].[ID] IS NULL

        GROUP BY [T1].[ID]

        ) AS [T]

        ON [D].[ID] = [T].[ID]

    )

SET [Geom (I)] = [Area];

Attachments:
Remove coincident vertices (UPDATE).txt

irfan3 post(s)
#28-Feb-11 08:21

wow

perfect solution, i really love manifold sql capabilities.

thanks a lot for the solution.

Manifold User Community Use Agreement Copyright (C) 2007-2017 Manifold Software Limited. All rights reserved.