[postgis-users] 2 Simple Questions

Dylan Lorimer edylan at google.com
Thu Oct 5 00:31:04 PDT 2006


Hi,

Thanks for your help with these two simple questions.

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.

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;

Again, many thanks!
Cheers,
dylan



More information about the postgis-users mailing list