Quantcast
Channel: Question and Answer » arcpy
Viewing all articles
Browse latest Browse all 767

Convert raster to polygon then join attributes

$
0
0

I’m trying to convert IMG files to shapefiles, then joining the attributes of the IMG file to the new shapefile. I got the conversion part to work, but am a stuck on how to join the tables. I have these python scripts separately, but want to work within one. Below is the conversion. I have to do this to about 100 files.

>>> import os arcpy

#To overwrite output
arcpy.env.overwriteOutput = True

#Set environment settings
arcpy.env.workspace = "C:/Users/testfolder"

outws="C:/Users/segment_pgon/p"

#checkout ArcGIS spatial analyst extension license
arcpy.CheckOutExtension("Spatial")

inraster = arcpy.ListRasters("*", "IMG")

for i in inraster:
    filename=os.path.splitext(i)[0]
    outPolygons= outws + str(filename) + '.shp'
    field = "VALUE"
    arcpy.RasterToPolygon_conversion(i, outPolygons, "NO_SIMPLIFY", field)

Viewing all articles
Browse latest Browse all 767

Trending Articles