PostGIS st_makeline extra columns in resultproblem transforming pgr route to a line - unexpected extra lines from St_MakeLinePostGIS Group By ErrorOrder by geometry columnsCreate a “wide” table recording all overlaps between polygons in PostGISSt_ClosestPoint within St_MakeLine Query problemInsert geometry into new postgis table using python 2PostGIS: Update table with st_geometryfromtextpsycopg2 not working because column “geom” does not existPostGIS MakeLine issueCreate continuous line network using PostgreSQL
A word that means "blending into a community too much"
Why are trash cans referred to as "zafacón" in Puerto Rico?
Is it safe to change the harddrive power feature so that it never turns off?
sed + add word before string only if not exists
Why didn't Voldemort recognize that Dumbledore was affected by his curse?
Warning about needing "authorization" when booking ticket
How can I get an unreasonable manager to approve time off?
Why am I getting a strange double quote (“) in Open Office instead of the ordinary one (")?
Is it expected that a reader will skip parts of what you write?
Is White controlling this game?
CSV how to trim values to 2 places in multiple columns using UNIX
English word for "product of tinkering"
How to safely destroy (a large quantity of) valid checks?
If I leave the US through an airport, do I have to return through the same airport?
Can I use trees and other climbable objects to get on Tenser's Floating Disk?
Extreme flexible working hours: how to get to know people and activities?
Russian word for a male zebra
Who are the Missing Members of this Noble Family?
Print lines between start & end pattern, but if end pattern does not exist, don't print
ed command: Delete from line 1 until the first blank line
What is the maximum number of net attacks that one can make in a round?
Meaning of 'lose their grip on the groins of their followers'
Determining fair price for profitable mobile app business
How to communicate to my GM that not being allowed to use stealth isn't fun for me?
PostGIS st_makeline extra columns in result
problem transforming pgr route to a line - unexpected extra lines from St_MakeLinePostGIS Group By ErrorOrder by geometry columnsCreate a “wide” table recording all overlaps between polygons in PostGISSt_ClosestPoint within St_MakeLine Query problemInsert geometry into new postgis table using python 2PostGIS: Update table with st_geometryfromtextpsycopg2 not working because column “geom” does not existPostGIS MakeLine issueCreate continuous line network using PostgreSQL
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
From a table of point data, there are some groups of points that can define a line (cross sections of a water course). 'cross_section' is the name of the table with the point data, geometrypoint the column with the geometry. 'code_sequence_nr' is the column that specifies the point sequence, so it becomes a nice line.
To make lines from groups of point data I have the following query:
CREATE TABLE cross_section_lines AS
SELECT st_makeline(geometrypoint) as cross_section,
cross_section.profile_code,
cross_section.administrative_area_id,
FROM (SELECT geometrypoint, profile_code, administrative_area_id
FROM cross_section
ORDER BY code_sequence_nr) cross_section
GROUP BY cross_section.profile_code, cross_section.administrative_area_id;
Now I need more information than the columns used for grouping, but if I add a column like this:
CREATE TABLE cross_section_lines AS
SELECT st_makeline(geometrypoint) as cross_section,
cross_section.profile_code,
cross_section.administrative_area_id,
cross_section.profile_type_id
FROM (SELECT geometrypoint, profile_code, administrative_area_id
FROM cross_section
ORDER BY code_sequence_nr) cross_section
GROUP BY cross_section.profile_code, cross_section.administrative_area_id;
The following error occurs:
ProgrammingError: (psycopg2.errors.UndefinedColumn) column cross_section.profile_type_id does not exist
But that column is certainly there. Now how do I add the profile type (and other usefull columns) to the resulting table that is created?
python postgis postgresql
add a comment |
From a table of point data, there are some groups of points that can define a line (cross sections of a water course). 'cross_section' is the name of the table with the point data, geometrypoint the column with the geometry. 'code_sequence_nr' is the column that specifies the point sequence, so it becomes a nice line.
To make lines from groups of point data I have the following query:
CREATE TABLE cross_section_lines AS
SELECT st_makeline(geometrypoint) as cross_section,
cross_section.profile_code,
cross_section.administrative_area_id,
FROM (SELECT geometrypoint, profile_code, administrative_area_id
FROM cross_section
ORDER BY code_sequence_nr) cross_section
GROUP BY cross_section.profile_code, cross_section.administrative_area_id;
Now I need more information than the columns used for grouping, but if I add a column like this:
CREATE TABLE cross_section_lines AS
SELECT st_makeline(geometrypoint) as cross_section,
cross_section.profile_code,
cross_section.administrative_area_id,
cross_section.profile_type_id
FROM (SELECT geometrypoint, profile_code, administrative_area_id
FROM cross_section
ORDER BY code_sequence_nr) cross_section
GROUP BY cross_section.profile_code, cross_section.administrative_area_id;
The following error occurs:
ProgrammingError: (psycopg2.errors.UndefinedColumn) column cross_section.profile_type_id does not exist
But that column is certainly there. Now how do I add the profile type (and other usefull columns) to the resulting table that is created?
python postgis postgresql
add a comment |
From a table of point data, there are some groups of points that can define a line (cross sections of a water course). 'cross_section' is the name of the table with the point data, geometrypoint the column with the geometry. 'code_sequence_nr' is the column that specifies the point sequence, so it becomes a nice line.
To make lines from groups of point data I have the following query:
CREATE TABLE cross_section_lines AS
SELECT st_makeline(geometrypoint) as cross_section,
cross_section.profile_code,
cross_section.administrative_area_id,
FROM (SELECT geometrypoint, profile_code, administrative_area_id
FROM cross_section
ORDER BY code_sequence_nr) cross_section
GROUP BY cross_section.profile_code, cross_section.administrative_area_id;
Now I need more information than the columns used for grouping, but if I add a column like this:
CREATE TABLE cross_section_lines AS
SELECT st_makeline(geometrypoint) as cross_section,
cross_section.profile_code,
cross_section.administrative_area_id,
cross_section.profile_type_id
FROM (SELECT geometrypoint, profile_code, administrative_area_id
FROM cross_section
ORDER BY code_sequence_nr) cross_section
GROUP BY cross_section.profile_code, cross_section.administrative_area_id;
The following error occurs:
ProgrammingError: (psycopg2.errors.UndefinedColumn) column cross_section.profile_type_id does not exist
But that column is certainly there. Now how do I add the profile type (and other usefull columns) to the resulting table that is created?
python postgis postgresql
From a table of point data, there are some groups of points that can define a line (cross sections of a water course). 'cross_section' is the name of the table with the point data, geometrypoint the column with the geometry. 'code_sequence_nr' is the column that specifies the point sequence, so it becomes a nice line.
To make lines from groups of point data I have the following query:
CREATE TABLE cross_section_lines AS
SELECT st_makeline(geometrypoint) as cross_section,
cross_section.profile_code,
cross_section.administrative_area_id,
FROM (SELECT geometrypoint, profile_code, administrative_area_id
FROM cross_section
ORDER BY code_sequence_nr) cross_section
GROUP BY cross_section.profile_code, cross_section.administrative_area_id;
Now I need more information than the columns used for grouping, but if I add a column like this:
CREATE TABLE cross_section_lines AS
SELECT st_makeline(geometrypoint) as cross_section,
cross_section.profile_code,
cross_section.administrative_area_id,
cross_section.profile_type_id
FROM (SELECT geometrypoint, profile_code, administrative_area_id
FROM cross_section
ORDER BY code_sequence_nr) cross_section
GROUP BY cross_section.profile_code, cross_section.administrative_area_id;
The following error occurs:
ProgrammingError: (psycopg2.errors.UndefinedColumn) column cross_section.profile_type_id does not exist
But that column is certainly there. Now how do I add the profile type (and other usefull columns) to the resulting table that is created?
python postgis postgresql
python postgis postgresql
edited May 23 at 11:15
JGH
14.4k21439
14.4k21439
asked May 23 at 9:47
Rob RikkenRob Rikken
183
183
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
Since you don't want the column in the GROUP BY section, you would have to aggregate the values of this column.
For instance, you can use STRING_AGG and possibly keep only the distinct values via the DISTINCT keyword.
You may have to cast the column to text as well
SELECT id, string_agg(distinct colA::text, ',')
FROM mytable
GROUP BY id;
I've decided to solve my problem in a different way, using multiple lines that are noded. But this answer solves my question well.
– Rob Rikken
May 23 at 14:24
add a comment |
profile_type_id is not in your select statement so the outer select can't see it. You need to try something like:
CREATE TABLE cross_section_lines AS
SELECT st_makeline(geometrypoint) as cross_section,
cross_section.profile_code,
cross_section.administrative_area_id,
cross_section.profile_type_id
FROM (SELECT geometrypoint, profile_code, administrative_area_id, profile_type_id
FROM cross_section
ORDER BY code_sequence_nr) cross_section
GROUP BY cross_section.profile_code, cross_section.administrative_area_id, cross_section.profile_type_id;
Unfortunately that didn't do the trick: ProgrammingError: (psycopg2.errors.GroupingError) column "cross_section.profile_type_id" must appear in the GROUP BY clause or be used in an aggregate function
– Rob Rikken
May 23 at 9:57
That would work for the profile code, because that's the same for the whole profile. But there are other columns that are not the same for the whole profile. In that case the line would be split in however many groups there are of that item.
– Rob Rikken
May 23 at 10:06
2
In this case, you need to add to your question the INPUT - structure of your source table and an example of its content and OUTPUT what you would like to get...
– Cyril
May 23 at 10:11
That's probably true. This is my first question on stackexchange, so I was not really sure how much information people need to figure out a question :) .
– Rob Rikken
May 23 at 12:12
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "79"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgis.stackexchange.com%2fquestions%2f323680%2fpostgis-st-makeline-extra-columns-in-result%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
Since you don't want the column in the GROUP BY section, you would have to aggregate the values of this column.
For instance, you can use STRING_AGG and possibly keep only the distinct values via the DISTINCT keyword.
You may have to cast the column to text as well
SELECT id, string_agg(distinct colA::text, ',')
FROM mytable
GROUP BY id;
I've decided to solve my problem in a different way, using multiple lines that are noded. But this answer solves my question well.
– Rob Rikken
May 23 at 14:24
add a comment |
Since you don't want the column in the GROUP BY section, you would have to aggregate the values of this column.
For instance, you can use STRING_AGG and possibly keep only the distinct values via the DISTINCT keyword.
You may have to cast the column to text as well
SELECT id, string_agg(distinct colA::text, ',')
FROM mytable
GROUP BY id;
I've decided to solve my problem in a different way, using multiple lines that are noded. But this answer solves my question well.
– Rob Rikken
May 23 at 14:24
add a comment |
Since you don't want the column in the GROUP BY section, you would have to aggregate the values of this column.
For instance, you can use STRING_AGG and possibly keep only the distinct values via the DISTINCT keyword.
You may have to cast the column to text as well
SELECT id, string_agg(distinct colA::text, ',')
FROM mytable
GROUP BY id;
Since you don't want the column in the GROUP BY section, you would have to aggregate the values of this column.
For instance, you can use STRING_AGG and possibly keep only the distinct values via the DISTINCT keyword.
You may have to cast the column to text as well
SELECT id, string_agg(distinct colA::text, ',')
FROM mytable
GROUP BY id;
answered May 23 at 11:14
JGHJGH
14.4k21439
14.4k21439
I've decided to solve my problem in a different way, using multiple lines that are noded. But this answer solves my question well.
– Rob Rikken
May 23 at 14:24
add a comment |
I've decided to solve my problem in a different way, using multiple lines that are noded. But this answer solves my question well.
– Rob Rikken
May 23 at 14:24
I've decided to solve my problem in a different way, using multiple lines that are noded. But this answer solves my question well.
– Rob Rikken
May 23 at 14:24
I've decided to solve my problem in a different way, using multiple lines that are noded. But this answer solves my question well.
– Rob Rikken
May 23 at 14:24
add a comment |
profile_type_id is not in your select statement so the outer select can't see it. You need to try something like:
CREATE TABLE cross_section_lines AS
SELECT st_makeline(geometrypoint) as cross_section,
cross_section.profile_code,
cross_section.administrative_area_id,
cross_section.profile_type_id
FROM (SELECT geometrypoint, profile_code, administrative_area_id, profile_type_id
FROM cross_section
ORDER BY code_sequence_nr) cross_section
GROUP BY cross_section.profile_code, cross_section.administrative_area_id, cross_section.profile_type_id;
Unfortunately that didn't do the trick: ProgrammingError: (psycopg2.errors.GroupingError) column "cross_section.profile_type_id" must appear in the GROUP BY clause or be used in an aggregate function
– Rob Rikken
May 23 at 9:57
That would work for the profile code, because that's the same for the whole profile. But there are other columns that are not the same for the whole profile. In that case the line would be split in however many groups there are of that item.
– Rob Rikken
May 23 at 10:06
2
In this case, you need to add to your question the INPUT - structure of your source table and an example of its content and OUTPUT what you would like to get...
– Cyril
May 23 at 10:11
That's probably true. This is my first question on stackexchange, so I was not really sure how much information people need to figure out a question :) .
– Rob Rikken
May 23 at 12:12
add a comment |
profile_type_id is not in your select statement so the outer select can't see it. You need to try something like:
CREATE TABLE cross_section_lines AS
SELECT st_makeline(geometrypoint) as cross_section,
cross_section.profile_code,
cross_section.administrative_area_id,
cross_section.profile_type_id
FROM (SELECT geometrypoint, profile_code, administrative_area_id, profile_type_id
FROM cross_section
ORDER BY code_sequence_nr) cross_section
GROUP BY cross_section.profile_code, cross_section.administrative_area_id, cross_section.profile_type_id;
Unfortunately that didn't do the trick: ProgrammingError: (psycopg2.errors.GroupingError) column "cross_section.profile_type_id" must appear in the GROUP BY clause or be used in an aggregate function
– Rob Rikken
May 23 at 9:57
That would work for the profile code, because that's the same for the whole profile. But there are other columns that are not the same for the whole profile. In that case the line would be split in however many groups there are of that item.
– Rob Rikken
May 23 at 10:06
2
In this case, you need to add to your question the INPUT - structure of your source table and an example of its content and OUTPUT what you would like to get...
– Cyril
May 23 at 10:11
That's probably true. This is my first question on stackexchange, so I was not really sure how much information people need to figure out a question :) .
– Rob Rikken
May 23 at 12:12
add a comment |
profile_type_id is not in your select statement so the outer select can't see it. You need to try something like:
CREATE TABLE cross_section_lines AS
SELECT st_makeline(geometrypoint) as cross_section,
cross_section.profile_code,
cross_section.administrative_area_id,
cross_section.profile_type_id
FROM (SELECT geometrypoint, profile_code, administrative_area_id, profile_type_id
FROM cross_section
ORDER BY code_sequence_nr) cross_section
GROUP BY cross_section.profile_code, cross_section.administrative_area_id, cross_section.profile_type_id;
profile_type_id is not in your select statement so the outer select can't see it. You need to try something like:
CREATE TABLE cross_section_lines AS
SELECT st_makeline(geometrypoint) as cross_section,
cross_section.profile_code,
cross_section.administrative_area_id,
cross_section.profile_type_id
FROM (SELECT geometrypoint, profile_code, administrative_area_id, profile_type_id
FROM cross_section
ORDER BY code_sequence_nr) cross_section
GROUP BY cross_section.profile_code, cross_section.administrative_area_id, cross_section.profile_type_id;
edited May 23 at 10:21
answered May 23 at 9:51
Ian Turton♦Ian Turton
51.3k548121
51.3k548121
Unfortunately that didn't do the trick: ProgrammingError: (psycopg2.errors.GroupingError) column "cross_section.profile_type_id" must appear in the GROUP BY clause or be used in an aggregate function
– Rob Rikken
May 23 at 9:57
That would work for the profile code, because that's the same for the whole profile. But there are other columns that are not the same for the whole profile. In that case the line would be split in however many groups there are of that item.
– Rob Rikken
May 23 at 10:06
2
In this case, you need to add to your question the INPUT - structure of your source table and an example of its content and OUTPUT what you would like to get...
– Cyril
May 23 at 10:11
That's probably true. This is my first question on stackexchange, so I was not really sure how much information people need to figure out a question :) .
– Rob Rikken
May 23 at 12:12
add a comment |
Unfortunately that didn't do the trick: ProgrammingError: (psycopg2.errors.GroupingError) column "cross_section.profile_type_id" must appear in the GROUP BY clause or be used in an aggregate function
– Rob Rikken
May 23 at 9:57
That would work for the profile code, because that's the same for the whole profile. But there are other columns that are not the same for the whole profile. In that case the line would be split in however many groups there are of that item.
– Rob Rikken
May 23 at 10:06
2
In this case, you need to add to your question the INPUT - structure of your source table and an example of its content and OUTPUT what you would like to get...
– Cyril
May 23 at 10:11
That's probably true. This is my first question on stackexchange, so I was not really sure how much information people need to figure out a question :) .
– Rob Rikken
May 23 at 12:12
Unfortunately that didn't do the trick: ProgrammingError: (psycopg2.errors.GroupingError) column "cross_section.profile_type_id" must appear in the GROUP BY clause or be used in an aggregate function
– Rob Rikken
May 23 at 9:57
Unfortunately that didn't do the trick: ProgrammingError: (psycopg2.errors.GroupingError) column "cross_section.profile_type_id" must appear in the GROUP BY clause or be used in an aggregate function
– Rob Rikken
May 23 at 9:57
That would work for the profile code, because that's the same for the whole profile. But there are other columns that are not the same for the whole profile. In that case the line would be split in however many groups there are of that item.
– Rob Rikken
May 23 at 10:06
That would work for the profile code, because that's the same for the whole profile. But there are other columns that are not the same for the whole profile. In that case the line would be split in however many groups there are of that item.
– Rob Rikken
May 23 at 10:06
2
2
In this case, you need to add to your question the INPUT - structure of your source table and an example of its content and OUTPUT what you would like to get...
– Cyril
May 23 at 10:11
In this case, you need to add to your question the INPUT - structure of your source table and an example of its content and OUTPUT what you would like to get...
– Cyril
May 23 at 10:11
That's probably true. This is my first question on stackexchange, so I was not really sure how much information people need to figure out a question :) .
– Rob Rikken
May 23 at 12:12
That's probably true. This is my first question on stackexchange, so I was not really sure how much information people need to figure out a question :) .
– Rob Rikken
May 23 at 12:12
add a comment |
Thanks for contributing an answer to Geographic Information Systems Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgis.stackexchange.com%2fquestions%2f323680%2fpostgis-st-makeline-extra-columns-in-result%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown