In the below post I make some queries and it works fine. However when I add the lines that do the coordinates conversion and the line that query the geom I receive the following error when I run the web-service:
Input geometry has unknown (0) SRID
I am new to Postgis. How can I fix this issue?
Code:
query = """ WITH data AS (
SELECT '{featuresArray}'::json AS featuresCollection
)
SELECT gid,geom,type::text,properties::text,
array_to_string(array_agg(x_4326||' '||y_4326 ORDER BY gid),',') AS g4326,
array_to_string(array_agg(x_25832||' '||y_25832 ORDER BY gid),',') AS g25832
FROM (
SELECT
ROW_NUMBER() OVER () AS gid,
ST_AsText(ST_GeomFromGeoJSON(feature->>'geometry')) AS geom,
feature->>'type' AS type,
feature->>'properties' AS properties,
ST_X((ST_DumpPoints((ST_GeomFromGeoJSON(feature->>'geometry')))).geom) x_4326,
ST_Y((ST_DumpPoints((ST_GeomFromGeoJSON(feature->>'geometry')))).geom) y_4326,
ST_X((ST_DumpPoints((ST_Transform(ST_GeomFromGeoJSON(feature->>'geometry'),25832)))).geom) x_25832,
ST_X((ST_DumpPoints((ST_Transform(ST_GeomFromGeoJSON(feature->>'geometry'),25832)))).geom) y_25832
FROM (SELECT json_array_elements(featuresCollection->'features') AS feature FROM data) AS f) j
GROUP BY gid,type::text,properties::text,geom
ORDER BY gid;""".format(featuresArray=featuresArray)