[postgis-users] point_inside_circle(geometry,float,float,float) : units -> meters ?
Pedro Salazar
pedro-b-salazar at ptinovacao.pt
Tue Apr 15 07:28:42 PDT 2003
David,
Indeed, your suggestion is a very clever ideia your, and I would like to
try it since it's a very flexible. However, there are a few points I
would like to clarify with you.
1) I didn't find any reference to the "expand" function in postgis
0.7.4. Is a new function on postgis CVS? What it does is just a creation
of box over my geometry? (in my case, is a point, so is very simple to
do it)
2) What is the SRID for measuring the distance between geometries in
meters? I'm using the SRID 4326 (WGS84). So, to what system should I
transform my geometries to get the distance in meters?
thanks,
Pedro Salazar.
> Here's a fairly general method:
>
> 1. Find a cartesian projection thats accurate for where your data is
> (ie. UTM zone whatever)
> 2. make sure this projection is properly entered in your spatial_ref_sys
> table. Most likely its already there if you uploaded the standard epsg
> projections.
> 3. Optional (for indexing) : find a maximum conversion factor between
> your data's units and meters. We;'ll be using this information to make
> a bounding box that's LARGER than the circle you want to enscribe
>
> SELECT * FROM table WHERE
> the_geom && expand( <GEOMETRY>, <BOX SIZE> )
> AND distance(transform(the_geom,<SRID>),
> transform(<GEOMETRY>,<SRID>) < <DIST>
>
> This is a bit more general than what you're asking for, but:
> < GEOMETRY > = point thats the centre of your circle
> <BOX SIZE> = this is the step #3 conversion factor (degrees)
> <SRID> = step #2's SRID in the spatial_ref_sys table
> <DIST> = distance (meters)
>
> This is a bit complicated, but:
>
> the_geom && expand( <GEOMETRY>, <BOX SIZE> )
> This uses the index to quickly find points that are nearby. Box size
> will depend on step #3.
> NB: make sure this box size is ALWAYS bigger than the distance you're
> looking for - dont
> worry if its too big. Its in the units of your source data (ie. degrees)
>
> distance(transform(the_geom,<SRID>), transform(<GEOMETRY>,<SRID>) <
> <DIST>
> This calculates the distance between the centre of your circle
> ("<GEOMETRY>") and the
> data in the table.
> transform( <geom>, <srid>) - re-projects <geom> to the projection
> defined by <srid>
>
> The expand() expression isnt really needed, but it will significantly
> speed this process up since you'll only be doing the expensive functions
> on a small portion of the data.
>
--
PS
pedro-b-salazar at ptinovacao.pt
PGP:0E129E31D803BC61
More information about the postgis-users
mailing list