0

I have tried to get this to work but have ran in to this error

Runtime error Traceback (most recent call last): File "", line 11, in ExecuteError: Error creating point Name: on feature 0 Failed to execute (CreateFeaturesFromTextFile).

  # Create geoprocessing dispatch object
  import arcgisscripting
  gp = arcgisscripting.create()

   # Set up inputs to tool
  inTxt = r"C:\Users\Kevin\Desktop\Geoprograming\WeekSeven\Propety.txt"
  inSep = ","
  strms = r"C:\Users\Kevin\Desktop\Geoprograming\WeekSeven\Property.shp"

  # Run tool
  gp.CreateFeaturesFromTextFile(inTxt, inSep, strms, "#")

  # Use output from createfeatures tool as input to buffer
  outFCbuf = r"C:\Users\Kevin\Desktop\Geoprograming\WeekSeven\PropertyBuf.shp"
  gp.buffer(strms, "10 Unknown", "FULL", "ROUND", "NONE", "#")

my text file looks like this

  polygon
Spatial Reference: 43006
Name: Jones Tract
424564.620666, 4396443.55267
425988.30892, 4395630.01652
426169.09473, 4395426.63249
426214.291182, 4395268.4449
426259.487635, 4395065.06087
426259.487635, 4394409.7123
426010.907146, 4394183.73004
425762.326657, 4394115.93536
425513.746168, 4394093.33714
425287.763906, 4394048.14068
425106.978096, 4394025.54246
424858.397607, 4393776.96197
424655.013571, 4393641.37261
424361.236629, 4393709.16729
424180.450819, 4393957.74778
424293.441951, 4394748.6857
424361.236629, 4395087.65909
424519.424213, 4395268.4449
424632.415344, 4395675.21297
424609.817118, 4396014.18637
424564.620666, 4396443.55267
  • 1
    What version of ArcGIS Desktop are you using? – PolyGeo Aug 2 '16 at 21:44
  • 1
    What version of ArcGIS are you using? It looks like 8.3 which is now obsolete. The tool you are using requires a specific format for polygons that is not quite the same as your example. This tool is also deprecated – kimo Aug 2 '16 at 21:45
1

The format required for the tool is a special format that is only produced by the complementary tool to dump out geometry. From the original help sample.

Text files that represent polygons should be in the following format: The first line should contain the word Polygon to indicate the geometry type and the structure continues with the id number of the first line, followed by the part number (in case it is a multipart polygon). Point coordinates for the respective part and feature follow. In the case of an interior ring, the word InteriorRing (no space) is written before the group of coordinates. Polygons should be closed, that is, the first and last points should be the same. The final line should contain the word END. Generically, it will look like this: Polygon polygon_id part_number pnt_id x y z m pnt_id x y z m ... InteriorRing pnt_id x y z m pnt_id x y z m ... polygon_id part_number pnt_id x y z m pnt_id x y z m ... END In the example below, there are two polygons. Polygon zero has two parts. The second part has an interior ring. Polygon one is a normal polygon. Polygon 0 0 0 5.0 5.0 1.#QNAN 1.#QNAN 1 5.0 6.0 1.#QNAN 1.#QNAN 2 6.0 6.0 1.#QNAN 1.#QNAN 3 6.0 5.0 1.#QNAN 1.#QNAN 4 5.0 5.0 1.#QNAN 1.#QNAN 0 1 0 0.0 0.0 1.#QNAN 1.#QNAN 1 0.0 4.0 1.#QNAN 1.#QNAN 2 4.0 4.0 1.#QNAN 1.#QNAN 3 4.0 0.0 1.#QNAN 1.#QNAN 4 0.0 0.0 1.#QNAN 1.#QNAN InteriorRing 0 1.0 1.0 1.#QNAN 1.#QNAN 1 1.0 3.0 1.#QNAN 1.#QNAN 2 3.0 3.0 1.#QNAN 1.#QNAN 3 3.0 1.0 1.#QNAN 1.#QNAN 4 1.0 1.0 1.#QNAN 1.#QNAN 1 0 0 5.0 3.0 1.#QNAN 1.#QNAN 1 5.0 4.0 1.#QNAN 1.#QNAN 2 6.0 4.0 1.#QNAN 1.#QNAN 3 6.0 3.0 1.#QNAN 1.#QNAN 4 5.0 3.0 1.#QNAN 1.#QNAN END (you don't need the 1.#QNAN fields)

Polygon
0 0
0 424564.620666 4396443.55267
1 425988.30892 4395630.01652
2 426169.09473 4395426.63249
3 426214.291182 4395268.4449
4 426259.487635 4395065.06087
5 426259.487635 4394409.7123
6 426010.907146 4394183.73004
7 425762.326657 4394115.93536
8 425513.746168 4394093.33714
9 425287.763906 4394048.14068
10 425106.978096 4394025.54246
11 424858.397607 4393776.96197
12 424655.013571 4393641.37261
13 424361.236629 4393709.16729
14 424180.450819 4393957.74778
14 424293.441951 4394748.6857
15 424361.236629 4395087.65909
16 424519.424213 4395268.4449
17 424632.415344 4395675.21297
18 424609.817118 4396014.18637
19 424564.620666 4396443.55267
END
END

Note only one space between numbers, no commas. This is an obsolete and oversimple demo example that has been removed as a tool. It hangs about for backward compatibility, so you won't see any documentation.


    import arcgisscripting
gp = arcgisscripting.create()

inTxt = 'j:/workspace/test.txt'
inSep = '.'
strms = 'j:/workspace/streams.shp'
gp.CreateFeaturesFromTextFile(inTxt, inSep, strms, "#")
print "success!"

  • I'm using Arc 10.4 and the above formatting didn't work – kevin Aug 2 '16 at 22:09
  • You should give up 8.3 style scripting and use the arcpy module. I did get the example to work, but note: The separator refers to the decimal point and a comma would be the continental style. You must use space (and only one space!) between numbers. It does not define a projection. Better to load the data as points from a csv file (edit the header to define fields X and Y and then convert this to points and then polygons with the standard current toolbox. – kimo Aug 4 '16 at 2:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.