On Wed, Jul 14, 2010 at 3:11 AM, Joel C <[email protected]> wrote:
> Hello, i'm new here and I am attempting to modify attributes of a
> shapefile via python  I can't seem to get the shapefile to be
> updated!  Can anyone tell me what i'm doing wrong?
>
> import sys
> import osgeo.ogr as ogr
> import random
>
> ds = ogr.Open( "dist_google.shp", 1 )
> lyr = ds.GetLayerByName( "dist_google" )
>
> lyr.ResetReading()
>
> feat = lyr.GetNextFeature()
> while feat is not None:
>    print str(feat.GetFieldAsInteger("COLOR")),  # shows 0
>    feat.SetField(13,-1)
>    print "changed to: "+ str(feat.GetFieldAsInteger("COLOR"))    #
> shows -1
>    feat = lyr.GetNextFeature()
>
> ds.Destroy()
>
>
> ds = ogr.Open( "dist_google.shp", 1 )
> lyr = ds.GetLayerByName( "dist_google" )
> feat = lyr.GetNextFeature()
> while feat is not None:
>    print str(feat.GetFieldAsInteger("COLOR")),  # shows 0 !!!!
>    feat = lyr.GetNextFeature()

Your best bet would be to ask on gdal-dev

  http://www.osgeo.org/mailman/listinfo/gdal-dev/

This group isn't for help with GDAL, OGR, or ArcGIS.

-- 
Sean

Reply via email to