Advertisement
Guest User

Untitled

a guest
Aug 1st, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. # Import the GeoTIFF into PostGIS using raster2pgsql
  2. raster2pgsql -s 4326 -t 50x50 -f rast -I -Y my.tif etopo_2008_raw | psql MYDB
  3.  
  4. # Generate contours of the desired area using gdal since there is no
  5. # ST_contours type function in PostGIS that I am aware of.
  6. 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
  7.  
  8. # Load the output shapefile back into postgres
  9. shp2pgsql -I -s 4326 etopo_contours etopo_contours | psql MYDB
  10.  
  11. CREATE TABLE hypsometric_area_X00 AS
  12. WITH A AS (SELECT st_makevalid((st_dump(st_polygonize(geom))).geom) AS geom FROM etopo_contours WHERE elev='0'),
  13. B AS (SELECT st_makevalid((st_dump(st_polygonize(geom))).geom) AS geom FROM etopo_contours WHERE elev='-X00')
  14. 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