NetTopologySuite / NetTopologySuite.IO.Esri

BSD 3-Clause "New" or "Revised" License
31 stars 16 forks source link

Editing attribute data of an existing shapefile, using VB.NET #17

Closed SiebeBosch closed 1 year ago

SiebeBosch commented 1 year ago

Hi all,

I am applying your library in order to adjust attribute values in an existing polygon shapefile. What is the best way to approach this? Here is my code so far. However it does not work and returns an error saying the file is already in use by another process. Also if I change the results filename I get an error: "value cannot be null, parameter name: Geometry"

        Dim ShapeReader As New NetTopologySuite.IO.Esri.Shapefiles.Readers.ShapefilePolygonReader("full.shp")
        Dim myFeature As NetTopologySuite.Features.Feature
        Dim Deleted As Boolean
        While ShapeReader.Read(Deleted, myFeature)
            myFeature.Attributes.Item("GFEIDENT") = "new value"
        End While

        Dim options As New ShapefileWriterOptions(ShapeReader)

        Using myWriter As New NetTopologySuite.IO.Esri.Shapefiles.Writers.ShapefilePolygonWriter("full.shp", options)
            myWriter.Write()
        End Using

Thanks in advance for your help! Siebe Bosch

DGuidi commented 1 year ago

the editing is not supported (at least, I think), you need to write the data to a new file with a different name

SiebeBosch commented 1 year ago

Thanks