import arcpy
log = open('error_log','a')
arcpy.env.workspace = 'J:\\raster\\raster\\fastighet'
arcpy.env.compression = 'LZW'
#arcpy.env.overwriteOutput = True
sqaure_coast = 'J:\\raster\\raster\\raster.gdb\\sweref_Square_coast'
property_map = 'C:\\Users\\admin\\Desktop\\property.sde\\PROPERTYMAP?.GISSDEADM?.SR_08_PROPERTYMAP?'
x = arcpy.SearchCursor?(sqaure_coast)
for s in x:
file_name = 'f_'+str(s.index5km)+'.tif'
if arcpy.Exists('J:\\raster\\raster\\fastighet\\' + file_name):
print str(s.index5km) + ' Found'
continue
else:
print str(s.index5km) + ' Not Found trying the clip'
try:
arcpy.Clip_management(property_map,"#",file_name,s.SHAPE?,"0","NONE?")
except:
print 'Error in ' + file_name
log.write('Error in ' + file_name)
log.flush()
log.close()
print 'done'
The above open a .lyr file called property.sde and grabs the layer \\PROPERTYMAP?.GISSDEADM?.SR_08_PROPERTYMAP? which is pretty smooth if you have an sde file, personally I want to do this in code. I think I have a way to do it, stay tuned.
Everything seen here is
#!/usr/bin/env python # -*- coding: utf-8 -*- # # Copyright 2011? # # # Note: This document should follow pythons style guide Pep-0008? (http://www.python.org/dev/peps/pep-0008?/), # however, I make no promises for one shot things # # Licensed under the MIT license; # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # # THE SOFTWARE? IS PROVIDED? "AS IS", WITHOUT? WARRANTY? OF ANY KIND?, EXPRESS? OR # IMPLIED?, INCLUDING? BUT NOT LIMITED? TO THE WARRANTIES? OF MERCHANTABILITY?, # FITNESS? FOR A PARTICULAR? PURPOSE? AND NONINFRINGEMENT?. IN NO EVENT? SHALL? THE # AUTHORS? OR COPYRIGHT? HOLDERS? BE LIABLE? FOR ANY CLAIM?, DAMAGES? OR OTHER? # LIABILITY?, WHETHER? IN AN ACTION? OF CONTRACT?, TORT? OR OTHERWISE?, ARISING? FROM?, # OUT OF OR IN CONNECTION? WITH? THE SOFTWARE? OR THE USE OR OTHER? DEALINGS? IN # THE SOFTWARE?.