[postgis-users] Adding Spatial Index to Existing Table

Gregory S. Williamson gsw at globexplorer.com
Fri Dec 29 20:32:38 PST 2006


The geometry type can handle any type of geometry. Sometimes that is what you want, but usually I find it better to specify the type (or types) to be allowed).

If you know the column must be point data, you can declare the geometry type to be POINT which will protect you from accidently inserting other geometries (from one of our table definitions):
<...>
    "cntr_chk" CHECK (geometrytype(the_cntr) = 'POINT'::text OR the_cntr IS NULL)
    "$2" CHECK (geometrytype(the_geom) = 'MULTIPOLYGON'::text OR the_geom IS NULL)
    "$1" CHECK (srid(the_geom) = 4326)
    "$3" CHECK (srid(the_cntr) = 4326)
<...>
(Sloppy naming conventions, granted)

This lets us keep from putting the wrong geometries into the respective columns.

HTH,

Greg Williamson
DBA
GlobeXplorer

-----Original Message-----
From:	postgis-users-bounces at postgis.refractions.net on behalf of Adam
Sent:	Fri 12/29/2006 8:23 PM
To:	PostGIS Users Discussion
Cc:	
Subject:	Re: [postgis-users] Adding Spatial Index to Existing Table

And when I add the new "location" column, do I add it as type "geometry"?
  ----- Original Message ----- 
  From: Brad Ediger 
  To: PostGIS Users Discussion 
  Sent: Friday, December 29, 2006 1:18 PM
  Subject: Re: [postgis-users] Adding Spatial Index to Existing Table


  If your lat/longs are WGS84, you should be able to say:



  UPDATE table SET location = SetSRID(MakePoint(Long,Lat), 4326);


  That should update all points in one statement, and set the proper SRID.


  Brad


  On Dec 29, 2006, at 1:08 PM, Adam wrote:


    This is my first try at adding spatial to my table.  Currently I have a 'Lat' and 'Long' columns that have my Latitiude and Longitude.

    Do I need to add another column named 'Location' and insert each rows 'Lat' and 'Long' into the corresponding 'Location' row by doing:  "INSERT INTO table ( Location ) VALUES ( GeometryFromText('Point xx.xxx yy.yyyy', 4326) )" ?  This will assume WGS 84 datum.

    Is this right?
    _______________________________________________
    postgis-users mailing list
    postgis-users at postgis.refractions.net
    http://postgis.refractions.net/mailman/listinfo/postgis-users




------------------------------------------------------------------------------


  _______________________________________________
  postgis-users mailing list
  postgis-users at postgis.refractions.net
  http://postgis.refractions.net/mailman/listinfo/postgis-users



-------------------------------------------------------
Click link below if it is SPAM gsw at globexplorer.com
"https://mailscanner.globexplorer.com/dspam/dspam.cgi?signatureID=4595e91b129751539520699&user=gsw@globexplorer.com&retrain=spam&template=history&history_page=1"
!DSPAM:4595e91b129751539520699!
-------------------------------------------------------






More information about the postgis-users mailing list