Sunday, 21 June 2009

PostGIS špikeri

Konvertēt MULTIPOLYGON uz POLYGON ģeometrijas veidu:
CREATE TABLE gislatvija.mezi_simple AS SELECT gid, shape_leng, shape_area, (public.st_dump(the_geom)).geom AS the_geom FROM gislatvija.mezi_multi;

Validēt ģeometriju:
SELECT st_isvalid(the_geom) FROM foo WHERE gid = 40;
st_isvalid
------------
t
(1 row)


Uzzināt objekta ģeometrijas izmēru megabaitos:
SELECT st_mem_size(the_geom)/131072 as size_in_mb FROM foo WHERE gid = 40;
size_in_mb
---------
2
(1 row)



Ģenerēt 'bounding box' ģeometriju no koordinātēm:
UPDATE mytable SET the_geom = st_geomfromtext('POLYGON((' || minx || ' ' || maxy || ',' ||
maxx || ' ' || maxy || ',' || maxx || ' ' || miny || ',' || minx || ' ' || miny || ',' || minx ||
' ' || maxy || '))', 27700);


Shapefile dump from PostGIS database:
pgsql2shp -u lasma -h localhost -f myfile mydatabase "select id, ('/home/lasma/' || tif_path) as location from myschema.mytable where name = 'Worcester'"

No comments: