Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I currently working on some scripts with 3D polygons using arcpy (arcgis10). Reading and data manupulation works fine, however writing the output back into a shapefile doesn't seem to work, it only generated 2D files. for writing i use the following function:

import arcpy    
def write_new_MP(data,outfile):
        array = arcpy.Array()
        point = arcpy.Point()
        features=[]
        for feature in data:
            for part in feature:         
                point.X=part[0]
                point.Y=part[1]
                point.Z=part[2]
                array.add(point)
            MP=arcpy.Polygon(array,None,True,True)
            array.removeAll()
            features.append(MP)
        arcpy.CopyFeatures_management(features, outfile,"", "0", "0", "0")
        return

the data is a list likedata=[[[5,5,5],[10,5,5],[10,10,5],[5,10,5],[5,5,5]],[[15,15,15],[10,15,15],[10,10,15],[15,10,15],[15,15,15]]]

Does somebody know why the Z-values aren't used when generating the output?

share|improve this question
    
How have you confirmed that the Z isn't written to the file? Are you viewing this in the 3D analyst? –  Dan Patterson Jun 15 '11 at 15:14
    
by viewing in arcscene, all objects appear flat no matter what z-data is written –  Paul Jun 16 '11 at 7:29
    
Depending on your data you might also need to include another nested loop to account for multi-part features (an array of arrays). So it would go Features -> Parts -> Vertices. –  blah238 Oct 30 '11 at 1:11
add comment

3 Answers 3

The CreateFeatureClass_management has the necessary flags to enable Z values whereas CopyFeatures_management does not. Perhaps that is the necessary switch you need to make.

share|improve this answer
add comment

Let me say first that I spent few minutes learning what GIS is and few more minutes learning what arcpy is. In addition, I do not have required software to check your code. However, the similarity of your code and the code at Arc Gis Resource Center-Desktop10-polygon example-Create a polyline feature class from scratch is striking. What is missing in your code is the following.

"Add the first point of the array in to close off the polygon"

array.add(array.getObject(0))

in between your lines

array.add(point)
MP=arcpy.Polygon(array,None,True,True)

Did you try that already?

share|improve this answer
add comment

Are you using an existing feature class or are you creating the fc as part of this script? If it is part of the script can you post that portion as well? How are you setting the coordinate system, etc?

share|improve this answer
    
I don't have enough privilege to comment so please accept this "Answer" as a comment. It appears I am 8 points away! –  theJones Oct 28 '11 at 17:11
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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