Ask Your Question
0

What steps can I take to rectify the issue of a corrupted geometry column caused by altering the Postgis Schema Name in QGIS?

asked 2023-01-08 11:00:00 +0000

scrum gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2021-07-28 09:00:00 +0000

qstack gravatar image

Here are the steps you can take to rectify the issue of a corrupted geometry column caused by altering the Postgis Schema Name in QGIS:

  1. Connect to your PostGIS database using a SQL client, such as pgAdmin or psql.

  2. Create a backup of your database in case anything goes wrong during the following steps.

  3. Run the following SQL script to update the schema name of your spatial tables:

    ALTER TABLE <schema_name>.<table_name> SET SCHEMA <new_schema_name>;
    
  4. Run the following SQL script to update the SRID of your spatial tables:

    SELECT UpdateGeometrySRID('<new_schema_name>', '<table_name>', 'geom', <new_srid>);
    

    Replace <new_srid> with the SRID that you want to use for your geometry column.

  5. If you have any views that reference your spatial tables, update their definitions to use the new schema name:

    CREATE OR REPLACE VIEW <new_schema_name>.<view_name> AS
    SELECT <columns>
    FROM <new_schema_name>.<table_name>
    WHERE <condition>;
    

    Replace <columns> with the columns that you want to select and <condition> with the condition that you want to use to filter the rows.

  6. Finally, re-add the spatial tables to QGIS and verify that the geometry column is now working correctly.

If you are not comfortable performing these steps yourself, it may be best to seek the assistance of a qualified database administrator or GIS professional.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2023-01-08 11:00:00 +0000

Seen: 10 times

Last updated: Jul 28 '21