Polygon shapefile with null values?

I assume you mean null for the geometry/shape column, because shapefiles don't support null for any field type except the geometry and (i hear) for date fields.

The code below creates 1 shapefile with 1 record/feature that has a null poly geometry.


  import arcpy
  import os
  outfc = r'c:\temp\outfc.shp'
  arcpy.env.workspace = os.path.dirname(outfc)
  arcpy.CreateFeatureclass_management(arcpy.env.workspace,os.path.basename(outfc), 'polygon')
  cur = arcpy.InsertCursor(outfc)
  row = cur.newRow()
  cur.insertRow(row)
  del(row)
  del(cur)
  r = arcpy.CheckGeometry_management(outfc,'in_memory\\outtable')
  print r.getMessages()



I run it and get this which is what i'd expect

WARNING 000442: null geometry at 0 in c:\temp\outfc.shp


Be warned that a lot of software reading SHP files do not support null-values for the geometry. Even older versions of ArcView had problems.

I have created a sample here: http://www.routeware.dk/temp/shp_null_sample.zip It has 3 records, the 2nd has no geometry.

Tags:

Shapefile