POST
|
It worked! I changed the in_template_dataset to be equal to the absolute path of the shapefile I was calling. in_template_dataset = "Z:/Fall2016_GlacierNationalParkClimate/Term2/Charlotte/ADS/ADS_PerRanktop10percentTPA2001/PerRanktop10percentTPA2001.shp" Thank you so much!
... View more
03-03-2017
01:54 PM
|
0
|
0
|
2542
|
POST
|
So how could I set it up so that the inputs to the Clip function are coming from two different folders? I thought if I defined a workspace once I wouldn't have to do it again. Or how could I collect the full path of the shapefiles in FolderA?
... View more
03-03-2017
01:39 PM
|
0
|
2
|
2542
|
POST
|
I tried making the source and destination paths a lot shorter and I checked with my print statements that the locations are still confirmed right before running Clip... still didn't work and I'm still getting the same error.
... View more
03-03-2017
12:51 PM
|
0
|
0
|
2542
|
POST
|
I have seen a few questions with this error, but none of the fixes worked for me. I am trying to use the clipping data management tool to clip raster files to a shapefile of polygons. I have also tried to do the same thing with the Extract by Mask tool and I got the same error. This is the error: ERROR 000732: Output Extent: Dataset PerRanktop10percentTPA2001.shp does not exist or is not supported Failed to execute (Clip). The error says that the shapefile PerRanktop10percentTPA2001.shp does not exist, but when I use the print statement in line 39 it prints out this file, so it definitely exists and the script can find it. Hope someone can help! Here's my code: #import necessary packages
import arcpy
import os
from arcpy import env
#sets workspace to ADS folder
env.workspace = "Z:/Fall2016_GlacierNationalParkClimate/Term2/Charlotte/ADS/ADS_PerRanktop10percentTPA2001"
#turns overwrite on
env.overwriteOuput = True
#lists shapefiles
shapefiles = arcpy.ListFeatureClasses("*")
print (shapefiles)
#changes year to match ADS year
shapefile = shapefiles[0]
year = shapefile [22:26]
print (year)
#sets workspace to rasters folder
env.workspace = "Z:/Fall2016_GlacierNationalParkClimate/Term2/Charlotte/RGI/RGI_2000_2003"
env.overwriteOuput = True
#Lists folders in workspace
folders = arcpy.ListWorkspaces()
for folder in folders:
env.workspace = folder
env.overwriteOuput = True
#lists rasters in all folers
rasters = arcpy.ListRasters("*", "tif")
print (rasters)
for raster in rasters:
#Names inputs and outputs for each raster in each folder
in_raster = rasters[0]
in_template_dataset = shapefiles[0]
out_raster = ("clip_ads_" + year + raster.split(".")[0] + ".tif")
output_path = "Z:/Fall2016_GlacierNationalParkClimate/Term2/Charlotte/RGI_ADS_clip_output"
print(in_template_dataset)
#runs clip data management
clip = arcpy.Clip_management(in_raster, "#", output_path + out_raster, in_template_dataset, "#", "ClippingGeometry","NO_MAINTAIN_EXTENT")
... View more
03-02-2017
12:19 PM
|
0
|
6
|
4751
|
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:25 AM
|