9

I have a point data set which contains the information of workplaces per hectare.

Each point represents the South-Western corner of the surveyed hectare. Not the entire map is covered with points, only there where people are working does a point even exist.

I want to create now a polygon shapefile with many rectangular polygons (100*100m) and the information from the point.

In the image you can see how the point relates to the desired polygons. The ones scribbled in black are not necessary, as there are no workspaces.

I am using QGIS.

example

3 Answers 3

10

In QGIS, use "Geometry by Expression" tool (in a projected CRS). It will also add points information/attributes to polygons.

  • Select "Polygon" as "Output geometry type" option.

  • Add the following expression as "Geometry expression" value:

    make_square(make_point($x, $y), make_point($x+100, $y+100))
    

enter image description here

0
8

Using a Virtual layer, you can create a polygon of the desired dimension and move it to each location of the point layer. You can then save as the output if you want to persist the data.

Go to the menu Layer > Add Layer > Add/Edit Virtual Layer... and enter the following query. Replace the layer name for yours.

WITH src AS (
SELECT ST_GeomFromText('POLYGON((0 0, 100 0, 100 100, 0 100, 0 0))') AS geometry
)

SELECT ID, ST_Translate(src.geometry, st_x(pt.geometry), st_y(pt.geometry),0) as geometry
FROM "myPointLayer" pt, src

enter image description here

4

For each point (x,y) in a projected CRS generate a string like:

polygon((x y, x+100, y, x+100, y+100, x y+100, x y)) 

you can then process that into a Polygon using geom_from_wkt.

Then save the layer as a shapefile (or better still a GeoPackage).

2
  • 1
    thank you for your answer. Sorry for asking, but where you write that code?
    – Yves
    Sep 8, 2020 at 13:34
  • in the field calculator when you add your new field
    – Ian Turton
    Sep 8, 2020 at 13:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.