forked from JavierLopatin/Python-Remote-Sensing-Scripts
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDissolve_all.py
More file actions
executable file
·34 lines (27 loc) · 808 Bytes
/
Dissolve_all.py
File metadata and controls
executable file
·34 lines (27 loc) · 808 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Dissolve all vector fields
Usage: python Dissolve_all.py -i vector.shp
@author: javier
"""
import argparse
import geopandas as gpd
# create the arguments for the algorithm
parser = argparse.ArgumentParser()
# set arguments
parser.add_argument('-i','--inputVector', help='Input raster', type=str, required=True)
parser.add_argument('--version', action='version', version='%(prog)s 1.0')
args = vars(parser.parse_args())
# set argument
shp = args["inputVector"]
# read vector file
vector = gpd.read_file(shp)
# add dummy field to perform the dissolve
vector.loc[:, "dissolve"] = 1
# perform dissolve
print("Dissolving vector file...")
vector = vector.dissolve(by = "dissolve")
# save new vector
vector.to_file(shp[:-4] + "_diss.shp")
print("Done!")