Briefly saying there is no match, but you can make some of it yourself.
The resulting Attribute table after using the Create Grid contains five fields, namely:
"id"
, "left"
, "top"
, "right"
, and "bottom"
, see an image below.
where:
"id"
is simply an integer starting from 1 until n-th cell. The
order of cells is from the top-left feature to the bottom left each time moving one column right an so on, something like following the И
-pattern.
"left"
corresponds to the most western "X"
-coordinate
"top"
to the most northern "Y"
-coordinate
"right"
to the most eastern "X"
-coordinate
"bottom"
to the most southern "Y"
-coordinate
If your question was interpreted correctly, there are several possibilities to get the coordinates for each cell.
- Coordinates as a centroid of each cell:
SELECT "id", ST_X(st_centroid(geometry)) AS "X", ST_Y(st_centroid(geometry)) AS "Y"
FROM "Grid"
- Coordinates as a centroid of each cell in WKT-format:
SELECT "id", st_astext(st_centroid(geometry))
FROM "Grid"
- Coordinates as a polyline in WKT-format:
SELECT "id", st_astext(st_exteriorring(geometry))
FROM "Grid"
- Coordinates as a polygon in WKT-format:
SELECT "id", st_astext(geometry)
FROM "Grid"
All Options are based on the usage of a Virtual Layer through Layer > Add Layer > Add/Edit Virtual Layer...
.
So, my suggestion on this stage before exporting a grid in CSV-file is to create a new column in the Attribute table where you will store the geometry in a WKT-Format i.e. in the Field calculator use geom_to_wkt($geometry)
for a text-field with unlimited length, see image below.
So, afterwards you will be able freely read the wkt-geometry when importing a CSV-file into QGIS-Project, part of in described here Loading WKT polygons into QGIS.
If suddenly you have no opportunity to read a WKT from a CSV-file in QGIS, put eye on the following workflow.
Drag&Drop your csv with grids into QGIS
Deploy a Virtual Layer through Layer > Add Layer > Add/Edit Virtual Layer...
to obtain a layer with geometry.
SELECT *, setsrid(make_polygon(make_line(
make_point(left,bottom),
make_point(left,top),
make_point(right,top),
make_point(right,bottom)
)), #here use your SRID, e.g. 25833)
FROM "test"
Get the Output
Regarding the "Z"
and "M"
coordinates. If you have those Attributes in you CSV-file then extend the make_point(left,bottom)
to make_point(left,bottom, "alltitude_field", "m_field")
, e.g. make_point(1,2,3,4)
, as described in PostGIS Docs | ST_MakePoint.