I am trying to convert stream segments to text. This is function for the script
#function to convert feature to text as ungenerate command in ArcGIS workstation
def featureTotext(path,feature,TextFileName):
import string, os, sys, locale, arcgisscripting
gp = arcgisscripting.create()
gp.overwriteoutput = 1
msgNotEnoughParams = "Incorrect number of input parameters."
msgUseValidDecimalPointSep = "Please use one of the valid decimal point separators."
try:
os.chdir(path)
inputFC = feature
outFile = open(TextFileName, "w")
sepchar=""
inDesc = gp.describe(inputFC)
inRows = gp.searchcursor(inputFC)
inRow = inRows.next()
# outFile.write(inDesc.ShapeType + "\n")
while inRow:
feat = inRow.GetValue(inDesc.ShapeFieldName)
partnum = 0
partcount = feat.partcount
while partnum < partcount:
outFile.write("\t"+str(inRow.GetValue('GRID_CODE')) + "\n")
print inRow.GetValue('GRID_CODE')
part = feat.getpart(partnum)
part.reset()
pnt = part.next()
pnt_count = 0
while pnt:
outLine = "\t" + str(pnt.x) + "\t" + str(pnt.y) + "\n"
if sepchar == "": outFile.write(outLine)
else: outFile.write(outLine.replace(".", sepchar))
pnt = part.next()
pnt_count += 1
if not pnt:
pnt = part.next()
if pnt:
outFile.write("InteriorRing\n")
partnum += 1
outFile.write("END\n")
inRow = inRows.next()
outFile.write("END")
outFile.flush()
outFile.close()
print outFile
except Exception, ErrorDesc:
gp.AddError(ErrorDesc[0])
if outFile: outFile.close()
gp.AddError(gp.getmessages(2))
This script gives output similar as the "ungenerate" command in ArcGIS workstation. When used, this function gives the fewer output points than using the ungenerate command.
Output from this function look like :
1354
391367.254831 9456327.37568
389617.254831 9458077.37568
389617.254831 9459077.37568
388117.254831 9460577.37568
387117.254831 9460577.37568
380117.254831 9467577.37568
END
I want to have more points (smaller interval) while extracting X and Y coordinates from a feature. How can I do this ?