[postgis-users] 2 Simple Questions

Markus Schaber schabi at logix-tt.com
Thu Oct 5 03:47:37 PDT 2006


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



More information about the postgis-users mailing list