1

I have data stored in PostGIS. When I view its properties in QGIS, it says:

SRS: EPSG:4326 - WGS 84

However, when I want retrieve the SRID value directly using the Find_SRID function, it returns 0. And by looking at the data, SRID is really 0 in PostGIS.

Query:

select * from geometry_columns;

Returns:

f_table_name | f_geometry_column | coord_dimension | srid |  type

-----------------+------------------+--------------+-------------------

vector       | wkb_geometry      |               2 |    0 | POINT

vector       | wkb_geometry      |               2 |    0 | POINT

buff_out     | wkb_geometry      |               2 |    0 | POLYGON

buff_out     | wkb_geometry      |               2 |    0 | POLYGON

Question: Why is SRID for the same data different in QGIS and in PostGIS? How do I get the correct SRID value from PostGIS?

I am using PostGIS 9.5.

  • 6
    0 in PostGIS means no SRID given. In your QGIS probably the WGS84 is the default projection. The default projection is used in QGIS when the SRID is not given. You should define the correct SRID in PostGIS and QGIS will use the same. – Zoltan Jul 22 '18 at 12:52
  • 1
    Instead of querying the geometry_columns table, can you see what ST_SRID(geom) reports from the table itself? – DPSSpatial Jul 22 '18 at 18:03
  • i wanted to try ST_SRID() too but I dont understand what should I pass it as the (geom) argument.. – Jan Pisl Jul 22 '18 at 23:32
  • 1
    @JanPisl throughout the PostGIS docs and Q/A, geom refers to the identifier/name of the data's geometry column; it's wkb_geometry in this case, e.g. SELECT ST_SRID(wkb_geometry) FROM <your_table> – geozelot Jul 23 '18 at 7:03
1

You could try the following (as an example) if you still have issues.

SELECT UpdateGeometrySRID('vector','wkb_geometry',4326);

In QGIS when you add layers to canvas you only set the SRID for that proyect's layers

| improve this answer | |
0

To update the SRID in PostgreSQL/PostGIS you can run:

ALTER TABLE vector ALTER COLUMN wkb_geometry TYPE geometry(POINT,4326) using ST_SetSRID(wkb_geometry, 4326);

This does the exact same thing as YPCA's answer, but is standard SQL.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.