2

How do I update the CRS for a table geometry column?

I have created my db and table with

spatialite_tool -i -shp London_Ward_CityMerged -d london_boundaries.sqlite -t Barnet -g geometry -c utf-8 -s 27700

Then removed a few rows with

delete from Barnet where DISTRICT != "Barnet";

When I try to update the geometry column with

update Barnet set geometry = ST_Transform(geometry, 4326);

I get the error

Error: Barnet.geometry violates Geometry constraint [geom-type or SRID not allowed]
3
  • 1
    Your column is constrained to be 27700 so you can't store 4326 geom in it
    – Ian Turton
    Sep 4, 2022 at 13:31
  • Ah, got it. I created a new column first and then transformed. If you want to provide an answer I will accept it. Or I can just edit my question
    – Rojj
    Sep 4, 2022 at 13:38
  • 1
    Or you can write that as an answer yourself.
    – user30184
    Sep 5, 2022 at 7:57

1 Answer 1

2

Based on the comment I modified my code to create a geometry column first and then tranform the orignal column into the new one.

select AddGeometryColumn("Barnet", "GeometryLatLon", 4326, 'POLYGON', 'XY');
update Barnet set GeometryLatLon = ST_Transform(geometry, 4326);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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