Skip to main content
deleted 151 characters in body
Source Link
xunilk
  • 30.2k
  • 4
  • 43
  • 82

I have a table in a PostGIS database where with this query :

SELECT ST_CENTROID(pol8.geom) AS geom
FROM polygon8 AS pol8;

I got this:

                        geom                        
----------------------------------------------------
 0101000020647F00001AFAEAE428C91641E38374F8A8015141
 0101000020647F0000CB093A0DFA6C19416AFE29C6F8FB5041
 0101000020647F00002D325E7A35301C411F69C65A03F95041
 0101000020647F00007F7DBD9F049F1A419FDBBA0177E65041
 0101000020647F00005F7B5395D9CC18416E2BB23D61E35041
 0101000020647F000057844F356A0016417EA357E1A5EE5041
 0101000020647F0000CAFFD8471C1A18414B9D4A488DF95041
 0101000020647F000033426EF4B7B91C41C5D5530680E55041
(8 rows)

However, with this one I have a syntax error:

SELECT ST_AsText (ST_CENTROID(pol8.geom) AS geom
FROM polygon8 AS pol8);
ERROR:  syntax error at or near "AS"
LINE 1: SELECT ST_AsText (ST_CENTROID(pol8.geom) AS geom
                                                 ^

I only get the expected result with these additional queries (three in total):

CREATE TABLE centroids_pol8 AS (SELECT ST_CENTROID(pol8.geom) AS geom
FROM polygon8 AS pol8);

SELECT ST_AsText (geom) AS wkt 
FROM centroids_pol8;

                   wkt                    
------------------------------------------
 POINT(373322.223552616 4458147.88211152)
 POINT(416574.512916711 4452323.0963131)
 POINT(461837.369499954 4449293.41836002)
 POINT(436161.155996285 4430300.0270299)
 POINT(406326.395826271 4427140.96399961)
 POINT(360474.552061146 4438679.52097404)
 POINT(394887.070163724 4449845.1295541)
 POINT(470637.988701853 4429312.09886688)
(8 rows)

I tried out many syntax forms and I can not find out the solution for a query in only one path. Where is the issue in my second approach?

Editing Note:

The correct answer is:

SELECT ST_AsText (ST_CENTROID(pol8.geom)) AS geom
FROM polygon8 AS pol8;

Thanks to iant.

I have a table in a PostGIS database where with this query :

SELECT ST_CENTROID(pol8.geom) AS geom
FROM polygon8 AS pol8;

I got this:

                        geom                        
----------------------------------------------------
 0101000020647F00001AFAEAE428C91641E38374F8A8015141
 0101000020647F0000CB093A0DFA6C19416AFE29C6F8FB5041
 0101000020647F00002D325E7A35301C411F69C65A03F95041
 0101000020647F00007F7DBD9F049F1A419FDBBA0177E65041
 0101000020647F00005F7B5395D9CC18416E2BB23D61E35041
 0101000020647F000057844F356A0016417EA357E1A5EE5041
 0101000020647F0000CAFFD8471C1A18414B9D4A488DF95041
 0101000020647F000033426EF4B7B91C41C5D5530680E55041
(8 rows)

However, with this one I have a syntax error:

SELECT ST_AsText (ST_CENTROID(pol8.geom) AS geom
FROM polygon8 AS pol8);
ERROR:  syntax error at or near "AS"
LINE 1: SELECT ST_AsText (ST_CENTROID(pol8.geom) AS geom
                                                 ^

I only get the expected result with these additional queries (three in total):

CREATE TABLE centroids_pol8 AS (SELECT ST_CENTROID(pol8.geom) AS geom
FROM polygon8 AS pol8);

SELECT ST_AsText (geom) AS wkt 
FROM centroids_pol8;

                   wkt                    
------------------------------------------
 POINT(373322.223552616 4458147.88211152)
 POINT(416574.512916711 4452323.0963131)
 POINT(461837.369499954 4449293.41836002)
 POINT(436161.155996285 4430300.0270299)
 POINT(406326.395826271 4427140.96399961)
 POINT(360474.552061146 4438679.52097404)
 POINT(394887.070163724 4449845.1295541)
 POINT(470637.988701853 4429312.09886688)
(8 rows)

I tried out many syntax forms and I can not find out the solution for a query in only one path. Where is the issue in my second approach?

Editing Note:

The correct answer is:

SELECT ST_AsText (ST_CENTROID(pol8.geom)) AS geom
FROM polygon8 AS pol8;

Thanks to iant.

I have a table in a PostGIS database where with this query :

SELECT ST_CENTROID(pol8.geom) AS geom
FROM polygon8 AS pol8;

I got this:

                        geom                        
----------------------------------------------------
 0101000020647F00001AFAEAE428C91641E38374F8A8015141
 0101000020647F0000CB093A0DFA6C19416AFE29C6F8FB5041
 0101000020647F00002D325E7A35301C411F69C65A03F95041
 0101000020647F00007F7DBD9F049F1A419FDBBA0177E65041
 0101000020647F00005F7B5395D9CC18416E2BB23D61E35041
 0101000020647F000057844F356A0016417EA357E1A5EE5041
 0101000020647F0000CAFFD8471C1A18414B9D4A488DF95041
 0101000020647F000033426EF4B7B91C41C5D5530680E55041
(8 rows)

However, with this one I have a syntax error:

SELECT ST_AsText (ST_CENTROID(pol8.geom) AS geom
FROM polygon8 AS pol8);
ERROR:  syntax error at or near "AS"
LINE 1: SELECT ST_AsText (ST_CENTROID(pol8.geom) AS geom
                                                 ^

I only get the expected result with these additional queries (three in total):

CREATE TABLE centroids_pol8 AS (SELECT ST_CENTROID(pol8.geom) AS geom
FROM polygon8 AS pol8);

SELECT ST_AsText (geom) AS wkt 
FROM centroids_pol8;

                   wkt                    
------------------------------------------
 POINT(373322.223552616 4458147.88211152)
 POINT(416574.512916711 4452323.0963131)
 POINT(461837.369499954 4449293.41836002)
 POINT(436161.155996285 4430300.0270299)
 POINT(406326.395826271 4427140.96399961)
 POINT(360474.552061146 4438679.52097404)
 POINT(394887.070163724 4449845.1295541)
 POINT(470637.988701853 4429312.09886688)
(8 rows)

I tried out many syntax forms and I can not find out the solution for a query in only one path. Where is the issue in my second approach?

added 153 characters in body
Source Link
xunilk
  • 30.2k
  • 4
  • 43
  • 82

I have a table in a PostGIS database where with this query :

SELECT ST_CENTROID(pol8.geom) AS geom
FROM polygon8 AS pol8;

I got this:

                        geom                        
----------------------------------------------------
 0101000020647F00001AFAEAE428C91641E38374F8A8015141
 0101000020647F0000CB093A0DFA6C19416AFE29C6F8FB5041
 0101000020647F00002D325E7A35301C411F69C65A03F95041
 0101000020647F00007F7DBD9F049F1A419FDBBA0177E65041
 0101000020647F00005F7B5395D9CC18416E2BB23D61E35041
 0101000020647F000057844F356A0016417EA357E1A5EE5041
 0101000020647F0000CAFFD8471C1A18414B9D4A488DF95041
 0101000020647F000033426EF4B7B91C41C5D5530680E55041
(8 rows)

However, with this one I have a syntax error:

SELECT ST_AsText (ST_CENTROID(pol8.geom) AS geom
FROM polygon8 AS pol8);
ERROR:  syntax error at or near "AS"
LINE 1: SELECT ST_AsText (ST_CENTROID(pol8.geom) AS geom
                                                 ^

I only get the expected result with these additional queries (three in total):

CREATE TABLE centroids_pol8 AS (SELECT ST_CENTROID(pol8.geom) AS geom
FROM polygon8 AS pol8);

SELECT ST_AsText (geom) AS wkt 
FROM centroids_pol8;

                   wkt                    
------------------------------------------
 POINT(373322.223552616 4458147.88211152)
 POINT(416574.512916711 4452323.0963131)
 POINT(461837.369499954 4449293.41836002)
 POINT(436161.155996285 4430300.0270299)
 POINT(406326.395826271 4427140.96399961)
 POINT(360474.552061146 4438679.52097404)
 POINT(394887.070163724 4449845.1295541)
 POINT(470637.988701853 4429312.09886688)
(8 rows)

I tried out many syntax forms and I can not find out the solution for a query in only one path. Where is the issue in my second approach?

Editing Note:

The correct answer is:

SELECT ST_AsText (ST_CENTROID(pol8.geom)) AS geom
FROM polygon8 AS pol8;

Thanks to iant.

I have a table in a PostGIS database where with this query :

SELECT ST_CENTROID(pol8.geom) AS geom
FROM polygon8 AS pol8;

I got this:

                        geom                        
----------------------------------------------------
 0101000020647F00001AFAEAE428C91641E38374F8A8015141
 0101000020647F0000CB093A0DFA6C19416AFE29C6F8FB5041
 0101000020647F00002D325E7A35301C411F69C65A03F95041
 0101000020647F00007F7DBD9F049F1A419FDBBA0177E65041
 0101000020647F00005F7B5395D9CC18416E2BB23D61E35041
 0101000020647F000057844F356A0016417EA357E1A5EE5041
 0101000020647F0000CAFFD8471C1A18414B9D4A488DF95041
 0101000020647F000033426EF4B7B91C41C5D5530680E55041
(8 rows)

However, with this one I have a syntax error:

SELECT ST_AsText (ST_CENTROID(pol8.geom) AS geom
FROM polygon8 AS pol8);
ERROR:  syntax error at or near "AS"
LINE 1: SELECT ST_AsText (ST_CENTROID(pol8.geom) AS geom
                                                 ^

I only get the expected result with these additional queries (three in total):

CREATE TABLE centroids_pol8 AS (SELECT ST_CENTROID(pol8.geom) AS geom
FROM polygon8 AS pol8);

SELECT ST_AsText (geom) AS wkt 
FROM centroids_pol8;

                   wkt                    
------------------------------------------
 POINT(373322.223552616 4458147.88211152)
 POINT(416574.512916711 4452323.0963131)
 POINT(461837.369499954 4449293.41836002)
 POINT(436161.155996285 4430300.0270299)
 POINT(406326.395826271 4427140.96399961)
 POINT(360474.552061146 4438679.52097404)
 POINT(394887.070163724 4449845.1295541)
 POINT(470637.988701853 4429312.09886688)
(8 rows)

I tried out many syntax forms and I can not find out the solution for a query in only one path. Where is the issue in my second approach?

I have a table in a PostGIS database where with this query :

SELECT ST_CENTROID(pol8.geom) AS geom
FROM polygon8 AS pol8;

I got this:

                        geom                        
----------------------------------------------------
 0101000020647F00001AFAEAE428C91641E38374F8A8015141
 0101000020647F0000CB093A0DFA6C19416AFE29C6F8FB5041
 0101000020647F00002D325E7A35301C411F69C65A03F95041
 0101000020647F00007F7DBD9F049F1A419FDBBA0177E65041
 0101000020647F00005F7B5395D9CC18416E2BB23D61E35041
 0101000020647F000057844F356A0016417EA357E1A5EE5041
 0101000020647F0000CAFFD8471C1A18414B9D4A488DF95041
 0101000020647F000033426EF4B7B91C41C5D5530680E55041
(8 rows)

However, with this one I have a syntax error:

SELECT ST_AsText (ST_CENTROID(pol8.geom) AS geom
FROM polygon8 AS pol8);
ERROR:  syntax error at or near "AS"
LINE 1: SELECT ST_AsText (ST_CENTROID(pol8.geom) AS geom
                                                 ^

I only get the expected result with these additional queries (three in total):

CREATE TABLE centroids_pol8 AS (SELECT ST_CENTROID(pol8.geom) AS geom
FROM polygon8 AS pol8);

SELECT ST_AsText (geom) AS wkt 
FROM centroids_pol8;

                   wkt                    
------------------------------------------
 POINT(373322.223552616 4458147.88211152)
 POINT(416574.512916711 4452323.0963131)
 POINT(461837.369499954 4449293.41836002)
 POINT(436161.155996285 4430300.0270299)
 POINT(406326.395826271 4427140.96399961)
 POINT(360474.552061146 4438679.52097404)
 POINT(394887.070163724 4449845.1295541)
 POINT(470637.988701853 4429312.09886688)
(8 rows)

I tried out many syntax forms and I can not find out the solution for a query in only one path. Where is the issue in my second approach?

Editing Note:

The correct answer is:

SELECT ST_AsText (ST_CENTROID(pol8.geom)) AS geom
FROM polygon8 AS pol8;

Thanks to iant.

Source Link
xunilk
  • 30.2k
  • 4
  • 43
  • 82

Syntax error in a query with ST_AsText and ST_CENTROID

I have a table in a PostGIS database where with this query :

SELECT ST_CENTROID(pol8.geom) AS geom
FROM polygon8 AS pol8;

I got this:

                        geom                        
----------------------------------------------------
 0101000020647F00001AFAEAE428C91641E38374F8A8015141
 0101000020647F0000CB093A0DFA6C19416AFE29C6F8FB5041
 0101000020647F00002D325E7A35301C411F69C65A03F95041
 0101000020647F00007F7DBD9F049F1A419FDBBA0177E65041
 0101000020647F00005F7B5395D9CC18416E2BB23D61E35041
 0101000020647F000057844F356A0016417EA357E1A5EE5041
 0101000020647F0000CAFFD8471C1A18414B9D4A488DF95041
 0101000020647F000033426EF4B7B91C41C5D5530680E55041
(8 rows)

However, with this one I have a syntax error:

SELECT ST_AsText (ST_CENTROID(pol8.geom) AS geom
FROM polygon8 AS pol8);
ERROR:  syntax error at or near "AS"
LINE 1: SELECT ST_AsText (ST_CENTROID(pol8.geom) AS geom
                                                 ^

I only get the expected result with these additional queries (three in total):

CREATE TABLE centroids_pol8 AS (SELECT ST_CENTROID(pol8.geom) AS geom
FROM polygon8 AS pol8);

SELECT ST_AsText (geom) AS wkt 
FROM centroids_pol8;

                   wkt                    
------------------------------------------
 POINT(373322.223552616 4458147.88211152)
 POINT(416574.512916711 4452323.0963131)
 POINT(461837.369499954 4449293.41836002)
 POINT(436161.155996285 4430300.0270299)
 POINT(406326.395826271 4427140.96399961)
 POINT(360474.552061146 4438679.52097404)
 POINT(394887.070163724 4449845.1295541)
 POINT(470637.988701853 4429312.09886688)
(8 rows)

I tried out many syntax forms and I can not find out the solution for a query in only one path. Where is the issue in my second approach?