Advertisement
Guest User

Untitled

a guest
Aug 25th, 2017
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. insert
  2. ```shp2pgsql wdpa_final.shp | psql postgresql://charlie:{{password}}@localhost/gisdata
  3. shp2pgsql adm2_final.shp | psql postgresql://charlie:{{password}}@localhost/gisdata
  4. ```
  5.  
  6. check if they are in:
  7. ```
  8. ogrinfo PG:'host=localhost user=charlie dbname=gisdata password={{password}}' -so
  9. ```
  10. enter the DB
  11. ```
  12. psql postgresql://charlie:{{password}}@localhost/gisdata
  13. ```
  14.  
  15. UPDATE GEOMS
  16. ```
  17. UPDATE wdpa_final SET geom = ST_MakeValid(geom) WHERE ST_IsValid(geom)::integer <> 1;
  18. UPDATE adm2_final SET geom = ST_MakeValid(geom) WHERE ST_IsValid(geom)::integer <> 1;
  19. ```
  20.  
  21. create
  22. ```
  23. SELECT ST_Intersection(adm2.geom, wdpa.geom) AS geom, adm2.ISO, adm2.ID_1, adm2.ID_2, wdpa.wdpa_pid INTO out FROM adm2_final adm2, wdpa_final wdpa;
  24. ```
  25.  
  26. export. be sure to filter by multipolygon. intersect output can be lines too and shps only have one type
  27. ```
  28. pgsql2shp -f out.shp -h localhost -u charlie -P {{password}} gisdata "SELECT * FROM out WHERE ST_GeometryType(geom)='ST_MultiPolygon'"
  29. ```
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement