ArcGIS python enables batch cropping of images

Source: Internet
Author: User

First, the program code:

Import arcpyarcpy. Checkoutextension ("spatial") Arcpy.gp.overwriteoutput=1arcpy.env.workspace = "F:\\modis_16\\1moasic" rasters = arcpy . Listrasters ("*", "TIF") mask= "F:\\vegetation change\\data\\bound\\bound_buffer_polygon.shp" for raster in Rasters:    print (raster)    out= "F:\\vegetation change\\data\\gimms data\\new\\" + "Ma_" +raster[0:8]    Arcpy.gp.ExtractByMask_sa (Raster, mask, out)    print ("Ma_" +raster[0:8]+ "have done  ") print ("All done")

Second, the matters needing attention:

1.arcpy.gp.overwriteoutput=1 that overwrite the previous file;

2. The input is a. tif file, and the output is a grid file;

3.raster[0:8] indicates that 8 strings are taken from the beginning of the No. 0;

4.bound_buffer_plygon.shp suffix is indispensable.

Third, operation situation:


ArcGIS python enables batch cropping of images

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.