Py-Visvalingam-Whyatt
Py-Visvalingam-Whyatt copied to clipboard
Use of simplifier.from_threshold() with GDALSimplifier
What is the proper way to use simplifier.from_threshold() with the GDALSimplifier.
I see there is no build_threshold method in this class. What is the threshold arguments that is needed by the from_threshold() method?
Build_thresholds is called on init and you don't need to mess with it. From_threshold only takes one argument, the smallest area you want to keep.
To get an idea of scale, look at X.simplifiers[0].ordered_thresholds where X is a GDALSimplifier instance. On Aug 21, 2014 10:25 AM, "DemarsM" [email protected] wrote:
What is the proper way to use simplifier.from_threshold() with the GDALSimplifier.
I see there is no build_threshold method in this class. What is the threshold arguments that is needed by the from_threshold() method?
— Reply to this email directly or view it on GitHub https://github.com/Permafacture/Py-Visvalingam-Whyatt/issues/6.
I think its X.simplifiers[0][0].ordered_thresholds (maybe because input is a multipolygon ?)
The output geometry might be invalid doing:
simplifier = GDALSimplifier(feat.geom_multipolygon.ogr)
WS_ogr = simplifier.from_threshold(simplifier.simplifiers[0][0].ordered_thresholds[0])
one polygon inside the multipolygon returned might have less than 3 nodes and that make the whole geometry to be invalid. I dont have this issue using from_number()
No! Pick a value for the threshold. Pick one that represents the level of accuracy you want. I said look at ordered_thresholds to get an idea of what range your working in.
If you set the threshold to infinity (which I'm pretty sure you are doing), then I'd expect your polygons would all be useless. On Aug 21, 2014 12:03 PM, "DemarsM" [email protected] wrote:
I think its X.simplifiers[0][0].ordered_thresholds (maybe because input is a multipolygon ?)
The output geometry might be invalid doing:
simplifier = GDALSimplifier(feat.geom_multipolygon.ogr) WS_ogr = simplifier.from_threshold(simplifier.simplifiers[0][0].ordered_thresholds[0])
one polygon inside the multipolygon returned might have less than 3 nodes and that make the whole geometry to be invalid. I dont have this issue using from_number()
— Reply to this email directly or view it on GitHub https://github.com/Permafacture/Py-Visvalingam-Whyatt/issues/6#issuecomment-52950280 .
the threshold was not set to inf... even if I use a float
simplifier = GDALSimplifier(feat.geom_multipolygon.ogr)
WS_ogr = simplifier.from_threshold(400.554)
the error is still there. As I said, I check the wkt of the error geometry, and there was only 2 nodes
Please post the wkt of the shape that causes the error with that threshold. On Aug 21, 2014 1:44 PM, "DemarsM" [email protected] wrote:
the threshold was not set to inf... even if I use a float
simplifier = GDALSimplifier(feat.geom_multipolygon.ogr) WS_ogr = simplifier.from_threshold(400.554)
the error is still there
— Reply to this email directly or view it on GitHub https://github.com/Permafacture/Py-Visvalingam-Whyatt/issues/6#issuecomment-52964119 .
The WKT is too big to be paste, but you can try with the following shapefile https://drive.google.com/file/d/0B5KYgySq75o_aWtJQTFTMFVSZTQ/edit?usp=sharing
threshold set to 400.554, you will have some feature with 2 nodes in the output
I'm not at a place to look at this right now. The algorithim should make an arealess polygon (ie, a line) when you choose a threshold close enough to the area of the shape. I can fix any errors raised, but if you choose a threshold that makes the whole shape go away then you get what you get.
Ordered_thresholds[0] will make the whole shape go away. On Aug 21, 2014 2:35 PM, "DemarsM" [email protected] wrote:
The WKT is too big to be paste, but you can try with the following shapefile
https://drive.google.com/file/d/0B5KYgySq75o_aWtJQTFTMFVSZTQ/edit?usp=sharing
threshold set to 400.554, you will have some feature with 2 nodes in the output
— Reply to this email directly or view it on GitHub https://github.com/Permafacture/Py-Visvalingam-Whyatt/issues/6#issuecomment-52970771 .
Hmmm. I'm not sure what to do if a whole shape is below the threshold. It should be up to the user to exclude rendering of polygons with zero area, but holes of zero area should be removed by the algorithm I think. On Aug 21, 2014 3:26 PM, "Elliot Hallmark" [email protected] wrote:
I'm not at a place to look at this right now. The algorithim should make an arealess polygon (ie, a line) when you choose a threshold close enough to the area of the shape. I can fix any errors raised, but if you choose a threshold that makes the whole shape go away then you get what you get.
Ordered_thresholds[0] will make the whole shape go away. On Aug 21, 2014 2:35 PM, "DemarsM" [email protected] wrote:
The WKT is too big to be paste, but you can try with the following shapefile
https://drive.google.com/file/d/0B5KYgySq75o_aWtJQTFTMFVSZTQ/edit?usp=sharing
threshold set to 400.554, you will have some feature with 2 nodes in the output
— Reply to this email directly or view it on GitHub https://github.com/Permafacture/Py-Visvalingam-Whyatt/issues/6#issuecomment-52970771 .
I dont know what would be the best for the algorithm, but as a user I find it hard to set a threshold when dealing with multipolygon features, because part of it could be really small compared to the whole feature area. But knowing the issue now, I think filtering 0 area parts can be done outside of the algorithm too. It's your choice to include a fix or not.
I wonder if just using from_ratio() could be the safest option. Is it as fast as from_threshold() ?
Yea. It just grabs a threshold from ordered_thresholds first and then calls from_threshold. Zero speed difference.
Well, if you're losing an entire shape with that threshold, you're also losing areas that size at all the corners and details. I think if the hole is worth rendering, those areas around the big polygons are worth rendering too. Up to you of course.
Like, if you set the threshold to about the area of a pixel or two at the current zoom level, you'll never see inaccuracy.