Difference between revisions of "PostGIS update"

From gnewarchaeology wiki
Jump to: navigation, search
 
Line 3: Line 3:
 
__NOTOC__
 
__NOTOC__
  
Update a MultiPointZ table from a PointZ table, collecting geoms
+
== Update a MultiPointZ table from a PointZ table, collecting geoms ==
  
 
* [http://postgis.org/documentation/manual-2.0/ST_Multi.html]
 
* [http://postgis.org/documentation/manual-2.0/ST_Multi.html]
Line 15: Line 15:
 
   WHERE foo.geo = bar.geo and foo.unit = bar.unit;
 
   WHERE foo.geo = bar.geo and foo.unit = bar.unit;
 
</syntaxhighlight>
 
</syntaxhighlight>
 +
 +
== Update lat lon columns from geom ==
 +
 +
  
 
[[Category:PostGIS]]
 
[[Category:PostGIS]]

Latest revision as of 16:09, 12 December 2016

PostGIS > PostGIS update



Update a MultiPointZ table from a PointZ table, collecting geoms

# UPDATE geo AS foo SET multigeom = bar.geom
  FROM (
       SELECT p.geo, p.unit, ST_Multi(ST_Collect(p.geom)) AS geom FROM geo_point as p GROUP BY p.geo, p.unit
       ) AS bar
  WHERE foo.geo = bar.geo and foo.unit = bar.unit;

Update lat lon columns from geom