Hello everyone,
First of all, thanks for any input you can provide.
I'm very, very new to Python and I have a two-part challenge. I have to clip residential parcels from a raster, save those parcels under their APN number, then buffer the structure on each parcel.
Decided to do the clipping first and put a Python code together. Although the .tif files populate in my gdb folder, I can't open them. Could those files be corrupted? They range between 1 and 2 MB, but I can't seem to open them in any software.
I've also been unsuccessful at running the same script while using jpeg instead of tif.
Here's the code:
import arcpy
# Set environment settings
arcpy.env.workspace = r"C:\Users\Projects\FINALPython"
arcpy.env.overwriteOutput = True
# Define paths to feature classes and raster layer
parcels_fc = "Parcels_Clip"
raster_layer = "RGB_FBRanch 9.6.23.tif"
# Get APN field name
apn_field = arcpy.ListFields(parcels_fc, "APN")[0].name
# Create a search cursor to iterate through parcels and clip the raster layer
with arcpy.da.SearchCursor(parcels_fc, ["SHAPE@", apn_field]) as cursor:
for row in cursor:
# Define output path for clipped raster
apn_number = row[1]
clipped_output = arcpy.CreateUniqueName("clipped_{}.tif".format(apn_number))
# Clip raster layer using individual parcel
arcpy.management.Clip(raster_layer, "#", clipped_output, row[0], "", "ClippingGeometry")
Thanks so much for your input..
Solved! Go to Solution.
RGB_FBRanch 9.6.23.tif
make a copy of one of the images and rename it so it doesn't have spaces or punctuation...can it be added to a map now?
RGB_FBRanch 9.6.23.tif
make a copy of one of the images and rename it so it doesn't have spaces or punctuation...can it be added to a map now?
I spoke with Esri tech support and they recommended the "export raster" tool to rename and choose the file type. It worked!
Thank you for your suggestion, Dan. Much appreciated.
no problem
Hello again Dan,
I finally succeeded in producing a python script for clipping raster into multiple parcels, but my final output has to have buffer lines of 50 and 100-feet around each structure on each parcel. I'm attaching an image of the raster with the buffer and parcel lines,
I would appreciate any suggestions you may have on this subject.
Thanks so much,
Maha