Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- insert
- ```shp2pgsql wdpa_final.shp | psql postgresql://charlie:{{password}}@localhost/gisdata
- shp2pgsql adm2_final.shp | psql postgresql://charlie:{{password}}@localhost/gisdata
- ```
- check if they are in:
- ```
- ogrinfo PG:'host=localhost user=charlie dbname=gisdata password={{password}}' -so
- ```
- enter the DB
- ```
- psql postgresql://charlie:{{password}}@localhost/gisdata
- ```
- UPDATE GEOMS
- ```
- UPDATE wdpa_final SET geom = ST_MakeValid(geom) WHERE ST_IsValid(geom)::integer <> 1;
- UPDATE adm2_final SET geom = ST_MakeValid(geom) WHERE ST_IsValid(geom)::integer <> 1;
- ```
- create
- ```
- 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;
- ```
- export. be sure to filter by multipolygon. intersect output can be lines too and shps only have one type
- ```
- pgsql2shp -f out.shp -h localhost -u charlie -P {{password}} gisdata "SELECT * FROM out WHERE ST_GeometryType(geom)='ST_MultiPolygon'"
- ```
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement