Can I have a polygon-column in Postgres?
Is there a function to calculate the area of the polygon or at least the area of the bounding box?
(without postgis)
Thanks
EDIT:
area(path(w.poly)) works. Is it the same?
As you say area(path(w.poly)) works.
It calculates the area of a polygon or other geometric figure. It is correct.
Related
Im trying to calculate numerically an area of different shapes where the only thing I know about them is the (x,y) of each corner.
For example the shapes are:
P.s. The points inside the shape are for other calculation, I only need the area of the most outer shape.
Thank you.
Create polygon, and use polyarea function.
Given x,y location of corners than:
Area=polyarea(x,y)
I have objets have different shapes and my aim is to find ratio between object area and its Bounding Box area. There is no problem to find object area but I did not find a way to get Bounding Box area.
Is there any way or any exist function in matlab to calculate Bounding Box area?
But, you know the bounding box? If you dont, use regionprops(Imgbw,'BoundingBox')
And you will get it.
Once you have it, its kinda easy. Is just computing the area of a square. Regionprops will give you [x y] and [x_width y_width]. Im sure you are capable of calculating the area of a square with the size of its sides.
I have a shape which you can imagine as a lake in a field observed from the top (2D). I determined the border pixels of the shape after an image processing, so that I have the coordinates of each border point.
Now I want to calculate the perimeter of this shape. My problem is that I have the points not in following order that would give a closed loop, but unordered.
How can a problem like this be solved in Matlab? (including Curve-Fitting-Toolbox etc.)
Thank you for any suggestions!
You can use the function regionprops for this.
Turn your image into a binary image with 1 inside your 'lake' and 0 outside (which you should be easily able to do, as you mention you extracted the boundaries).
Then use:
props=regionprops(YourBinaryImage, 'Perimeter');
You can then access the perimeter as follows: props.Perimeter
If you have set of 3D points with (x,y,z) coordinates, you may set z to zero and use the 2D (x,y) points to find the convex hull using convhull regardless of their order .
I am using regionprop function in matlab to get MajorAxisLength of an image. I think logically this number should not be greater than sqrt(a^2+b^2) in wich a abd b are the width and heigth of the image. but for my image it is. My black and white image contains a black circle in the center of the image. I think this is strange. Can anybody help me?
Thanks.
If you look at the code of regionprops (subfunction ComputeEllipseParams), you see that they use the second moment to estimate the ellipsoid radius. This works very well for ellipsoid-shaped features, but not very well for features with holes. The second moment increases if you remove pixels from around the centroid (which is, btw, why they make I-beams). Thus, the bigger the 'hole' in the middle of your image, the bigger the apparent ellipsoid radius.
In your case, you may be better off using the extrema property of regionprops, and to calculate the largest radius from there.
I have a table with thousands of addresses as points.
Is there a function in postgis that will allow me to get a bounding polygon around these points and return it as a polygon?
update I am looking for a more complex polygon than just a bounding rectangle
It may be not 100% clear from your question what you mean as more bounding polygon. It may be understood as
minimum bounding rectangle (also known as MBR or envelope) for which you can use ST_Envelope, ST_Box2D or ST_Extent,
as s a minimum geometry which encloses all points within given geometry, a convex envelope and in this case you can use ST_ConvexHull or even ST_ExteriorRing if your input would be a polygon,
As Pimin pointed in the comments below, ST_ConcaveHull is another option worth to consider, available since PostGIS 2.0.0.
ST_Extent provides an aggregate function that returns a bounding box that bounds a set of geometries.