Subscribe to this thread
Home - General / All posts - hectare mesh out of SW points
adaptagis

633 post(s)
#14-Jul-16 14:24

hello Community

I got a file containing the South-western Point of a hectare mesh as a reference.

to create the actual mesh (or grid)

1.I use the local offset in the projection section and set them to 50 meter

2. set a buffer of 50m

3. I create a bounding box among the buffer area..

I'm pretty shure that there is a mor elegant (sql) way to do this task..

any hints are most welcome!

Dimitri

5,119 post(s)
online
#14-Jul-16 16:41

A quick and dirty way to create a grid:

1. Create a drawing that contains the southwestern point marking the corner of your desired grid.

2. Zoom out to the view that covers the area of interest where you would like your grid to be created.

3. Use View - Grid (see http://www.georeference.org/doc/manifold.htm#view_grid.htm ) to create a grid as line objects or points or however you want it. You can just set every 50m for x and y.

4. Using snap to lines and snap to points, select the entire grid, then move it (using the SHIFT move) so that the lower left corner of the grid snaps to the southwestern reference point.

5. Select any parts of the created grid that is beyond the bounds of what you want and delete it.

tjhb

8,410 post(s)
online
#15-Jul-16 04:37

I have SQL for this if you want it, as well as Dimitri's perfectly elegant solution.

It would be necessary to know how you set up the whole extent of the grid, e.g. by the extent of a component or object, by a second point marking the upper right limit, or something else.

adaptagis

633 post(s)
#25-Jul-16 21:59

thank you Dimitri and Tim

sorry for the late reply.. was on a development survey

in Haiti that got a bit complicated.. will try Dimitris approach and keep you

posted.

worthind3 post(s)
#26-Jul-16 10:31

tim

i have a need to set a hexagonal grid across the extent of a component

would appreciate any sql pointers

tjhb

8,410 post(s)
online
#26-Jul-16 10:36

Funnily enough, I have some old code for this (from 2009). I haven't looked at it since, and don't have time to revise it just now (night time), but have a look and we can discuss it later.

OPTIONS COORDSYS("Drawing" AS COMPONENT);

PARAMETERS [Radius (m)] DOUBLE;

SELECT [N][M][Cell]

FROM 

    (SELECT

        [D].[Box],

        [N][M],

        ConvertToArea(

            AssignCoordSys(

                CASE [M] MOD 2

                    WHEN 0 THEN -- Even row

                        NewLine(

                            NewPoint(

                                    [OffsetX] + ([N] * 3 - 1) * [Radius (m)][OffsetY] + [M] * [Radius (m)] * Cos(Deg2Rad(30))

                                    ),

                            NewPoint(

                                    [OffsetX] + ([N] * 3 - 0.5) * [Radius (m)][OffsetY] + [M] * [Radius (m)] * Cos(Deg2Rad(30)) + Cos(Deg2Rad(30)) * [Radius (m)]

                                    ),

                            NewPoint(

                                    [OffsetX] + ([N] * 3 + 0.5) * [Radius (m)][OffsetY] + [M] * [Radius (m)] * Cos(Deg2Rad(30)) + Cos(Deg2Rad(30)) * [Radius (m)]

                                    ),

                            NewPoint(

                                    [OffsetX] + ([N] * 3 + 1) * [Radius (m)][OffsetY] + [M] * [Radius (m)] * Cos(Deg2Rad(30))

                                    ),

                            NewPoint(

                                    [OffsetX] + ([N] * 3 + 0.5) * [Radius (m)][OffsetY] + [M] * [Radius (m)] * Cos(Deg2Rad(30)) - Cos(Deg2Rad(30)) * [Radius (m)]

                                    ),

                            NewPoint(

                                    [OffsetX] + ([N] * 3 - 0.5) * [Radius (m)][OffsetY] + [M] * [Radius (m)] * Cos(Deg2Rad(30)) - Cos(Deg2Rad(30)) * [Radius (m)]

                                    ),

                            NewPoint(

                                    [OffsetX] + ([N] * 3 - 1) * [Radius (m)][OffsetY] + [M] * [Radius (m)] * Cos(Deg2Rad(30))

                                    )

                            )

                    WHEN 1 THEN -- Odd row

                        NewLine(

                            NewPoint(

                                    [OffsetX] + ([N] * 3 + 0.5) * [Radius (m)][OffsetY] + [M] * [Radius (m)] * Cos(Deg2Rad(30))

                                    ),

                            NewPoint(

                                    [OffsetX] + ([N] * 3 + 1) * [Radius (m)][OffsetY] + [M] * [Radius (m)] * Cos(Deg2Rad(30)) + Cos(Deg2Rad(30)) * [Radius (m)]

                                    ),

                            NewPoint(

                                    [OffsetX] + ([N] * 3 + 2) * [Radius (m)][OffsetY] + [M] * [Radius (m)] * Cos(Deg2Rad(30)) + Cos(Deg2Rad(30)) * [Radius (m)]

                                    ),

                            NewPoint(

                                    [OffsetX] + ([N] * 3 + 2.5) * [Radius (m)][OffsetY] + [M] * [Radius (m)] * Cos(Deg2Rad(30))

                                    ),

                            NewPoint(

                                    [OffsetX] + ([N] * 3 + 2) * [Radius (m)][OffsetY] + [M] * [Radius (m)] * Cos(Deg2Rad(30)) - Cos(Deg2Rad(30)) * [Radius (m)]

                                    ),

                            NewPoint(

                                    [OffsetX] + ([N] * 3 + 1) * [Radius (m)][OffsetY] + [M] * [Radius (m)] * Cos(Deg2Rad(30)) - Cos(Deg2Rad(30)) * [Radius (m)]

                                    ),

                            NewPoint(

                                    [OffsetX] + ([N] * 3 + 0.5) * [Radius (m)][OffsetY] + [M] * [Radius (m)] * Cos(Deg2Rad(30))

                                    )

                        )

                    END

                    COORDSYS("Drawing" AS COMPONENT)

                )

            ) AS [Cell]

    FROM 

        (SELECT

            [Box],

            MinX([Box]AS [OffsetX],

            MinY([Box]AS [OffsetY]

        FROM

            (SELECT

                BoundingBox(UnionAll([Box])) AS [Box]

            FROM

                (SELECT

                    CASE [Type (I)]

                        WHEN 3 THEN UnionAll([Geom (I)]-- Areas

                        WHEN 2 THEN BoundingBox(AllBranches([Geom (I)])) -- Lines

                        WHEN 1 THEN BoundingBox(AllCoords([Geom (I)])) -- Points

                    END AS [Box]

                FROM [Drawing]

                WHERE [Selection (I)]

                GROUP BY [Type (I)]

                )

            )

        ) AS [D]

        LEFT JOIN

        (SELECT

            --[Digit 7] * 1e6 +

            --[Digit 6] * 1e5 +

            --[Digit 5] * 1e4 +

            [Digit 4] * 1e3 +

            [Digit 3] * 100 + 

            [Digit 2] * 10 + 

            [Digit 1] AS [N]

        FROM

            --(VALUES (0), (1), (2), (3), (4), (5), (6), (7), (8), (9) NAMES ([Digit 7]))

            --CROSS JOIN

            --(VALUES (0), (1), (2), (3), (4), (5), (6), (7), (8), (9) NAMES ([Digit 6]))

            --CROSS JOIN

            --(VALUES (0), (1), (2), (3), (4), (5), (6), (7), (8), (9) NAMES ([Digit 5]))

            --CROSS JOIN

            (VALUES (0), (1), (2), (3), (4), (5), (6), (7), (8), (9) NAMES ([Digit 4]))

            CROSS JOIN

            (VALUES (0), (1), (2), (3), (4), (5), (6), (7), (8), (9) NAMES ([Digit 3]))

            CROSS JOIN

            (VALUES (0), (1), (2), (3), (4), (5), (6), (7), (8), (9) NAMES ([Digit 2]))

            CROSS JOIN

            (VALUES (0), (1), (2), (3), (4), (5), (6), (7), (8), (9) NAMES ([Digit 1]))

        ) AS [OffsetX]

        ON [OffsetX].[N] <= RectWidth([D].[Box]) / [Radius (m)] / 3

        LEFT JOIN

        (SELECT

            --[Digit 7] * 1e6 +

            --[Digit 6] * 1e5 +

            --[Digit 5] * 1e4 +

            [Digit 4] * 1e3 +

            [Digit 3] * 100 + 

            [Digit 2] * 10 + 

            [Digit 1] AS [M]

        FROM

            --(VALUES (0), (1), (2), (3), (4), (5), (6), (7), (8), (9) NAMES ([Digit 7]))

            --CROSS JOIN

            --(VALUES (0), (1), (2), (3), (4), (5), (6), (7), (8), (9) NAMES ([Digit 6]))

            --CROSS JOIN

            --(VALUES (0), (1), (2), (3), (4), (5), (6), (7), (8), (9) NAMES ([Digit 5]))

            --CROSS JOIN

            (VALUES (0), (1), (2), (3), (4), (5), (6), (7), (8), (9) NAMES ([Digit 4]))

            CROSS JOIN

            (VALUES (0), (1), (2), (3), (4), (5), (6), (7), (8), (9) NAMES ([Digit 3]))

            CROSS JOIN

            (VALUES (0), (1), (2), (3), (4), (5), (6), (7), (8), (9) NAMES ([Digit 2]))

            CROSS JOIN

            (VALUES (0), (1), (2), (3), (4), (5), (6), (7), (8), (9) NAMES ([Digit 1]))

        ) AS [OffsetY]

        ON [OffsetY].[M] <= RectHeight([D].[Box]) / ([Radius (m)] * Cos(Deg2Rad(30))) + 1

    )

--WHERE Touches([Cell], [Box])

--AND NOT Adjacent([Cell], [Box])

;

Attachments:
Draw hex grid.txt

worthind3 post(s)
#28-Jul-16 10:53

errr, yeah, thats a pretty good pointer, lol

no revision needed!

that is very nice thanku

any explanation of the greyed out would be appreciated

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