0

I'm currently stuck on this issue, I've tried almost everything but didn't get further than this. What I'm trying to do is read the shapefile and extract the data to save it in my PostGIS database(Custom Tables). What I am currently doing is saving the zip file in /temp folder, extracting it and reading it afterwards using ShapeDataReader from NetTopologySuite.IO.ShapeFile.Extended but there seems to be no option reading it as a stream.

This is my function to read it from the /temp path:

public IEnumerator<IShapefileFeature> ReadShapeFile(string path)
{
    ShapeDataReader reader = new ShapeDataReader(path);
    var shpBounds = reader.ShapefileBounds;
    var result = reader.ReadByMBRFilter(shpBounds);
    var coll = result.GetEnumerator();

    return coll;
}

After getting the data I just loop over it and extract the necessary data. The thing is I don't want to extract it anywhere, because I will have multiple clients that are importing their own data in my application and it doesn't seem to be a good approach to save it on the drive.

3
  • 2
    Creating temporary local working directories is way easier than waiting for someone to alter code to the way you want it to behave. – Vince May 3 at 16:17
  • Hi , thanks for the reply. I think you are correct on this one, I don't really have time to waste. I've tried this in the past, but when I attempted to delete the uploaded files afterwards, there's something that still uses my files. Might be the ShapeDataReader, not really sure. That was the reason why I was searching for a different approach. – dtkturpal May 3 at 16:55
  • How I fixed this: I ended up using the /temp directory. The reason I couldn't delete the files was because of the ShapeDataReader. After I was done with using the data I just call the .Dispose() on the reader. – dtkturpal May 3 at 17:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.