Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Import the GeoTIFF into PostGIS using raster2pgsql
- raster2pgsql -s 4326 -t 50x50 -f rast -I -Y my.tif etopo_2008_raw | psql MYDB
- # Generate contours of the desired area using gdal since there is no
- # ST_contours type function in PostGIS that I am aware of.
- gdal_contour -a ELEV -i METERS -f 'ESRI Shapefile' 'PG: dbname=MYDB host=LOCALHOST user=postgres password=PASSWORD port=PORT mode=2 schema=SCHEMA column=rast table=etopo_2008_raw' ~/PATH/etopo_contours
- # Load the output shapefile back into postgres
- shp2pgsql -I -s 4326 etopo_contours etopo_contours | psql MYDB
- CREATE TABLE hypsometric_area_X00 AS
- WITH A AS (SELECT st_makevalid((st_dump(st_polygonize(geom))).geom) AS geom FROM etopo_contours WHERE elev='0'),
- B AS (SELECT st_makevalid((st_dump(st_polygonize(geom))).geom) AS geom FROM etopo_contours WHERE elev='-X00')
- SELECT ST_SymDifference(C.geom,D.geom) AS geom FROM (SELECT *, row_number() OVER (ORDER BY 1) AS rn FROM A) AS C JOIN (SELECT *,row_number() OVER (ORDER BY 1) AS RN FROM B) AS D ON C.rn=D.rn;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement