Aug 12, 2009 at 12:29 PM
Edited Aug 12, 2009 at 12:58 PM
Thanks fobermaier and johndiss for your replies. I really appreciate!
But the thing is that I don't want to use converters. I create a new, blank shapefile and then I start adding features from an existing, "genuine" shapefile.Actually, is not really blank, because the create method from the shapefile class writes
the file header.
So, if I didn't make myself understanded in the first post , converting, copying etc is not an option. I need a blank .shp (from the features' and geometries' point of view)
Also, another thing I have missed to mention, I don't use the SharpMap 2.0 from googlecode.com, but the old SharpMap 2.0 from here, from codeplex
Here is a piece of my code:
public void LoadShapefileLayer(ShapeFile OriginalShapefile,ShapeFile NewShapeFile)
if (OriginalShapefile.ShapeType != ShapeType.Polygon && OriginalShapefile.ShapeType != ShapeType.PolyLine
&& OriginalShapefile.ShapeType != ShapeType.MultiPoint && OriginalShapefile.ShapeType != ShapeType.Point)
int Count = OriginalShapefile.GetFeatureCount();
//List<Geometry> geometry = new List<Geometry>();
BoundingBox ext = OriginalShapefile.GetExtents();
IEnumerable<Geometry> geometries = OriginalShapefile.GetGeometriesInView(ext);
foreach (Geometry geom in geometries)
// List<SharpMap.Geometries.Point> points = new List<SharpMap.Geometries.Point>();
FeatureDataSet fds = new FeatureDataSet();
FeatureDataTable fdt = fds.Tables;
if (fdt.Rows.Count > 0)
foreach (FeatureDataRow fdr in fdt.Rows)
Both files are opened; OriginalShapefile is enabled for reading and the NewShapefile is enabled for writing.
Ok, don't bother to test the code, it doesn't works.
<EDIT1> : // A strange thing is that count is 0 and I don't have any idea why, honestly..1
Count is not 0 anymore. Reason was... well... kind of stupid.. I've commented out some lines in Open(..) method, the ones that parsed the index and projection. Counting is ok now,,
<EDIT2>: well, it kind of works. I mean something like : both the original and the newly created have the same size, somewhere around 2 mb.. But.. When i open the new shape, with the debugger, some features aren't there. Like the envelope box. which
is empty. also, i don't have the same number of features. In the original one, the variable Count is ~ 70k, while in the new one it's ~ 50. att: 50, not 50k.
What am I doing wrong?
I need to see this working, before I start adding color and style info directly in the .shp
I hope you understand what I want (I'm not really good in explaining to others what I want to do :) )
Thanks again for support and I expect to hear (or read :P ) from you :)
By the way, nice job that you are doing here, with SharpMap!