Hi all,
how can I change the size of a polygon? I need to be able to increase/decrease it by user entered feet size. In case of a simple square/rectangle, I just add the entered value to XMax, XMin, YMax and YMin, but I'm not sure how I can do that with weird shaped polygons?
Thanks,
how about using buffering with some constraint on area (just a thought)
could you please elaborate? not sure I understand. You mean I first compute the area of the polygons, and then increase that?
Yes you can compute the area of the polygon using geometry service then increase the area
True, the area could be computed just as easily. I am more perplexed about how I can use the result to increase/decrease the polygon's size? Sorry I must be missing some simple point.
Thanks.
This is what I did and I don't know if its the right way or some one can suggest a better way but...
(Buffering creates round edges)
1. Draw some crazy polygon and calculate its area (a1)
2. Buffer it by say 1km and calculate its area (a2)
3. calculate the times increase in area x1=(a2/a1) which indicates for every 1km buffer your area increases by (a2/a1) times
4. ask the user how many sq km he wants to increase the polygon (a3)
5. calculate the times increase in area x2= (a1+a3)/a1
6. calculate buffer distance x2/x1
7. Draw the new polygon using the original polygon with new buffer distance
I wrote a small app for this and it works for me either if user wants to increase/decrease area
hmm. I'll certainly try that out. But before I do so, I should confess that I seem to have been looking at my issue from a stupid angle. What I really had been trying to do was draw a buffer polygon around any polygons.
In my case, these polygons are parcels. When user enters 'x' buffer size in feet and clicks on a parcel, it should essentially draw a buffer polygon around that parcel with the exact same shape, only bigger in area. A use case for this would be to determine what others parcels reside ten feet away from the selected parcel.
I was poking around with geometry server while calculating parcel's area, then I realized that it had a buffer function to meet my needs better. Using that, I tentatively achieved what I had needed, but it still isn't quite accurate.
BufferParameters bufferParams = new BufferParameters()
{
BufferSpatialReference = new SpatialReference(4326),
OutSpatialReference = MyMap.SpatialReference,
Unit = LinearUnit.Foot,
};
bufferParams.Distances.Add(1); // Adding 1 foot buffer
bufferParams.Features.Add(parcelGeometry); // selected parcel's geometry
geometryService.BufferAsync(bufferParams);
this returns a geometry than can be drawn as a buffer polygon. It's very accurate if the buffer size is close to 0 feet. But bigger the buffer, the rounder the corners of the buffer polygon becomes. I have attached 2 screenshots here to show you what's happening -- left one with buffer size 10 feet, and the right with 50 feet.
In essence, I think Buffer function will give me what I need w/o a lot of trouble. So I was wondering if I could get some help preventing the corners from becoming rounder by feet?
Try using the Offset service with GeometryOffset.Mitered for "OffsetHow" option
Hi,
I tried Offset service instead but it didn't yield accurate results either. I've attached another screenshot of what I get after the new approach.
If you looked at the left polygon, the buffer's left line isn't quite parallel to the original polygon. And the right polygon's buffer goes haywire, I'm assuming because of the complicated shape.
Once again, the buffer polygon seems to be accurate if OffsetDistance is less, upto about 20 feet. Beyond that, the results aren't accurate.
Any way to make this better?