1

I have a very big multipoint feature class (in ArcGIS 10 imported from XYZ .txt files) and I have a shapefile which contains 50 polygons. (If I look at the attribute table, the 50 polygons are separated)

Now I want to split up the big multipoint feature class in smaller parts so that they have the extends of my polygons. After that I want to export the small parts again as XYZ .txt files.

Is there a possibility to to this automatically / with a batch operation? In ArcGIS I tried the "split" command which crashes with error 9999999.

Otherwise I would have to make 50 single shapefiles out of the single one with the polygon and then clip the big multipoint feature class 50 times with every single file.


I wrote a script that needs a feature class with several polygons and another feature class with multipoints (e.g. generated from 3dAscii to feature from the 3D toolbox). as input. The script then iterates through all the polygons, clips the multipoint layer with each polygon and exports the result as ASCII3D files. (In addition I included a function that adds a offset to the z coordinate of each clipped multipoint. therefore each polygon needs an attribute "Add_mm".

Here is the script:

##Script Name: MultiClipPolygon
##Description: Clip one feature class with all polygons in another feature class
##from a folder and places the clipped
##feature classes into a Geodatabase.
##Created By: Mathias Schlagenhauser
##Date: 2016 / 8 / 8

#Import standard library modules
import arcpy, sys , os, arcgisscripting, time, string

# Check if the neccesary tools are licensed
arcpy.CheckOutExtension('3D')

arcpy.env.parallelProcessingFactor = "100%" 

FC_ToBeClipped = arcpy.GetParameter(0)
polygonFeatureClass = arcpy.GetParameter(1)
outputFolder = arcpy.GetParameter(2)

# Settings for the Z feature to  ASCII
outFormat = "XYZ"
delimeter = "SPACE"
decimal = "FIXED"
digits = 3
dec_sep = "DECIMAL_POINT"


# the in memory is a virtual space in RAM which is very fast and used to store the temporary files
arcpy.Delete_management("in_memory")

arcpy.AddMessage("-----------------------------------------------\n")        
# iterate through every polygon in the polygon feature class
for single_polygon in arcpy.da.SearchCursor(polygonFeatureClass, ["SHAPE@", "NAME","Add_mm"]):

    nameOfTEMPFile = "in_memory" + "\\" + str(single_polygon[1])+"_MP"
    #nameOfTEMPFile = str(outputFolder) + "\\" + str(single_polygon[1])+"_MP.shp"
    nameOfFINALFile = str(outputFolder) + "\\" + str(single_polygon[1]) + ".txt"

    if  not(arcpy.Exists(nameOfFINALFile)):

        arcpy.AddMessage("Clipping Input with: "+single_polygon[1]+"...")
        arcpy.Clip_analysis(FC_ToBeClipped, single_polygon[0], nameOfTEMPFile,"")
        arcpy.AddMessage("Clipping FINISHED.")
        mmToAddToZ = single_polygon[2]
        arcpy.AddMessage ("Z-Offset aktuelles Polygon: " + str(mmToAddToZ) + "mm")
        if (mmToAddToZ !=0 ):
            arcpy.AddMessage("Z-Korrektur gestartet...") 
            mToAddToZ = mmToAddToZ / 1000.00 
            arcpy.AddMessage("Korrektur um [m]: " + str(mToAddToZ)) 
            arcpy.Adjust3DZ_management (nameOfTEMPFile, "", mToAddToZ, "", "")
        else:
            arcpy.AddMessage("Keine Z-Korrektur nötig...") 

        #Aus dem geclippten Shapefile drei Attribut Spalten auslesen
        with arcpy.da.UpdateCursor(nameOfTEMPFile,["OID@", "SHAPE@", "PointCount" ] ) as cursor:
            totalPoints = 0
            # Alle zusammengefassten Punktpackages (Multipoint) durchgehen

            for row in cursor:   
                totalPoints += row[2] 

            arcpy.AddMessage("Number Of Points: "+ str(totalPoints))

            if (totalPoints > 50):
                arcpy.AddMessage("Exporting ASCII...")
                arcpy.FeatureClassZToASCII_3d(nameOfTEMPFile, outputFolder, nameOfFINALFile, outFormat, delimeter, decimal, digits, dec_sep)
                arcpy.AddMessage("Exporting ASCII DONE...")
                arcpy.Delete_management(nameOfTEMPFile)
            else:
               arcpy.AddMessage("Empty Output, will be skipped")

            arcpy.AddMessage("-----------------------------------------------\n")
    else:
        arcpy.AddMessage("File exists, skipped")
4
  • If you have Windows 64 bit, have you installed 64bit Background Processing and enabled it? error 999999 is sometimes an out of memory error.
    – klewis
    Aug 4, 2016 at 16:59
  • I have Windows 64bit but the 64bit background is not enabled as I work in a PDB personal file database. would the "Split" command do the right thing for me?
    – Mathiaas
    Aug 5, 2016 at 9:51
  • I think Split is correct for what you want, to clip the Points by each Polygon, creating 50 featureclasses.
    – klewis
    Aug 5, 2016 at 12:40
  • I'm not sure if I made a mistake by appending your answer into your question as being about how to see the problem rather than how to solve it. If the latter let me know and I can rollback what I did.
    – PolyGeo
    Sep 30, 2016 at 1:17

1 Answer 1

0

Assuming that you are hitting a memory, hardware or software limitation trying to use Split of so many points into 50 shapefiles as part of a single operation, the way that I would do this is using the following pseudo code with ArcPy.

  1. Iterate through your 50 polygon shapefile using arcpy.da.SearchCursor()
  2. Use the SHAPE@ token to access the geometry of each polygon
  3. Clip the point feature class using each polygon geometry

If clipping by any individual polygons still gives an error then try using arcpy.env.extent to reduce the processing extent to just that of each polygon.

0

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