[postgis-users] extent of properties within a specified distance
Obe, Regina
robe.dnd at cityofboston.gov
Wed May 21 06:13:55 PDT 2008
That question would probably be better to ask in the mapserver list.
The scale bar in mapserver is dependent on a number of things. Which
the following come to mind at the moment
1) What do you have your map projection init set to for the map. I
presume you have something like
MAP ...
PROJECTION
"init=epsg:27700"
END
epsg:27700 has to be defined in your proj file and if it isn't you have
to put the whole proj4text in projection or add it to your file - which
my mind escapes me how to do that. I think you can pretty much copy the
proj4text from the spatial_ref_sys
2) Your SCALEBAR section must say meters - something like
SCALEBAR
STATUS embed
INTERVALS 3
SIZE 200 2
COLOR 0 0 0
OUTLINECOLOR 0 0 0
UNITS meters
LABEL
COLOR 0 0 0
SIZE small
END
TRANSPARENT ON
END
hope that helps,
Regina
________________________________
From: postgis-users-bounces at postgis.refractions.net
[mailto:postgis-users-bounces at postgis.refractions.net] On Behalf Of User
Map
Sent: Wednesday, May 21, 2008 8:27 AM
To: PostGIS Users Discussion
Subject: Re: [postgis-users] extent of properties within a specified
distance
hi there,
thanks for the immediate reply. i have tried what you have suggested,
and its now taking no more longer time spans :) but i dont know how it
is calculating the distance, because the extent returned by the query
when used in the mapfile for mapserver with a scalebar, it is giving
much larger area of about 800m in total, which should be about 100 m in
actual as defined in the query.
i have this query
________________________________________________________________________
SELECT ST_Extent(geom) as ext, count
(*),Max(Distance(geom,GeomFromText('POINT(530525.056494402
191742.597993273)',27700))) as max_dist
FROM tarea
WHERE ST_DWithin(geom,GeomFromText('POINT(530525.056494402
191742.597993273)',27700), 50)
________________________________________________________________________
__
POINT(530525.056494402 191742.597993273) is got from
AsText(Centroid(geom))
i have OSGB36 data, and srid= 27700, which i have set in the query.
the extent returned is much larger. but the max_dist is returning 49.5,
which is fine.
do you know why it is not matching the scalebar in the mapserver. does
the mapserver scalebar works differently then the Distance query.
any help will be appriciated
regards
----- Original Message ----
From: "Obe, Regina" <robe.dnd at cityofboston.gov>
To: PostGIS Users Discussion <postgis-users at postgis.refractions.net>
Sent: Wednesday, May 21, 2008 11:38:57 AM
Subject: RE: [postgis-users] extent of properties within a specified
distance
Have you tried using ST_DWithin(...) ?
- even with Within (neither Distance nor Within use spatial indexes so
you are essentially always doing a table scan. You would still need an
&& for those to make them use indexes. So try:
SELECT ST_Extent(geom) as ext, Max(ST_Distance(geom, '<center of
polygon>')) as max_dist
FROM tarea
WHERE ST_DWithin(geom,'<center of polygon>', 50);
If you are using an older version of Postgis that doesn't have the ST_
(e.g. pre 1.3)
Do the following instead
SELECT Extent(geom) as ext, Max(Distance(geom, '<center of polygon>'))
as max_dist
FROM tarea
WHERE geom && Expand('<center of polygon>',50) AND Distance(geom,
'<center of polygon>') < 50;
Hope that helps,
Regina
________________________________
From: postgis-users-bounces at postgis.refractions.net
[mailto:postgis-users-bounces at postgis.refractions.net] On Behalf Of User
Map
Sent: Wednesday, May 21, 2008 5:19 AM
To: PostGIS Users Discussion
Subject: Re: [postgis-users] extent of properties within a specified
distance
hi,
thanks, but the problem is still there, the time Distance() query is
taking. the concept behind using within() is only to minimize the number
of time the distance function executes. it works ok without using
within() also, but the time is still much longer. is there any way to
minimize the time it is taking to perform distance(), or any other way
to do the same task without using distance().
regards.
----- Original Message ----
From: Andy Anderson <aanderson at amherst.edu>
To: PostGIS Users Discussion <postgis-users at postgis.refractions.net>
Sent: Tuesday, May 20, 2008 10:09:27 PM
Subject: Re: [postgis-users] extent of properties within a specified
distance
On May 19, 2008, at 5:01 AM, User Map wrote:
hi,
thanks for reply. i think i have to clarify my problem a bit
more. i want to get the records from my table within a specified
distance for e.g 50 meters. For this i have to calculate the extent
first to get the image in mapserver. what i have is just a polygon geom,
which area as you know can vary from property to property. i dont want
to take into account the area/distance the property holds, but a center
point for that polygon, so to calculate the distance equally on each
side of that point, and then calculate the extent of those records, for
the image to be generated. what i have done uptil now is:
SELECT extent(geom),max(Distance('<center of polygon>',geom))as
distance
from tarea
where within(geom,'<expand(geom,50)from the given geom>')
and Distance('<center of polygon>',geom)<=50
but this query is taking about 25-26 mins which is quite a large
time span. and also when i get the results and on showing through the
map server, the scale bar is not matching, i mean it has to show a 100
meter bar scale, but, it is showing more then 100 meters on the
scalebar, about 192 or so.
A couple of thoughts, upon which the more experienced may correct or
elaborate:
1) It looks to me like you are performing a duplicate calculation. I'm
not sure if Postgres is smart enough to avoid this by itself, but just
in case you should take advantage of a subexpression to perform the
calculation once for each geom:
SELECT extent(geom), distance from (SELECT geom, Distance('<center of
polygon>', geom)) from tarea) as tdistance where distance <= 50.
2) Seems like
within(geom,'<expand(geom,50)from the given geom>')
is unnecessary, it will always be true. Or do you mean something
different than the simpler form:
within(geom, expand(geom,50))
-- Andy
________________________________
The substance of this message, including any attachments, may be
confidential, legally privileged and/or exempt from disclosure pursuant
to Massachusetts law. It is intended solely for the addressee. If you
received this in error, please contact the sender and delete the
material from any computer.
________________________________
Help make the earth a greener place. If at all possible resist printing
this email and join us in saving paper.
-----------------------------------------
The substance of this message, including any attachments, may be
confidential, legally privileged and/or exempt from disclosure
pursuant to Massachusetts law. It is intended
solely for the addressee. If you received this in error, please
contact the sender and delete the material from any computer.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20080521/46b5b4b5/attachment.html>
More information about the postgis-users
mailing list