[postgis-users] Questions about using SRID not -1

Kevin Neufeld kneufeld at refractions.net
Thu Jan 21 11:39:18 PST 2010


Hi Oscar,

Yes, this is definitely possible.  Using your example...

CREATE TABLE mydistance (the_geom geometry, the_name text);
\d mydistance
     Table "public.mydistance"
   Column  |   Type   | Modifiers
----------+----------+-----------
  the_geom | geometry |
  the_name | text     |


-- Insert without using an explicit SRID
INSERT INTO mydistance (the_geom, the_name)
    VALUES (ST_GeomFromText('POINT(-58.0 0.0)'),'Punto 1-1');

SELECT ST_SRID(the_geom), ST_AsText(the_geom) FROM mydistance ;
  st_srid |  st_astext
---------+--------------
       -1 | POINT(-58 0)
(1 row)


-- specify the srid of all the geometries
UPDATE mydistance SET the_geom = ST_SetSRID(the_geom, 4326);

SELECT ST_SRID(the_geom), ST_AsText(the_geom) FROM mydistance ;
  st_srid |  st_astext
---------+--------------
     4326 | POINT(-58 0)
(1 row)


-- update geometry_columns (inserts appropriate row and adds appropriate constraints to your spatial table)
SELECT populate_geometry_columns('mydistance'::regclass);
\d mydistance
     Table "public.mydistance"
   Column  |   Type   | Modifiers
----------+----------+-----------
  the_geom | geometry |
  the_name | text     |
Check constraints:
     "enforce_dims_the_geom" CHECK (ndims(the_geom) = 2)
     "enforce_geotype_the_geom" CHECK (geometrytype(the_geom) = 'POINT'::text OR the_geom IS NULL)
     "enforce_srid_the_geom" CHECK (srid(the_geom) = 4326)

SELECT * FROM geometry_columns WHERE f_table_name = 'mydistance';
  f_table_catalog | f_table_schema | f_table_name | f_geometry_column | coord_dimension | srid | type
-----------------+----------------+--------------+-------------------+-----------------+------+-------
                  | public         | mydistance   | the_geom          |               2 | 4326 | POINT
(1 row)


Does this help?
Cheers,
Kevin

On 1/21/2010 11:08 AM, Oscar Zamudio wrote:
> I already stated that this is only an experiment trying to solve the problem because my customer already loaded a
> lot of data WITHOUT expliciting SRID reference..... I mean,
>
> INSERT INTO mydistance (the_geom, the_name) VALUES (ST_GeomFromText('POINT(-58.0 0.0)',4326),'Punto 1-1');
>
> Is a step without SRID value that was taken years ago on their database. I'm trying to avoid the reloading process
> and taking in account that there are some functions that probably can make the task,,, I began to explore them
> without success up to now.
>
> Regards,
>



More information about the postgis-users mailing list