-2

So as I know the Slice string looking the strings or the integers but here I don't know why exactly I've got that parameter [:-4]. What exactly the python looks, in order to execute the fireDamage Why I need that parameter while I have the path.

import arcpy 

arcpy.env.overwriteOutput = True 

arcpy.env.workspace = 'C:/gispy/data/ch06' 

outDir = 'C:/gispy/scratch/' 

fireDamage = 'special_regions.shp' 

fireBuffer = outDir + fireDamage[:-4] + 'Buffer.shp' 

bufferDist = '1 mile'

park = 'park.shp' 

clipOutput = outDir + park[:-4] + 'DamageBuffer.shp' 

arcpy.Buffer_analysis(fireDamage, fireBuffer,bufferDist) 

print '{0} created.'.format(fireBuffer) 

arcpy.Clip_analysis(park, fireBuffer, clipOutput) 

print '{0} created.'.format(clipOutput) 
anyryg
  • 313
  • 2
  • 13

1 Answers1

1

Its because fireBuffer must be: 'C:/gispy/scratch/special_regions/Buffer.shp' and not this: 'C:/gispy/scratch/special_regions.shp/Buffer.shp'.

Using fireDamage[:-4] you get special_regions instead special_regions.shp which would cause an error.

anyryg
  • 313
  • 2
  • 13