<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
  <title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
awesome; using this function below to create a view works perfectly,
and the buffers render as nice circles everywhere:<br>
<blockquote> SELECT transform(buffer(transform(hospitals.the_geom,
utmzone(members.the_geom)), 25*1609), 4326) AS the_geom<br>
 FROM hospitals<br>
</blockquote>
<br>
thanks again,<br>
mike<br>
<br>
<a class="moz-txt-link-abbreviated" href="mailto:david.bitner@gmail.com">david.bitner@gmail.com</a> wrote:
<blockquote cite="mid4ECE59065E.0EB06D12TFSVIFTZ@gmail.com" type="cite">
  <pre wrap="">This function should work to return the correct UTM zone in WGS84 (unless I
messed something up quickly pulling this together -- verify before you use
it).

CREATE OR REPLACE FUNCTION utmzone(geometry)
  RETURNS integer AS
$BODY$
declare
geomgeog geometry;
zone int;
pref int;
begin
geomgeog:=transform($1,4326);
if (y(geomgeog))>0 then
  pref:=32600;
else
  pref:=32700;
end if;
zone:=floor((x(geomgeog)+180)/6)+1;
return zone+pref;
end;
$BODY$
  LANGUAGE 'plpgsql' VOLATILE;

On 4/2/07, David William Bitner <a class="moz-txt-link-rfc2396E" href="mailto:bitner@gyttja.org"><bitner@gyttja.org></a> wrote:
  </pre>
  <blockquote type="cite">
    <pre wrap="">If you're only concerned with 25 miles, you could use the method to
determine which UTM zone your data is in for your first hospital and then
use that for the calculation and buffer creation.  You could convert Pedro's
PHP script into PL/PGSQL to make it easy to work with in the db.

On 4/2/07, Michael Frumin <a class="moz-txt-link-rfc2396E" href="mailto:mfrumin@rpa.org"><mfrumin@rpa.org></a> wrote:
    </pre>
    <blockquote type="cite">
      <pre wrap=""> correct.  I wanted to calculate the buffer so that I can render a map
using GeoServer, which sits right on top of PostGIS, which would show the
first set of hospitals, the 25 mile radius, and the second set.

thanks,
mike

<a class="moz-txt-link-abbreviated" href="mailto:david.bitner@gmail.com">david.bitner@gmail.com</a> wrote:

It is a common mis-assumption that you need to do a buffer calculation.  To
do this type of analysis, all you need is the distance_sphere() calculation:
select *,distance_sphere(hospital1geom,hospitals2geom) from hospitals2 where

distance_sphere(hospital1geom,hospitals2geom)<25*1609 order by
distance_sphere(hospital1geom,hospitals2geom) asc;

Just add a limit 1 to the end if all you want is the closest.

No buffer necessary at all.



David


On 4/2/07, Michael Frumin <a class="moz-txt-link-rfc2396E" href="mailto:mfrumin@rpa.org"><mfrumin@rpa.org></a> <a class="moz-txt-link-rfc2396E" href="mailto:mfrumin@rpa.org"><mfrumin@rpa.org></a> wrote:

  Right, I should be more specific from the outset.  I did do some
searching thru the PostGIS archives, and didn't find the answer I was
looking for; is there a PostGIS FAQ somewhere?

As for my problem, my inputs are two sets of geocoded hospitals, and I

just want to be able to identify for each hospital in the first set, the
hospitals in the second set within approximately 25 miles.  I will the map
these sets, with a 25 mile buffer around the first set, using Geoserver.

So, distance and area are both somewhat important, heading not at all.
distance_sphere(oid), sounds good for the calculation, but won't help with
the buffering because it doesn't tell me the 'distance' in lat/lng space

that would equate to 25 miles (because of course this varies over the
globe).  To achieve this I would need to reproject into something that is in
meters, and buffer around that.

How egregious would you expect the errors to be if I simply use the

projection for the UTM zone that represents, say, Central time?

thanks,
mike


     _______________________________________________
postgis-users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:postgis-users@postgis.refractions.net">postgis-users@postgis.refractions.net</a>
<a class="moz-txt-link-freetext" href="http://postgis.refractions.net/mailman/listinfo/postgis-users">http://postgis.refractions.net/mailman/listinfo/postgis-users</a>


------------------------------


It is a common mis-assumption that you need to do a buffer calculation.
To do this type of analysis, all you need is the distance_sphere()
calculation:
select *,distance_sphere(hospital1geom,hospitals2geom) from hospitals2
where distance_sphere(hospital1geom,hospitals2geom)<25*1609 order by
distance_sphere(hospital1geom,hospitals2geom) asc;

Just add a limit 1 to the end if all you want is the closest.

No buffer necessary at all.


David


On 4/2/07, Michael Frumin <a class="moz-txt-link-rfc2396E" href="mailto:mfrumin@rpa.org"><mfrumin@rpa.org></a> wrote:
      </pre>
      <blockquote type="cite">
        <pre wrap="">Right, I should be more specific from the outset.  I did do some
searching thru the PostGIS archives, and didn't find the answer I was
looking for; is there a PostGIS FAQ somewhere?

As for my problem, my inputs are two sets of geocoded hospitals, and I
just want to be able to identify for each hospital in the first set, the
hospitals in the second set within approximately 25 miles.  I will the map
these sets, with a 25 mile buffer around the first set, using Geoserver.
So, distance and area are both somewhat important, heading not at all.
distance_sphere(oid), sounds good for the calculation, but won't help with
the buffering because it doesn't tell me the 'distance' in lat/lng space
that would equate to 25 miles (because of course this varies over the
globe).  To achieve this I would need to reproject into something that is in
meters, and buffer around that.

How egregious would you expect the errors to be if I simply use the
projection for the UTM zone that represents, say, Central time?

thanks,
mike


        </pre>
      </blockquote>
      <pre wrap="">_______________________________________________
postgis-users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:postgis-users@postgis.refractions.net">postgis-users@postgis.refractions.net</a>
<a class="moz-txt-link-freetext" href="http://postgis.refractions.net/mailman/listinfo/postgis-users">http://postgis.refractions.net/mailman/listinfo/postgis-users</a>


      </pre>
    </blockquote>
    <pre wrap="">
--
************************************
David William Bitner
    </pre>
  </blockquote>
  <pre wrap=""><!---->



-- ************************************
David William Bitner
_______________________________________________
postgis-users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:postgis-users@postgis.refractions.net">postgis-users@postgis.refractions.net</a>
<a class="moz-txt-link-freetext" href="http://postgis.refractions.net/mailman/listinfo/postgis-users">http://postgis.refractions.net/mailman/listinfo/postgis-users</a>
  </pre>
  <br>
  <hr size="4" width="90%"><br>
This function should work to return the correct UTM zone in WGS84
(unless I messed something up quickly pulling this together -- verify
before you use it).<br>
  <br>
CREATE OR REPLACE FUNCTION utmzone(geometry)<br>
  RETURNS integer AS
  <br>
$BODY$<br>
declare<br>
geomgeog geometry;<br>
zone int;<br>
pref int;<br>
begin<br>
geomgeog:=transform($1,4326);<br>
if (y(geomgeog))>0 then <br>
  pref:=32600; <br>
else <br>
  pref:=32700; <br>
end if;<br>
zone:=floor((x(geomgeog)+180)/6)+1;
  <br>
return zone+pref;<br>
end;<br>
$BODY$<br>
  LANGUAGE 'plpgsql' VOLATILE;<br>
  <br>
  <div><span class="gmail_quote">On 4/2/07, <b class="gmail_sendername">David
William Bitner</b> <<a href="mailto:bitner@gyttja.org">
bitner@gyttja.org</a>> wrote:</span>
  <blockquote class="gmail_quote"
 style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">If
you're only concerned with 25 miles, you could use the method to
determine which UTM zone your data is in for your first hospital and
then use that for the calculation and buffer creation.  You could
convert Pedro's PHP script into PL/PGSQL to make it easy to work with
in the db.
    <div><span class="e" id="q_111b3f1db36b21e4_1"><br>
    <br>
    <div><span class="gmail_quote">On 4/2/07, <b
 class="gmail_sendername">Michael Frumin</b> <<a
 href="mailto:mfrumin@rpa.org" target="_blank"
 onclick="return top.js.OpenExtLink(window,event,this)">
mfrumin@rpa.org</a>> wrote:</span>
    <blockquote class="gmail_quote"
 style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
      <div bgcolor="#ffffff" text="#000000">correct.  I wanted to
calculate the buffer so that I can render a map
using GeoServer, which sits right on top of PostGIS, which would show
the first set of hospitals, the 25 mile radius, and the second set.<br>
      <br>
thanks,<br>
mike
      <div><span><br>
      <br>
      <a href="mailto:david.bitner@gmail.com" target="_blank"
 onclick="return top.js.OpenExtLink(window,event,this)">david.bitner@gmail.com</a>
wrote:
      </span></div>
      <blockquote cite="http://mid4ECE4FEECC.0EB06C4FTFSVEVOZ@gmail.com"
 type="cite">
        <div><span>
        <pre>It is a common mis-assumption that you need to do a buffer calculation.  To
do this type of analysis, all you need is the distance_sphere() calculation:
select *,distance_sphere(hospital1geom,hospitals2geom) from hospitals2 where


distance_sphere(hospital1geom,hospitals2geom)<25*1609 order by
distance_sphere(hospital1geom,hospitals2geom) asc;

Just add a limit 1 to the end if all you want is the closest.

No buffer necessary at all.




David


On 4/2/07, Michael Frumin <a href="mailto:mfrumin@rpa.org"
 target="_blank" onclick="return top.js.OpenExtLink(window,event,this)"><mfrumin@rpa.org></a> wrote:
  </pre>
        </span></div>
        <blockquote type="cite">
          <div><span>
          <pre> Right, I should be more specific from the outset.  I did do some
searching thru the PostGIS archives, and didn't find the answer I was
looking for; is there a PostGIS FAQ somewhere?

As for my problem, my inputs are two sets of geocoded hospitals, and I


just want to be able to identify for each hospital in the first set, the
hospitals in the second set within approximately 25 miles.  I will the map
these sets, with a 25 mile buffer around the first set, using Geoserver.


So, distance and area are both somewhat important, heading not at all.
distance_sphere(oid), sounds good for the calculation, but won't help with
the buffering because it doesn't tell me the 'distance' in lat/lng space


that would equate to 25 miles (because of course this varies over the
globe).  To achieve this I would need to reproject into something that is in
meters, and buffer around that.

How egregious would you expect the errors to be if I simply use the


projection for the UTM zone that represents, say, Central time?

thanks,
mike


    </pre>
          </span></div>
        </blockquote>
        <span>
        <pre>_______________________________________________
postgis-users mailing list
<a href="mailto:postgis-users@postgis.refractions.net" target="_blank"
 onclick="return top.js.OpenExtLink(window,event,this)">postgis-users@postgis.refractions.net

</a>
<a href="http://postgis.refractions.net/mailman/listinfo/postgis-users"
 target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">http://postgis.refractions.net/mailman/listinfo/postgis-users</a>
  </pre>
        <br>
        <hr size="4" width="90%"><br>
        <br>
        </span>
        <div><span>It is a common mis-assumption that you need to do a
buffer
calculation.  To do this type of analysis, all you need is the
distance_sphere() calculation:<br>
select *,distance_sphere(hospital1geom,hospitals2geom) from hospitals2
where distance_sphere(hospital1geom,hospitals2geom)<25*1609 order by
distance_sphere(hospital1geom,hospitals2geom) asc; <br>
        <br>
Just add a limit 1 to the end if all you want is the closest.<br>
        <br>
No buffer necessary at all.<br>
        <br>
        <br>
David<br>
        <br>
        <br>
        <div><span class="gmail_quote">On 4/2/07, <b
 class="gmail_sendername">Michael
Frumin</b> <<a href="mailto:mfrumin@rpa.org" target="_blank"
 onclick="return top.js.OpenExtLink(window,event,this)">mfrumin@rpa.org</a>>
wrote:</span>
        <blockquote class="gmail_quote"
 style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
          <div bgcolor="#ffffff" text="#000000">Right, I should be more
specific from the outset.  I did do some
searching thru the PostGIS archives, and didn't find the answer I was
looking for; is there a PostGIS FAQ somewhere?<br>
          <br>
As for my problem, my inputs are two sets of geocoded hospitals, and I
just want to be able to identify for each hospital in the first set,
the hospitals in the second set within approximately 25 miles.  I will
the map these sets, with a 25 mile buffer around the first set, using
Geoserver.  So, distance and area are both somewhat important, heading
not at all.  distance_sphere(oid), sounds good for the calculation, but
won't help with the buffering because it doesn't tell me the 'distance'
in lat/lng space that would equate to 25 miles (because of course this
varies over the globe).  To achieve this I would need to reproject into
something that is in meters, and buffer around that.<br>
          <br>
How egregious would you expect the errors to be if I simply use the
projection for the UTM zone that represents, say, Central time?<br>
          <br>
thanks,<br>
mike<br>
          <br>
          </div>
        </blockquote>
        </div>
        </span></div>
      </blockquote>
      </div>
      <br>
_______________________________________________<br>
postgis-users mailing list<br>
      <a href="mailto:postgis-users@postgis.refractions.net"
 target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">postgis-users@postgis.refractions.net
      </a><br>
      <a
 href="http://postgis.refractions.net/mailman/listinfo/postgis-users"
 target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">http://postgis.refractions.net/mailman/listinfo/postgis-users</a><br>
      <br>
    </blockquote>
    </div>
    <br>
    <br clear="all">
    <br>
    </span></div>
-- <br>
************************************<br>
    <span class="sg">David William Bitner
    </span></blockquote>
  </div>
  <br>
  <br clear="all">
  <br>
-- <br>
************************************<br>
David William Bitner
</blockquote>
</body>
</html>