GIS4DEV / GIS4DEV.github.io

Open Source GIScience & GIS for Development
1 stars 12 forks source link

Add to Canvas #8

Closed sarahhaedrich closed 4 years ago

sarahhaedrich commented 4 years ago

Hi Joe,

I'm trying to make centroids of the county data from Lab09. Here is my query: CREATE TABLE centroids As SELECT *, st_centroid(geometry) FROM counties

I look at the table in the Database Manager and all the table information is there, including a column name labeled "st_centroid" with "POINT" data. When I add the data to the canvas however, all the column names go blank and no data is carried over. Do you know why this is happening?

Best, Sarah

josephholler commented 4 years ago

There's a few things you might try:

1) alias the st_centroid() column to a good column name (AS .... ) 2) choose a different table name. 'centroids' might conflict with function names... this is probably not the cause of the problem, but anyway choose a table name more specific to the content, e.g. county_centroids 3) there might be confusion from having two geometry columns (one polygon, one point), so try to be sure to get the new columns registered in geometry_columns table using the select populate_geometry_columns() function so that you can be certain which geometry type you're trying to visualize in QGIS. 4) one last thought: QGIS tends to remember the schema of a table from the first time it was added, so if you had previously made incorrect versions of 'centroids' and added them to the canvas, you might need to close out QGIS and re-open.

sarahhaedrich commented 4 years ago

Thank you, I got it to work.


From: josephholler notifications@github.com Sent: Sunday, December 8, 2019 7:05 PM To: GIS4DEV/GIS4DEV.github.io GIS4DEV.github.io@noreply.github.com Cc: Haedrich, Sarah Campbell (Sarah Haedrich) shaedrich@middlebury.edu; Author author@noreply.github.com Subject: Re: [GIS4DEV/GIS4DEV.github.io] Add to Canvas (#8)

There's a few things you might try:

  1. alias the st_centroid() column to a good column name (AS .... )
  2. choose a different table name. 'centroids' might conflict with function names... this is probably not the cause of the problem, but anyway choose a table name more specific to the content, e.g. county_centroids
  3. there might be confusion from having two geometry columns (one polygon, one point), so try to be sure to get the new columns registered in geometry_columns table using the select populate_geometry_columns() function so that you can be certain which geometry type you're trying to visualize in QGIS.
  4. one last thought: QGIS tends to remember the schema of a table from the first time it was added, so if you had previously made incorrect versions of 'centroids' and added them to the canvas, you might need to close out QGIS and re-open.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/GIS4DEV/GIS4DEV.github.io/issues/8?email_source=notifications&email_token=ANE5FSFXNTPHDKVTAPZRMKTQXWDV3A5CNFSM4JX6W4RKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEGHOQSQ#issuecomment-563013706, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ANE5FSBJVE2DAV6WOAS7DBLQXWDV3ANCNFSM4JX6W4RA.