Skip to main content
Post Reopened by Inactivated Account, Andre Silva, John Powell, Mapperz
Removed commentary
Source Link
PolyGeo
  • 65.4k
  • 29
  • 114
  • 345

Really basic here but cant find a proper solution.

I create a query in PostGIS using 'where' clause, and with that a table. now I want to use those attributes to create a intersection with other table... but I don't know how to call the attributes, because is always asking for the original table and like that it will skip the query

First query to get Rail features:

CREATE TABLE RAIL AS
SELECT rw.gid, rw.name, rw.type, rw.geom
FROM railways rw
WHERE "type" = 'rail';

Here I have my new table (layer in qgis) with only the type "rails". NOw when I want to do the intersection with rivers table (layer):

CREATE TABLE RW_W_RESULT AS
SELECT rw.gid as rwgid, rw.name as rwname, rw.type as rwtype, w.gid as wgid, w.name as wname, w.type as wtype, 
ST_COLLECTIONEXTRACT(ST_INTERSECTION(w.geom, rw.geom),1) as rw_w_geom, 
COUNT(DISTINCT rw.gid)                      
FROM waterways w, rail 
WHERE ST_INTERSECTS(w.geom, rw.geom) AND w.gid < rw.gid 
GROUP BY rw.gid,w.gid;

I got this error: ERROR: missing FROM-clause entry for table "rw", that is clear to me, but how im suppose to call the attributes of the new created table(layer) to work with this query? If I eliminate rw. from the attributes its says is ambiguous.

Disclamer: thank you all for correction my initial query, I realize I didnt write it right in the question. For those who voted against my question... really? this is GIS TOO!

Really basic here but cant find a proper solution.

I create a query in PostGIS using 'where' clause, and with that a table. now I want to use those attributes to create a intersection with other table... but I don't know how to call the attributes, because is always asking for the original table and like that it will skip the query

First query to get Rail features:

CREATE TABLE RAIL AS
SELECT rw.gid, rw.name, rw.type, rw.geom
FROM railways rw
WHERE "type" = 'rail';

Here I have my new table (layer in qgis) with only the type "rails". NOw when I want to do the intersection with rivers table (layer):

CREATE TABLE RW_W_RESULT AS
SELECT rw.gid as rwgid, rw.name as rwname, rw.type as rwtype, w.gid as wgid, w.name as wname, w.type as wtype, 
ST_COLLECTIONEXTRACT(ST_INTERSECTION(w.geom, rw.geom),1) as rw_w_geom, 
COUNT(DISTINCT rw.gid)                      
FROM waterways w, rail 
WHERE ST_INTERSECTS(w.geom, rw.geom) AND w.gid < rw.gid 
GROUP BY rw.gid,w.gid;

I got this error: ERROR: missing FROM-clause entry for table "rw", that is clear to me, but how im suppose to call the attributes of the new created table(layer) to work with this query? If I eliminate rw. from the attributes its says is ambiguous.

Disclamer: thank you all for correction my initial query, I realize I didnt write it right in the question. For those who voted against my question... really? this is GIS TOO!

I create a query in PostGIS using 'where' clause, and with that a table. now I want to use those attributes to create a intersection with other table... but I don't know how to call the attributes, because is always asking for the original table and like that it will skip the query

First query to get Rail features:

CREATE TABLE RAIL AS
SELECT rw.gid, rw.name, rw.type, rw.geom
FROM railways rw
WHERE "type" = 'rail';

Here I have my new table (layer in qgis) with only the type "rails". NOw when I want to do the intersection with rivers table (layer):

CREATE TABLE RW_W_RESULT AS
SELECT rw.gid as rwgid, rw.name as rwname, rw.type as rwtype, w.gid as wgid, w.name as wname, w.type as wtype, 
ST_COLLECTIONEXTRACT(ST_INTERSECTION(w.geom, rw.geom),1) as rw_w_geom, 
COUNT(DISTINCT rw.gid)                      
FROM waterways w, rail 
WHERE ST_INTERSECTS(w.geom, rw.geom) AND w.gid < rw.gid 
GROUP BY rw.gid,w.gid;

I got this error: ERROR: missing FROM-clause entry for table "rw", that is clear to me, but how im suppose to call the attributes of the new created table(layer) to work with this query? If I eliminate rw. from the attributes its says is ambiguous.

added 712 characters in body
Source Link

Really basic here but cant find a proper solution.

I create a query in PostGIS using 'where' clause, and with that a table. now I want to use those attributes to create a intersection with other table... but I don't know how to call the attributes, because is always asking for the original table and like that it will skip the query

First query to get Rail features:

CREATE TABLE RAIL AS
SELECT rw.gid, rw.name, rw.type, rw.geom
FROM railways rw
WHERE "type" = 'rail';

And queryHere I have my new table (layer in qgis) with only the type "rails". NOw when I want to get rail features intersectingdo the intersection with rivers table (layer):

selectCREATE TABLE RW_W_RESULT AS
SELECT rw.gid as rwgid, rw.name as rwname, rw.type as rwtype, w.gid as wgid, w.name as wname, w.type as wtype, 
ST_COLLECTIONEXTRACT(ST_INTERSECTION(rww.geom, wrw.geom),1) as rw_w_geom, 
COUNT(DISTINCT rw.gid)                      
FROM riverswaterways w, rail;rail 
WHERE ST_INTERSECTS(w.geom, rw.geom) AND w.gid < rw.gid 
GROUP BY rw.gid,w.gid;

How can I combinegot this error: ERROR: missing FROM-clause entry for table "rw", that is clear to me, but how im suppose to call the queries and writeattributes of the output to a new created table(layer) to work with this query? If I eliminate rw. from the attributes its says is ambiguous.

Disclamer: thank you all for correction my initial query, I realize I didnt write it right in the question. For those who voted against my question... really? this is GIS TOO!

Really basic here but cant find a proper solution.

I create a query in PostGIS using 'where' clause, and with that a table. now I want to use those attributes to create a intersection with other table... but I don't know how to call the attributes, because is always asking for the original table and like that it will skip the query

First query to get Rail features:

CREATE TABLE RAIL AS
SELECT rw.gid, rw.name, rw.type
FROM railways rw
WHERE "type" = 'rail';

And query to get rail features intersecting with rivers:

select rw.gid, rw.name, rw.type, w.name, w.type
(ST_INTERSECTION(rw.geom, w.geom)
FROM rivers w, rail;

How can I combine the queries and write the output to a new table?

Really basic here but cant find a proper solution.

I create a query in PostGIS using 'where' clause, and with that a table. now I want to use those attributes to create a intersection with other table... but I don't know how to call the attributes, because is always asking for the original table and like that it will skip the query

First query to get Rail features:

CREATE TABLE RAIL AS
SELECT rw.gid, rw.name, rw.type, rw.geom
FROM railways rw
WHERE "type" = 'rail';

Here I have my new table (layer in qgis) with only the type "rails". NOw when I want to do the intersection with rivers table (layer):

CREATE TABLE RW_W_RESULT AS
SELECT rw.gid as rwgid, rw.name as rwname, rw.type as rwtype, w.gid as wgid, w.name as wname, w.type as wtype, 
ST_COLLECTIONEXTRACT(ST_INTERSECTION(w.geom, rw.geom),1) as rw_w_geom, 
COUNT(DISTINCT rw.gid)                      
FROM waterways w, rail 
WHERE ST_INTERSECTS(w.geom, rw.geom) AND w.gid < rw.gid 
GROUP BY rw.gid,w.gid;

I got this error: ERROR: missing FROM-clause entry for table "rw", that is clear to me, but how im suppose to call the attributes of the new created table(layer) to work with this query? If I eliminate rw. from the attributes its says is ambiguous.

Disclamer: thank you all for correction my initial query, I realize I didnt write it right in the question. For those who voted against my question... really? this is GIS TOO!

added more details to include the use of multiple queries and altered the title to include the use of a spatial function.
Source Link
Inactivated Account
  • 18.9k
  • 5
  • 70
  • 114

Table result Create table from query postgisresults of ST_Intersection queries in PostGIS

Really basic here but cant find a proper solution.

I create a query in PostGIS using 'where' clause, and with that a table. now I want to use those attributes to create a intersection with other table... but I don't know how to call the attributes, because is always asking for the original table and like that it will skip the query

Here it isFirst query to get Rail features:

CREATE TABLE RAIL AS
SELECT rw.gid, rw.name, rw.type
FROM railways rw
WHERE "type" = 'rail';

and the the intersectionAnd query to get rail features intersecting with rivers:

select rw.gid, rw.name, rw.type, w.name, w.type
(ST_INTERSECTION(rw.geom, w.geom)
FROM rivers w, rail;

How can I combine the queries and write the output to a new table?

Table result from query postgis

Really basic here but cant find a proper solution.

I create a query in PostGIS using 'where' clause, and with that a table. now I want to use those attributes to create a intersection with other table... but I don't know how to call the attributes, because is always asking for the original table and like that it will skip the query

Here it is

CREATE TABLE RAIL AS
SELECT rw.gid, rw.name, rw.type
FROM railways rw
WHERE "type" = 'rail';

and the the intersection with rivers

select rw.gid, rw.name, rw.type, w.name, w.type
(ST_INTERSECTION(rw.geom, w.geom)
FROM rivers w, rail;

Create table from results of ST_Intersection queries in PostGIS

Really basic here but cant find a proper solution.

I create a query in PostGIS using 'where' clause, and with that a table. now I want to use those attributes to create a intersection with other table... but I don't know how to call the attributes, because is always asking for the original table and like that it will skip the query

First query to get Rail features:

CREATE TABLE RAIL AS
SELECT rw.gid, rw.name, rw.type
FROM railways rw
WHERE "type" = 'rail';

And query to get rail features intersecting with rivers:

select rw.gid, rw.name, rw.type, w.name, w.type
(ST_INTERSECTION(rw.geom, w.geom)
FROM rivers w, rail;

How can I combine the queries and write the output to a new table?

Post Closed as "Not suitable for this site" by Vince, alphabetasoup, Fezter
corrected spelling, fixed grammar, improved formatting
Source Link
whyzar
  • 12.1k
  • 23
  • 39
  • 72
Loading
Source Link
Loading