filmov
tv
Python script to separate shapefile based on type (Point, Line and Polygon)

Показать описание
Move Shapefile into sub folders based on type (Point, Line and Polygon) with Python.
The Code
--------------
import glob
import shapefile # pip install pyshp
import shutil
# Paths to respective shp folders...
point_folder = r'C:\Users\Yusuf_08039508010\Desktop\Move SHP\SHP folder_2\points SHP'
line_folder = r'C:\Users\Yusuf_08039508010\Desktop\Move SHP\SHP folder_2\lines SHP'
polygon_folder = r'C:\Users\Yusuf_08039508010\Desktop\Move SHP\SHP folder_2\polygon SHP'
# Read all the shp into a list...
for shp in shp_files:
# Read the first shp from the list...
sf = shapefile.Reader(shp) # Can also use: open(shp_files[0], "rb")
# Check for shapefile type and copy to appropriate folder...
else:
print('This is niether point, line or polygon shapefile...')
print('Done...')
The Code
--------------
import glob
import shapefile # pip install pyshp
import shutil
# Paths to respective shp folders...
point_folder = r'C:\Users\Yusuf_08039508010\Desktop\Move SHP\SHP folder_2\points SHP'
line_folder = r'C:\Users\Yusuf_08039508010\Desktop\Move SHP\SHP folder_2\lines SHP'
polygon_folder = r'C:\Users\Yusuf_08039508010\Desktop\Move SHP\SHP folder_2\polygon SHP'
# Read all the shp into a list...
for shp in shp_files:
# Read the first shp from the list...
sf = shapefile.Reader(shp) # Can also use: open(shp_files[0], "rb")
# Check for shapefile type and copy to appropriate folder...
else:
print('This is niether point, line or polygon shapefile...')
print('Done...')