wiki:BluePrintGIStools

Version 5 (modified by Nico Presto, 14 years ago) ( diff )

--

Basic GIS calculations that may be useful in Sahana eden:

  • Centroid
    select name, asText(Centroid(the_geom)) from table where name='location';
    
  • Bounding boxes
    select name, asText(Envelope(the_geom) from table where name='location';
    select name, extent(the_geom) from table where name = 'location' group by name;
    

  • buffer calculations
  • Distance - linear
    select distance(
    (transform(GeomFromText('Point(lon lat)'), 900913), 26915), 
    (transform(GeomFromText('Point(lon lat)'), 900913), 26915);
    
  • Distance - Spherical
    select distance_sphere(
    (transform(GeomFromText('Point(lon lat)'), 900913), 
    (transform(GeomFromText('Point(lon lat)'), 900913);
    
  • Distance - Spheroid
    select distance_spheroid(
    (GeomFromText('Point(lon lat)'), 900913), 
    (GeomFromText('Point(lon lat)'), 900913),
    'SPHEROID["GRS 1980", 6378137, 298.257222101]');
    
  • intersections
    select name from location where
    GeomFromText('Point(lon lat)',900913)
    && the_geom AND
    within (GeomFromText('Point(lon lat)', 900913), the_geom);
    
  • Point within polygon
    select name from location where
    GeomFromText('Point(lon lat)', 900913)
    && the_geom;
    
Note: See TracWiki for help on using the wiki.