[postgis-users] Accessing points externally

Mike Toews mwtoews at sfu.ca
Tue Aug 18 09:50:53 PDT 2009


Hi Facundo,

In PostgreSQL, you can use database VIEWS to see tables with X and Y 
coordinates. This view would be defined using the st_x and st_y functions.

CREATE OR REPLACE VIEW my_view AS
 SELECT gid, identifier, st_x(geometry) AS x, st_y(geometry) AS y
   FROM my_table;

Now you can view this table MS Access and other programs, and the st_x() 
and st_y() functions are hidden to the end-user. (This table is 
"read-only", but to make this table editable so you can modify the x,y 
coordinates directly, a few more steps are required).

Using the GEOMETRY type to store point locations has endless 
applications, such as being able to use spatial SQL queries (find all 
the red dots in the green polygons), reprojection into different 
coordinate systems, and you can visualize and edit the data in GIS 
applications (uDig, QGIS, AutoCAD Map3D, etc.). It is a worthwhile 
investment if your work relies on anything spatial.

-Mike

Facundo Ciccioli wrote:
> Hi. Here at work we are thinking of using PostGIS to store points
> indicating locations (in the future we'll need polygons as well). I
> was wondering if there is a way to, once I get the Point object stored
> in the database (with something like "SELECT my_point_field FROM
> my_table;"), query the data returned to obtain the x and y
> coordinates. I read the "Simple features" defined by OpenGIS, and if I
> understood correctly, it should NOT be possible what I want to do. The
> standard states that the Geometry object's attributes should only be
> accessed via SQL (in my case it would go "SELECT st_x(my_point_field),
> st_y(my_point_field) FROM my_table;"). But as I said: *if I understood
> correctly* :P.
>
> So, is there a way to do this? I guess that what I'm
> looking for is a library or something with the functions that access
> the internal format of the points as stored in the database, or the
> specifications of such format so that we could write a library like
> that.
>
> Thanks in advance.
> FaQ
> _______________________________________________
> postgis-users mailing list
> postgis-users at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users
>   




More information about the postgis-users mailing list