There is NDVI image of a small agricultural area. I was also given separate shapefiles for all fields (37 fields) inside that area. I have written a script that clipped NDVI image for each field using the shapefile. When a clipped NDVI image is saved, it is exported in tiff format and grayscale.

Shape_Files_Name = ['TX1_10_poly.shp', 'TX1_11N_poly.shp', 'TX1_11S_poly.shp'...........]

for n in Shape_Files_Name:

    #mask out each field
    Clipped_File_Name = random.randint(1,101)
    arcpy.gp.ExtractByMask_sa (NDVI_Layer, n, Clipped_File_Name ) 

    #save the raster  
    arcpy.CopyRaster_management (Clipped_File_Name, NDVI_Save_Location_and_Extension)

I was trying to find a way to export them to a known colour ramp. Thus, a dummy layer is created and applied the desired colour ramp to it. Later, for each NDVI field image, just applying the colour ramp by the following codes

arcpy.ApplySymbologyFromLayer_management(in raster, color ramp layer)

It works. But I would like to export those NDVI images in the colour ramp I applied.

Is there any way to do that in ArcPy?

  • I may be small minded, but I don't think what you are looking for is possible within ArcGIS, outside of your suggestion, since NDVI is a single band/value per pixel, this wouldn't be possible for it to be natively read that way. If what you're really looking for is for creating a map only, I would suggest adding it to a map, and exporting it as a jpg or .TIFF. These would be threeband, rather than single band like your NDVI calculation(although they wouldn't necessarily be georeferenced. arcpy.mapping has some tools you may want to look at. – bwp8nt Jun 14 '18 at 19:41
  • I have been looking for the solution for a while! None came up. I also found someone who said that it's not possible to that with ArcPy. However, NDVI image in RGB format is required by my our team. Do you any other software can do that? – Sourav Jun 14 '18 at 20:03

Your Answer

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

Browse other questions tagged or ask your own question.