[postgis-users] 2 Simple Questions

Brent Wood pcreso at pcreso.com
Thu Oct 5 16:12:02 PDT 2006



--- Dylan Lorimer <edylan at google.com> wrote:

> Hi,
> 
> Many thanks. That pretty much worked for getting that 3rd coordinate.
> Any idea if it is possible to get the results as a comma delimited
> values rather than the EWKT?

The below interactive commands work for me. Note cells1.the_geom is a column of
square polygons, so applying centroid gives me a point geometry. The force_3d &
X,Y,Z, functions return the values you want, while the \a \t \f , instructions
deliver CSV format. These also work on the psql command line as well as within
a session, but I'd implement as 
psql <db> -A -t -f "," -c "..." 


\t
\a
\f ,
select X(centroid(the_geom)), 
       Y(centroid(the_geom)), 
       Z(force_3d(centroid(the_geom)))
from cells1 limit 1;
52.0083,13.1577,0



Cheers,

  Brent Wood

 
> As for 'better', I thought I could pull this off using a join but
> couldn't figure it out. Is that possible?
> cheers,
> dylan
> 
> On 10/5/06, Markus Schaber <schabi at logix-tt.com> wrote:
> > Hi, Dylan,
> >
> > Dylan Lorimer wrote:
> >
> > > 1) Given a 2 dimensional point geometry, is there a way to get the
> > > AsText version of it but with a 0 inserted for the z value? To expound
> > > slightly, I've created a geom column to store city coordinates. I'd
> > > like to run typical spatial queries against the cities, but get in
> > > some cases get a 0 back for the non-existent z value. I thought
> > > 'force_3d' might do this; but it doesn't seem to.
> >
> > Try "asEWKT(force_3d(the_geom))".
> >
> > AsText currently cuts down to 2 dimensions due to the OpenGIS standard
> > being 2D.
> >
> > > 2) There's a better way to find all cities within some distance from a
> > > given city in my table that the following sub-select, right? It seems
> > > a bit clunky.
> > >
> > > SELECT city_name FROM gnis WHERE distance_sphere(the_geom, (SELECT
> > > the_geom FROM gnis WHERE city_name='San Francisco' AND
> > > country_code='US' AND sub_national_code='CA')) < 18046.7;
> >
> > What do you mean with "better"?
> >
> > Markus
> > --
> > Markus Schaber | Logical Tracking&Tracing International AG
> > Dipl. Inf.     | Software Development GIS
> >
> > Fight against software patents in Europe! www.ffii.org
> > www.nosoftwarepatents.org
> > _______________________________________________
> > postgis-users mailing list
> > postgis-users at postgis.refractions.net
> > http://postgis.refractions.net/mailman/listinfo/postgis-users
> >
> 
> 
> -- 
> E. Dylan Lorimer | Google Earth Enterprise
> 650.253.2459 (O) | 650.862.6810 (M) | 650.644.0182 (F)
> _______________________________________________
> 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