I have some building data (polygons) as a shapefile in QGIS 2.18. I'm trying to add a location coordinates (the polygons rough center) and an array of the polygons coordinates (its points). I've been able to do the first one using vector –> analysis tools –> mean coordinates which generates a new layer. I can't work out how to get the polygons coordinates though? The end goal is to extract this all to a spreadsheet if that makes a difference.
[GIS] Extract Polygon Coordinates from Shapefile data
geolocationpolygonqgisqgis-2shapefile
Related Solutions
First you need to project your geographic coordinates to a cartesian 2D coordinate system, since affine transformations don't apply to geographic coordinate systems.
You can apply an affine transformation from control points or from transformation parameters. The QGIS plugin asks you transformation parameters, but it is much more common for a user to have control points.
From control points you can calculate transformation parameters. For an affine transformation there are 6 transformation parameters, so you need at least 3 control points (each control point implies 4 coordinates: Xsource, Ysource, Xtarget, Ytarget), but more control points are recommended to have redundancy and thus be able to apply Least Squares, which would give you an estimation of the transformation's quality. Remember that affine transformations can rotate, shift, scale (even applying different factors on each axis) and skew geometries.
Control points must have the form:
X SOURCE: Xs
Y SOURCE: Ys
X TARGET: Xt
Y TARGET: Yt
Parameters are:
a: Scale X
e: Scale Y
d: Rotation X
b: Rotation Y
c: Translation X
f: Translation Y
And we know:
Xt = X*a + Y*b + c
Yt = X*d + Y*e + f
So, you need to solve this system of equations (for 3 control points):
¦ Xs1 Ys1 1 0 0 0 ¦ | a ¦ ¦ Xt1 ¦
¦ Xs2 Ys2 1 0 0 0 ¦ ¦ b ¦ ¦ Xt2 ¦
¦ Xs3 Ys3 1 0 0 0 ¦ ¦ c ¦ = ¦ Xt3 ¦
¦ 0 0 0 Xs1 Ys1 1 ¦ ¦ d ¦ ¦ Yt1 ¦
¦ 0 0 0 Xs2 Ys2 1 ¦ ¦ e ¦ ¦ Yt2 ¦
¦ 0 0 0 Xs3 Ys3 1 ¦ ¦ f ¦ ¦ Yt3 ¦
Where parameters a, b, c, d, e, and f are unknown.
Once you calculate parameters a, b, c, d, e, and f, (for example with this online equation solver) place them into the QGIS plugin interface like this:
X' = a*x + b*y + c
Y' = d*x + e*y + f
or:
I think this solves your two questions.
For rough build up areas:
- Using python load image and scipy/numpy to:
- smooth it to get "uniform darker colour" for buildings
- reclassify image colours to change building from light gray to black
For the example image the result processed by python script looks like this:
- vectorize this adjusted image
Some graphics and CAD software has good tools to convert technical drawings lines to polylines and can be scriptable but it is far from perfect and needs much additional manual work:
At the end for these kind of tasks if you need good quality vector polygons you need to do that manually.
Best Answer
If you have a common id in the centroid layer and vertice table using Joseph's comment/method you could bring both layer and table in QGIS and perform a join on the common id field and export that joined layer to a .csv.