[postgis-users] Newbie questions on what geometry to use

snacktime snacktime at gmail.com
Fri Jul 7 09:51:17 PDT 2006


Thanks Mark!!   I had been looking for an example of how to do the math on
this.

Chris

On 7/5/06, mark thomas <javaguru at bellsouth.net> wrote:
>
>  Chris,
>
> Don't forget that the spatial functions perform calculations in the units
> of the input geometries, so for example if you have a point geometry in
> decimal degrees and you call Buffer(the_geom, 1) it will buffer the input
> geometry by 1 decimal degree.  You'll have to convert your input (miles) to
> the correct units (decimal degrees).  To save you some time, here are the
> functions in PL/PGSQL:
>
> -- function to convert miles into decimal degrees
> create or replace function convertMilesToDecimalDegrees(numeric) returns numeric as $$
> begin
>     -- $1 = radius in miles
>     -- x = ($1 * 63360) = convert to meters (i.e. 63360 meters/mile)
>     -- x = (x * 0.0254) = convert to inches (i.e. 0.0254 inches/meter)
>     -- x = (x / 1852) = convert to nautical miles (i.e. 1852 meters/nautical mile)
>     -- x = (x / 60) = convert to decimal degrees of latitude =
>     --      (i.e. 1 nautical mile = 1 decimal minute; therefore nautical miles/60 = decimal degrees
>     return (((($1 * 63360) * 0.0254) / 1852) / 60);
> end;
> $$ language plpgsql;
>
> --function to buffer a geometry by a radius whose value is specified in miles
> create or replace function getBufferedGeometry(geometry,numeric) returns geometry as $$
> declare g geometry;
> begin
>     select Buffer($1,convertMilesToDecimalDegrees($2)) into g;
>     return g;
> end;
> $$ language plpgsql;
>
>
> Hope this helps.
>
> Regards,
>
> Mark Thomas
>
>
> On Tue, 2006-07-04 at 12:00 -0700,
> postgis-users-request at postgis.refractions.net wrote:
>
> [postgis-users] Newbie questions on what geometry to use
>
>   Mark Thomas
> Senior Software Engineer
> Awarix Corporation
> mthomas at awarix.com
> http://www.awarix.com
>
> *"Commit to the Lord whatever you do, *
> *    and your plans will succeed." - Proverbs 16:3*
>
>
>
> _______________________________________________
> postgis-users mailing list
> postgis-users at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20060707/1691e4da/attachment.html>


More information about the postgis-users mailing list