4

The code below creates many IDW rasters:

for date in all_dates:
 # Create a feature layer of each unique date
 where = "{0}=date '{1}'".format(arcpy.AddFieldDelimiters(datasource=fc, field=date_field),
 date.strftime('%Y-%m-%d'))
 arcpy.MakeFeatureLayer_management(in_features=fc, out_layer='lyr', where_clause=where)
 # For each field interpolate. This is untested since I dont have spatial analyst
 for fieldname in value_fields:
 outIDW = Idw(in_point_features='lyr', z_field=fieldname,
 cell_size=10) # , {power}, {search_radius}, {in_barrier_polyline_features})
 outIDW.save(os.path.join(output_folder, '{0}_{1}.tif'.format(fieldname, date.strftime('%Y%m%d'))))

as you know the generated rasters are in black and white(color ramp) I want to know if I can change them to other colors by using ArcPy not one by one in ArcMap.

PolyGeo
65.5k29 gold badges115 silver badges350 bronze badges
asked Jun 2, 2021 at 20:53

1 Answer 1

4

The "Apply Symbology From Layer" tool does this. After the "outIDW.save" step, the layer will be the top-most layer in the map, so simply apply the symbology to the first layer in your map document. For example:

topLyr = arcpy.mapping.ListLayers(mxd, "*", df)[0]
symbologyLyr = r"C:\MyLayerFileFolder\someLayerFile.lyr"`
arcpy.management.ApplySymbologyFromLayer(topLyr, symbologyLyr)

(See Saving layers and layer packages).

answered Jun 2, 2021 at 21:15
1

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.