How do I use code (preferably c#) to clip all points within a shapefile that are not

المشرف العام

Administrator
طاقم الإدارة
So the task is simple: I want to take a point shapefile as input and remove all of the points that are not contained within a polygon.

I'm using DotSpatial to do this, but the catch is that there are millions of points, and it's just... hilariously slow.

I'm using some code that looks like this:

for (int i = 0; i < points.ShapeIndices.Count - 1; i--){ if (polygons.ShapeIndices[activeRow].Intersects(points.ShapeIndices)) { allPoints.Add(points.Features); }}This takes minutes to do 80,000 points. There's obviously something janky with their implementation but I don't have time to run it down.

So my question is, if you had to get this done and introduce minimal dependencies, how would you do it? I could install PostGIS and load the shapefiles into PostGIS to do the contains operation, but I am loath to introduce a database into this project.



أكثر...
 
أعلى