[postgis-users] SRID for analyzing a USA national data set in Meters

David William Bitner david.bitner at gmail.com
Mon Apr 2 13:42:44 PDT 2007


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 <bitner at gyttja.org> wrote:
>
> 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 <mfrumin at rpa.org> wrote:
> >
> >  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
> >
> > david.bitner at gmail.com 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 <mfrumin at rpa.org> <mfrumin at rpa.org> 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
> > postgis-users at postgis.refractions.net
> > http://postgis.refractions.net/mailman/listinfo/postgis-users
> >
> >
> > ------------------------------
> >
> >
> > 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 <mfrumin at rpa.org> 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
> > postgis-users at postgis.refractions.net
> > http://postgis.refractions.net/mailman/listinfo/postgis-users
> >
> >
>
>
> --
> ************************************
> David William Bitner




-- 
************************************
David William Bitner
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20070402/36e34615/attachment.html>


More information about the postgis-users mailing list