Home - General / All posts - update polygon geometry based on point layer
 irfan3 post(s) #25-Feb-11 14:32 hi every one, I have two shape files. Polygon shape filePoint 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,629 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,883 post(s)online #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 NULLGROUP 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.
 tjhb               8,883 post(s)online #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];
 irfan3 post(s) #28-Feb-11 08:21 wowperfect 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.