Skip to main content
added 191 characters in body
Source Link
david_p
  • 1.8k
  • 1
  • 19
  • 34

Can you use Python? You could use some for cycle. I tried to write some concept here:

import os

wd = r"c:\your\working\dir"
os.chdir = wd
list_of_files = os.listdir(wd)

file_that_clips = "path_to_shapefile_that_clips_other"

for file in list_of_files:
    if file[file_to_clip[-3:] == "shp":                          # If file is a shapefile
        clipped_file = file[file_to_clip[:-4] + "_clipped.shp"   # New name for output
        os.system("ogr2ogr -fclipsrclayer ESRI" Shapefile+ file_that_clips + " " + clipped_file + " " + filefile_to_clip)    # Execute cmd order

I'm not sure about the ogr2ogr Clip statement. But you could copy there yours.

Can you use Python? You could use some for cycle. I tried to write some concept here:

import os

wd = r"c:\your\working\dir"
os.chdir = wd
list_of_files = os.listdir(wd)

for file in list_of_files:
    if file[-3:] == "shp":                          # If file is a shapefile
        clipped_file = file[:-4] + "_clipped.shp"   # New name for output
        os.system("ogr2ogr -f ESRI Shapefile " + clipped_file + " " + file)    # Execute cmd order

Can you use Python? You could use some for cycle. I tried to write some concept here:

import os

wd = r"c:\your\working\dir"
os.chdir = wd
list_of_files = os.listdir(wd)

file_that_clips = "path_to_shapefile_that_clips_other"

for file in list_of_files:
    if file_to_clip[-3:] == "shp":                          # If file is a shapefile
        clipped_file = file_to_clip[:-4] + "_clipped.shp"   # New name for output
        os.system("ogr2ogr -clipsrclayer " + file_that_clips + " " + clipped_file + " " + file_to_clip)    # Execute cmd order

I'm not sure about the ogr2ogr Clip statement. But you could copy there yours.

Source Link
david_p
  • 1.8k
  • 1
  • 19
  • 34

Can you use Python? You could use some for cycle. I tried to write some concept here:

import os

wd = r"c:\your\working\dir"
os.chdir = wd
list_of_files = os.listdir(wd)

for file in list_of_files:
    if file[-3:] == "shp":                          # If file is a shapefile
        clipped_file = file[:-4] + "_clipped.shp"   # New name for output
        os.system("ogr2ogr -f ESRI Shapefile " + clipped_file + " " + file)    # Execute cmd order