This project has moved and is read-only. For the latest updates, please go here.

How to assign attributes to individual row of a shapefile

Feb 17, 2010 at 3:47 PM

Hi All,

I am trying to assign attributes to each geometry in a shapefile. For ex. I have 5 linestrings in my postgis table. I want to assign each linestring some value which will differentiate them from one another. 

However, I want to carry out this procedure dynamically. I am creating postgis tables using C#. (not using QGIS for assigning attributes). 

I am aware of selection of shapefile rows depending on their attributes so once I assign them attributes, I want to show this attributes on map in the form of text.

Is there any way to give attributes to each row in postgis table from command line (C#)?

Please let me know if anyone has any idea about it..



Feb 17, 2010 at 3:53 PM

Hi Siddhesh All the 0.9 providers are read only, you will have to modify the data at source - or use a GeometryFeatureProvider and copy the geometries into it. cheers js

Feb 17, 2010 at 4:13 PM

Thanks John for the reply.

May I know where can I get some sample code that involves GeometryProvider and Geometry classes to add attributes to row of shapefile? 


I am doing following :

I read one simple (not geometry) database which contains co-ord for a point but they are represented by varchar().

After getting two points from this database, I use these points to generate a table called 'lines' and store a line joining these two points in this table. 

Such a way, I keep reading and inserting lines in postgis database.

After everything is done, I import this lines from postgis to c# application using sharpmap.


When you suggested me to use GeometryProvider class and Geometry class, I tried making use of it and then I was wondering, Is it possible to display lines directly in a picturebox using GeometryProvider and Geometry classes without storing table 'lines' in postgis database?