Hello,
I can quickly delete features from a shapefile based on a series of column values ?
What approach would be the most performant ?
Tomas
Hello,
I can quickly delete features from a shapefile based on a series of column values ?
What approach would be the most performant ?
Tomas
Tomas,
You can use EditTools of ShapeFileFeatureLayer and use UpdateFeature method pass in features with empty column values, we have sample "EditFeaturesFromAFeatureLayer" in HowDoI sample to show how to update feature.
Please let me know if you have more questions,
Thanks,
James
James,
Thanks. The samples deal with deleting one feature. I know how to do that. I was asking for a situation with many features to delete in a large file.
In my previous question I wondered why the sql query to delete items doesn’t work. I need to delete 40k features roughly from a 300k features shapefile. I can do it via the EditTools moethods, but it takes rather long. Similar query in SQL server takes couple seconds. I know shapefile is not sql server when it comes to manipulating data, but still 1hours seems rather long to do this operation.
Tomas
Tomas,
I think the edit tools is probably the right way to delete target features from shape file no matter you want to delete one feature or multiple features.
While I think there might be a trick way using spatial index technique to speed it up, please take some considerations against it. Following are basically the steps:
1) Get all features out into memory using GetAllFeaturesAPI or GetFeaturesInsideBoundingBox which is 300K features.
2) Filter out those target deleted features (40k).
3) Building a new spatial index for the remaining 260K features from Step2.
4) When using the shape file again, use the new idx file from step3.
I do not think this solution will work for any case, so please consider it if it can work for your case.
Thanks.
Yale
Yale,
Thank you. I'll give it a shot.
Tomas
Thank Yale.
Tomas,
Let us know your result for trying.
James