change the reference system of a vector spatialite

37 views
Skip to first unread message

Roberto Montagnetti

unread,
Dec 3, 2016, 10:35:24 AM12/3/16
to SpatiaLite Users
I would change the reference system of a vector sqlite from 3004 to 4326
Can someone help me?

a.fu...@lqt.it

unread,
Dec 3, 2016, 11:30:41 AM12/3/16
to spatiali...@googlegroups.com
SELECT ST_Transform(geometry, 4326);

please RTFM,
Sandro

http://www.gaia-gis.it/gaia-sins/spatialite-sql-4.3.0.html#p15



Roberto Montagnetti

unread,
Dec 3, 2016, 11:46:45 AM12/3/16
to spatiali...@googlegroups.com
Grazie Sandro,
sono un amico di Luca Mandolesi.
Mi serve questa cosa per cambiare il SR dei layer sqlite del db di PyArchinit.
In pratica quindi basta applicare questa query al vettore?

Grazie ancora a presto.





--
You received this message because you are subscribed to a topic in the Google Groups "SpatiaLite Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/spatialite-users/0L05xn3mdwU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to spatialite-users+unsubscribe@googlegroups.com.
To post to this group, send email to spatialite-users@googlegroups.com.
Visit this group at https://groups.google.com/group/spatialite-users.
For more options, visit https://groups.google.com/d/optout.



--
Roberto Montagnetti

a.fu...@lqt.it

unread,
Dec 4, 2016, 4:09:02 AM12/4/16
to spatiali...@googlegroups.com
Roberto,

this is an international mailing list and posting in English
is strictly required. If you wish using the Italian language
you can eventually post your mails to gf...@lists.gfoss.it

This time I'll exceptionally reply to your latest mail,
but for the future remember that messages posted in any
other language except the English one will be simply
ignored.

A quick recall of the very basic and elementary principles
of SQL and Spatial SQL supported by SQLite + SpatiaLite:

a. data are always stored into some Table, i.e. into a
rectangular matrix presenting a variable number of
Rows and a fixed number of Columns.
In order to create a new Table you must specify
a list of Columns, and for each Column a name and
a data-type must be defined.
Geometry Columns are someway special, and require
to be created in a second time by specifying:
a1. a Geometry Class (e.g. Point or Polygon etc)
a2. a SRID (e.g. 3004, 32632, 4326 etc)
a3. Dimensions (e.g. XY, XYZ, XYM or XYZM)
A Geometry Column can never change its specific
attributes after being created; anyway you are
free to define two (or even more) Geometries for
the same Table.

b. ST_Transform() is the standard SQL function allowing
to re-project coordinates from a SRID to another.

c. SQL supports several mechanism allowing to copy values
from a Column to another and/or between two Tables.

Putting it all together:

1. you initially start with a Table presenting a Geometry
Column referencing SRID=3004
2a. you can add a second Geometry Column on the same
table referencing SRID=4326
2b. alternatively you can create a new Table presenting
the same Columns of the first one except in that this
time the Geometry Column will reference SRID=4326
3. after this you finally have to populate this new
Column (or Table) by copying data from the initial
Table and by applying an appropriate coordinate
transformation.

SQL snipper for case 2a
=======================
SELECT AddGeometryColumn('old_table', 'geom2', 4326, 'POINT', 'XY');
UPDATE old_table SET geom2 = ST_Transform(geom, 4326);


SQL snipper for case 2b
=======================
CREATE TABLE new_table (
... all column definitions, including PK and FK
constraints exactly as in old_table ...
);
SELECT AddGeometryColumn('new_table', 'geom', 4326, 'POINT', 'XY');
INSERT INTO new_table
SELECT ... columns list ..., ST_Transform(geom, 4326)
FROM old_table;


note: all the above informations are clearly and detailed
explained with many practical examples in the Cookbook:
http://www.gaia-gis.it/gaia-sins/spatialite-cookbook/index.html

reading the appropriate documentation before asking rather
trivial questions usually is the simpler and quicker way to
get all the informations you need.

bye Sandro
Reply all
Reply to author
Forward
0 new messages