Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have one ASCII text file with eight columns. The first four provide the x-coordinates (e.g. longitude) of the four corners of a grid cell, while the last four provide the y-coordinates (e.g. latitude) of the four corners of the same cell in the same order. Furthermore, the fourth x-coordinate of line k is equal to the first x-coordinate of line k + 1, and the third x-coordinate of line k is equal to the second x-coordinate of line k + 1; similarly for the y-coordinates. This means that the cells described in lines k and k + 1 are adjacent having two corners in common. In this context, the number of lines in the file is the number of grid cells.

I would like to ask if there is some way to draw in QGIS the grid cells described in this way.

Any ideas?

share|improve this question
I doubt you can achieve this without manually scripting it, but do check the list of plugins in case someone already worked with the same kind of files. – lynxlynxlynx Jan 22 '13 at 9:06
I can definitely write a Fortran program to re-arrange the data in the file but I don't know what kind of arrangement QGIS wants to see in order to draw the cells properly. – user14461 Jan 22 '13 at 9:32

If the coordinates describe a regular grid, it might be easier to extract the bounds and cell size and create the grid without going through the trouble of parsing the text file.

If the grid is irregular, one of the easier approaches - requiring no programming skills - would be to open the text file in Calc/Excel and use string concatenation to construct well-known text (WKT) representations of polygons (the cells). Here's an example WKT:

POLYGON ((30 10, 10 20, 20 40, 40 40, 30 10))

Of course, the same can be done using a scripting language of your choice.

share|improve this answer
Thanks for answering but I don't understand the suggestion about concatenation and WKT representations. Could you be more explicit? – user14461 Jan 22 '13 at 9:30
I see. So, this means that I will have to re-write my grid file in this way? That is, lines as much as the cells in the format you suggest? Sorry for insisting but I don't remember QGIS being able to read this. Re-arranging my file in WKT format seems pretty straightforward though. – user14461 Jan 22 '13 at 11:11
Compare… – underdark Jan 22 '13 at 11:13
Hm, I just found this:…. So, can I replace the "POINT" keyword by "POLYGON" as long as I provide 5 points inside the double parentheses? – user14461 Jan 22 '13 at 11:15
OK, thanks! I think that I have all the elements to start experimenting. – user14461 Jan 22 '13 at 11:19

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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