0
C:\OSGeo4W64\bin\gdalwarp.exe -dstnodata 0 -q -cutline D:\hillsborough_Images_work\split_Polygon\120-140k\Hillborough_FINAL_140000_region_IGD_120570003d29ed0dc.shp -crop_to_cutline -dstalpha -tr 0.500000000000000 0.500000000000000 -co "COMPRESS=LZW" D:\hillsborough_Images_work\HIL2017\mrsid.vrt D:\hillsborough_Images_work\Clipped_Images\120570003d29ed0dc.png

C:\OSGeo4W64\bin\gdalwarp.exe -dstnodata 0 -q -cutline D:\hillsborough_Images_work\split_Polygon\120-140k\Hillborough_FINAL_140000_region_IGD_120570004819de834.shp -crop_to_cutline -dstalpha -tr 0.500000000000000 0.500000000000000 -co "COMPRESS=LZW" D:\hillsborough_Images_work\HIL2017\mrsid.vrt D:\hillsborough_Images_work\Clipped_Images\120570004819de834.png

C:\OSGeo4W64\bin\gdalwarp.exe -dstnodata 0 -q -cutline D:\hillsborough_Images_work\split_Polygon\120-140k\Hillborough_FINAL_140000_region_IGD_120570006c12a2d77.shp -crop_to_cutline -dstalpha -tr 0.500000000000000 0.500000000000000 -co "COMPRESS=LZW" D:\hillsborough_Images_work\HIL2017\mrsid.vrt D:\hillsborough_Images_work\Clipped_Images\120570006c12a2d77.png

C:\OSGeo4W64\bin\gdalwarp.exe -dstnodata 0 -q -cutline D:\hillsborough_Images_work\split_Polygon\120-140k\Hillborough_FINAL_140000_region_IGD_120570008cca2ea3a.shp -crop_to_cutline -dstalpha -tr 0.500000000000000 0.500000000000000 -co "COMPRESS=LZW" D:\hillsborough_Images_work\HIL2017\mrsid.vrt D:\hillsborough_Images_work\Clipped_Images\120570008cca2ea3a.png

This worked fine but I wanted to do this task using for loop and I writed script for this but I'm doing something wrong. Can you please help me to do it correct?

#!/bin/sh
#    "shp" - folder for shapefiles 
#    "outputraster" - folder for output rasters
cd /home/user/cliprasters/
#  delete previous files
rm D:\hillsborough_Images_work\temp\*.png
#  run
for fname1 in D:\hillsborough_Images_work\split_Polygon\0-20k\*.shp do
  fname2="$(basename $fname1 .shp)"
  C:\OSGeo4W64\bin\gdalwarp.exe -dstnodata 0 -q -cutline D:\hillsborough_Images_work\split_Polygon\0-20k\$fname2.shp -crop_to_cutline -dstalpha -tr 0.500000000000000 0.500000000000000 -co "COMPRESS=LZW" D:\hillsborough_Images_work\HIL2017\mrsid.vrt D:\hillsborough_Images_work\temp\$fname2.png
done
  • Edit the question and fix the formatting please. – BERA Aug 7 '18 at 8:13
0

try adding semicolons before do and done:

for fname1 in D:\hillsborough_Images_work\split_Polygon\0-20k*.shp;
do fname2="$(basename $fname1 .shp)" C:\OSGeo4W64\bin\gdalwarp.exe -dstnodata 0 -q -cutline D:\hillsborough_Images_work\split_Polygon\0-20k\$fname2.shp -crop_to_cutline -dstalpha -tr 0.500000000000000 0.500000000000000 -co "COMPRESS=LZW" D:\hillsborough_Images_work\HIL2017\mrsid.vrt D:\hillsborough_Images_work\temp\$fname2.png;
done
  • hi thanks for your reply but still this code not working – Neeraj Singh Aug 13 '18 at 9:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.