I'm trying to convert a raster with multiple columns to a point shapefile to get rid of the "count" column but unfortunately the tool "raster to point" works just for one column so I tried to modify this code to write the atribute table to a csv file but it still doesn't work.
I just get a lot of zeros in my outfile. Why am I get just a bunch of zeros?
I'm using ArcMap.
This is the modified code:
outfile = Workspace + "/table" fOut = open(outfile, "wb") fOut.write('ID' + ',' + 'Flowaccumaltion' + ',' + 'Flowlength\n') rstArray = arcpy.RasterToNumPyArray(Combined_Raster) rows, cols = rstArray.shape for rowNum in xrange(rows): for colNum in xrange(cols): if colNum == 1 or colNum == 3: value = rstArray.item(rowNum, colNum) fOut.write(str(value) + ',') elif colNum ==4: value = rstArray.item(rowNum, colNum) fOut.write(str(value) + '\n') fOut.close()
This is the raster attribute table I want to convert
And I would like to get something like this:
ID , Flowaccumulation, Flowlength 57 , 727 , 1 58 , 727 , 1 0 , 76073 , 1008 1 , 14919 , 622 . , . , .
But if there is a tool which can convert a raster to a point shapefile with all fields except for the "count" field then this would be even better.