# [postgis-users] shp2pgsql: How are x,y-coordinates stored?

H.Lekin h.lekin at gmx.net
Wed Aug 9 07:54:32 PDT 2006

```> I simple terms the x,y coordinates are stored together in a big blob.
> Polylines and Polygons are stored in bigger blobs.  The secret to PostGIS is
> the blobs have a very specific form and there are lots of functions to do
> what you want.
> To prove it run the SQL command
>
> SELECT X(the_geom), Y(the_geom) from yourtablename

gistest=> select X(the_geom), Y(the_geom) from countryboundaries;
ERROR:  Argument to X() must be a point
# Same applies to GRASS command.

gistest=> select AsText (the_geom) from countryboundaries;
---snip---
MULTIPOLYGON(((3.71071599999999 50.380975,...,3.71071599999999 50.380975)))
(18 Zeilen)
# There are coordinates!

gistest=> select gid, isvalid(the_geom) from countryboundaries;
gid | isvalid
-----+---------
1 | t
2 | t
3 | t
---snip---
16 | t
17 | t
18 | t
(18 Zeilen)
# Description: Returns true if this geometry is valid.
# No idea what that is supposed to mean; at least things are valid.

gistest=> select Summary(the_geom) from countryboundaries;
---snip---
MultiPolygon[B] with 1 elements
Polygon[] with 1 rings
ring 0 has 161 points
(18 Zeilen)

gistest=> select extent(the_geom) from countryboundaries;
extent
--------------------------------------------------------------------------
BOX(3.71071577072144 45.2058982849121,17.1880855560303 57.1254005432129)
(1 Zeile)

What's wrong with the way I try to access coordinates?
>
> Where yourtablename is the name you specified.   You should get a table with
> the x,y coordinates of your data.
>
> The functions X() and Y() are PostGIS functions to get the x and y
> coordinates from a point stored in your table.  Apparently QGIS knows how to
> do this already from your e-mail but GRASS does not.  There are lots of GIS
> functions in PostGIS - that's why you were told to look at the documentation
> since nobody knows exactly what you want to do.

By the way, I have to admit that I don't even know this myself [yet].
Basically, I want to find out what somebody can do with open source GIS
tools. This is done on a new Debian installation (couldn't compile
PostGIS on Cygwin; in this respect the manual is rather jokey). I am my
own PostgreSQL admin as well as I'm trying to understand the GRASS
philosophy, if there really is one.
Please be patient, if I ask unprecise, a little foolish questions. I
really appreciate any help.

>                                                   I don't know what GRASS
> needs to have to import the data so I can't help you there.

I get the same error in GRASS, i.e. Argument to X() must be a point.
>
> Bruce Rindahl
Thanks a lot,
H.L.

```