1

I'm new to Python so sorry for maybe trivial question esta, I have four Landsat images and each image with an area to extract by mask. How can I make this script? I've tried with this script doesn't work

import arcpy, os
from arcpy import env
path = 'F:\\Master\\Python\\1997\\data'
arcpy.env.overwriteOutput = True
arcpy.env.workspace = path
arcpy.CheckOutExtension("spatial")

Local variables:

1='1_23165_1997204.img'
2='2_23065_1997197.img'
3='3_23166_1997204.img'
4= '4_23066_1997197.img'
rec_1 = "rec_1"
rec_2 = "rec_2"
rec_3 = "rec_3"
rec_4 = "rec_4"
Zona1 = "F:\\Master\\Python\\output\\zona1"
Zona2 = "F:\\Master\\Python\\output\\zona2"
Zona3 = "F:\\Master\\Python\\output\\zona3"
Zona4 = "F:\\Master\\Python\\output\\zona4"

Process: Extract by Mask

arcpy.gp.ExtractByMask_sa(1, rec_1, Zona1)
arcpy.gp.ExtractByMask_sa(2, rec_2, Zona2)
arcpy.gp.ExtractByMask_sa(3, rec_3, Zona3)
arcpy.gp.ExtractByMask_sa(4, rec_4, Zona4)
2
  • What do the four calls return? Mar 1 '16 at 14:46
  • Yes, one for each raster
    – epcardiel
    Mar 2 '16 at 18:48
1

Two issues that I see:

  1. Your raster variable names are invalid; they have to be more than just a number.
  2. To run the extract command use newRaster = arcpy.sa.ExtractByMask(inRaster, mask) newRaster.save(newFileName)

For each raster

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.