The previous article mainly introducedSt_snaptogrid. Now we use the features table in the previous articles for the following applications:
This section briefly describes the methods used:
GeometrySt_collect (Geometry[] G1_array); combines a series of geometries into a single st_geometry (the old version is called geometrycollection ).
GeometrySt_multi (GeometryG1); converts G1 to a multi * geometry.
As with the previous methods, connect to the database, open the query visualization box, and add the following SQL:
select st_multi (st_collect (the_geom )) as the_geom, st_astext (st_multi (st_collect (the_geom)
from features
group by st_snaptogrid (st_transform (the_geom, 2327 ), 2000 , 2000 )
Aggregates points in features into a grid of 2000*2000 m²,St_transform (the_geom,2327) Is to convert the coordinate system from 4326 to 2327, because the measurement unit of 4326 is degree, 2327 (here I randomly find a Xi'an 80 COORDINATE SYSTEM) should be meters. St_astext (st_multi (st_collect (the_geom) is not very useful, but it is easy to edit styles in qgis.
Change the grid size to 5000*5000:
SelectSt_multi (st_collect (the_geom ))AsThe_geom, st_astext (st_multi (st_collect (the_geom )))
FromFeatures
Group BySt_snaptogrid (st_transform (the_geom,2327),5000,5000)