2

I have an application in which users can upload a shapefile which is then converted to WKT in C# and saved to the database. I'm using DotSpatial for this purpose. In this case, I can use the following code and then proceed to do what I want:

IFeatureSet fs = FeatureSet.OpenFile("C://MyShapefile.shp");
for (int i = 0; i < fs.NumRows(); i++)
{
    string wkt = fs.GetShape(i, true).ToGeometry().ToString();
}

However, I would like to be able to upload a zipped shapefile directly and work with it, without having to extract it and only upload the .shp file.

I have looked around about this, but haven't managed to find anything that does what I want. Is it possible to maybe just read the shapefile data from a stream while extracting the zip file in code behind? Or is there some other way to do this?

Raj
  • 315
  • 4
  • 15
  • I think my project was similar to yours, I have the user submit a zipped shapefile which I then manipulate and store the data into a database. After going through some documentation I believe the only way is to unzip the file yourself and then refer to your unzipped .shp file. I never found a way for dotspatial to handle the zipfile or any other input streams. – Lyco Jul 23 '18 at 21:48
  • Thanks Char. That's probably what I'll end up doing as well. – Raj Jul 24 '18 at 18:17

0 Answers0