1

I have a set of points which represent the bottom left corner of a 50x50 meters grid. Could you please let me know if there is a way to build a polygon/square from this point to represent the 50x50 area?

There are over 10,000 points in the file.

My point data is in Latitude and Longitude.

  • Welcome to GIS:SE @geejay! Perhaps this post might help: How to create square buffers around points in QGIS with Python? – Joseph Sep 15 '16 at 11:11
  • Maybe a duplicate of gis.stackexchange.com/questions/210295/…. – user30184 Sep 15 '16 at 11:12
  • Thanks both - unfortunately, it asks about having the centre in the centroid position which I am able to figure out, but not sure how to progress with a polygon where the point is at the corner of each polygon to be created. – geejay Sep 15 '16 at 11:14
  • Have you tried ' Vector > Research Tools > Vector Grid'. You can then you the points layer as the grid extent with a 50m spacing and output as polygons – Knightshound Sep 15 '16 at 11:17
  • @Knightshound I need the polygon to 'have' the point at its bottom right corner. The points are not uniform/complete, so there may be 20 points spread across a city, and I need a 50x50 polygon where the point is at the bottom right corner. A vector grid would just place a grid over the entire canvas/selection. – geejay Sep 15 '16 at 11:21
3

It can be done without to much code, even in a good old spreadsheet program. But to do so with QGis: The idea is to build a WKT, well known text out of it. You have the lower left of a square and need the other 4 points to build a geometry (start and endpoint needs to be onto each other). As it is a square its easy with simple math. You add 50 to the x-coordinate, then 50 to both x and y and so on. The rules for formatting a wkt can be found here : https://en.wikipedia.org/wiki/Well-known_text

You end up with the following you put into the field-calculator for a new text field (set it to a length of 254, as the maximum for a shapefile and sufficient here):

'POLYGON ((' ||  $x  || ' ' ||  $y  || ', '||  ($x+50)  || ' ' ||  $y  || ', '||  ($x+50)  || ' ' ||  ($y+50)  || ', '||  $x  || ' ' ||  ($y+50)  || ', '||  $x  || ' ' ||  $y  || ', ' || '))'

It is just some text concatenation to build the wkt. You then export your layer to a csv. And load it as a text via "Layer menue - Load layer from textfile" You set it to comma seperated and choose "Well-Known-Text" at geometry definition and your text field you created earlier. Choose the correct coordinate reference when Qgis asks you after loading.

Added some pictures for better clearance (sorry for the german qgis, but the idea should be possible to follow):

enter image description here

enter image description here

enter image description here

enter image description here

  • Thanks for this Matte. Adding the 50 to x, y etc. just bumps up my coordinate number by 50 - it doesn't change it to 50m ? – geejay Sep 15 '16 at 13:10
  • Try to understand how the polygon is constructed from WKT. Is takes your original point as start vertex, bumps up coordinates and puts the second vertex there and so on, till the fifth vertex that is closing the polygon. – user30184 Sep 15 '16 at 13:34
  • I understand that. My question is that the bump doesn't seem to be distance but rather the literal value of the coordinate. This is because when I use the field calculate before exporting, the export is actually the direct coordinates? Or have I got the step of exporting wrong? – geejay Sep 15 '16 at 13:39
  • If your coordinate system is using meters as units changing the coordinate value by 50 moves the point 50 meters. If you use a system that is using degrees as units the movement is 50 degrees. Coordinates are the way how the physical location of the feature are expressed with numbers. I do not quite understand what you mean with "literal value of coordinate". If you are 2 meters tall and someone is stretching you 3 meters tall the literal value or the z coordinate of your head is bumped by 1 meter but you should feel something physical as well. – user30184 Sep 15 '16 at 13:53
  • Thanks for your comments. To illustrate - as I input the field calculator formula, the output is given as: 382500 812900 (my OS grid reference), 382550 812900, 382550 812950 So the increase in 50 in the OSGrid reference is not the same as 50m distance. My coordinate system is 'correctly' set to EPSG:7405. Really appreciate your help. – geejay Sep 15 '16 at 14:05
0

You can use 'Vector > Research Tools > Vector Grid' to create a single square polygon from a point in the bottom right corner. The example below use a point at 0,0 to better understanding how to set the grid extents but essentially to create a 50m box with the point in the bottom right corner you must set

xmin = -50m from point x coordinates

xmax = -25m from point x coordinates

ymin = 25m from point y coordinate

ymax = 50m from point y coordinate

enter image description here

  • Thanks for your reply Knightshound. I must have clarified that there are over 10,000 points (not just 1). I am assuming your method only draws the polygon for a single point? – geejay Sep 15 '16 at 11:55
  • Sadly it does. It's best when asking a question to have as much information about your situation as possible. I would have to guess that python needs to be used here – Knightshound Sep 15 '16 at 12:00
  • I should have been more clear then. Are there any tools or code available to make this happen? – geejay Sep 15 '16 at 12:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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