This is a result of a query:
The landuse column contains multiple attributes of polygons.
Now I want to create n new columns for the same table that have exactly the names from that query result strings (allotments, cemetery, commercial .... ).
I would do it manually, but I don't know all attributes that exist. Therefore, I need a programmatical solution.
I could not find a fitting solution in other posts.
CREATE TABLE wu_stations_karlsruhe_landcover_features AS (
WITH city_stations AS (
SELECT city, centerid, loc
--,ST_Buffer(loc :: GEOGRAPHY, 1000) AS stat_surr -- Take 1km radius to find close land coverage polygons
FROM wunderground_stations_within_large_cities
WHERE city = 'Karlsruhe'
),
stations_landuse_landcover AS
(
SELECT city, centerid, landuse, "natural", AVG(cs1.loc::geography <-> gp1.way::geography) AS dist, SUM(ST_Area(way::geography))
FROM ger_polygon_landcover AS gp1, city_stations AS cs1
WHERE ST_DWithin(cs1.loc::geography, gp1.way::geography, 1000)
GROUP BY city, centerid, landuse, "natural"
ORDER BY city, centerid, landuse, "natural"
)
SELECT *
FROM stations_landuse_landcover
);