Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
12 views2 pages

Python Script Rainfall - Temp Interpolation Specific Years

An easy & quick python script to interpolate rainfall trend for specific years.

Uploaded by

taiwobalogun85
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views2 pages

Python Script Rainfall - Temp Interpolation Specific Years

An easy & quick python script to interpolate rainfall trend for specific years.

Uploaded by

taiwobalogun85
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

import arcpy

from arcpy.sa import *

# Set up the ArcPy environment

arcpy.env.overwriteOutput = True

# --- Step 1: Set Variables ---

# The name of your point layer (the event layer created from the CSV).

in_point_features = "selected_years_annual_temp_for_GIS Events" # Make sure this name matches


exactly

# The name of the field containing the annual temperature values.

z_field = "ANN"

# The name of the output interpolated raster.

output_raster = "C:/YourPath/Interpolated_1994.tif"

# The name of the polygon feature class representing your area of interest.

# Make sure to replace "YourAreaOfInterest" with the actual name or path to your polygon.

area_of_interest = "C:/YourPath/YourAreaOfInterest.shp"

# --- Step 2: Filter the Data for 1994 ---

# Create a temporary layer from your point data to apply a filter.

arcpy.MakeFeatureLayer_management(in_point_features, "temp_layer")

# Select only the features where the YEAR field is 1994.


arcpy.SelectLayerByAttribute_management("temp_layer", "NEW_SELECTION", "YEAR = 1994")

# --- Step 3: Interpolate the 1994 Data ---

# Perform the IDW interpolation on the filtered data.

# You can adjust the power and search radius if needed.

print("Starting interpolation for 1994 data...")

interpolated_raster = Idw("temp_layer", z_field)

# Save the interpolated raster.

interpolated_raster.save(output_raster)

print(f"Interpolation for 1994 complete. Raster saved to {output_raster}")

# --- Step 4: Clip the Interpolated Raster to the Area of Interest ---

# Use the 'area_of_interest' polygon to clip the raster.

print("Clipping the interpolated raster...")

clipped_raster = arcpy.sa.ExtractByMask(interpolated_raster, area_of_interest)

# Save the final clipped raster.

clipped_raster.save("C:/YourPath/Clipped_1994_Temp.tif")

print("Clipped raster saved.")

print("Script finished successfully.")

You might also like