ST_MinimumBoundingCircle accepts the geometry type, i.e. planar geometry. Is there any way to get the minimum bounding circle of a geography collection using PostGIS? That is, the minimum bounding circle of a collection of features on the sphere. Simply converting a geography to a geometry and the resulting bounding circle back to geography does not create an accurate result. This guy (via https://observablehq.com/#fil/spherical-smallest-circle-problem) seems to have it worked out in JavaScript by
Going forward (to the stereographic plane), we compute the circumcenter of three projected points on each circle. Going backward, we use d3-geo-voronoi to retrieve the enclosing circle’s center.
Is there any built-in way to do this on PostGIS or achieve the same result using equivalent functions?
I have a table containing geometrics points (called [Polygon_Centre]) and distances (called [Desired_Radius]). Anybody know which Snowflake function I could use to create polygon circles from this?
I'm trying to achieve a similar result to the Trade Area tool in Alteryx if anybody is familiar with that.
I was hoping for something like the following (which doesn't work):
ST_MAKEPOLYGON('Circle', [Polygon_Centre], [Desired_Radius])
Does anybody know how to create a circle polygon from a given centre point and radius in Snowflake?
Thanks everybody. I've found and used the following solution:
Calculate 120 points around the circle mathematically
Turn this into an ordered list with ST_COLLECT() (the order is critical and the start and end must match)
Use ST_MAKELINE() to turn these points into a line
Create the circle with ST_MAKEPOLYGON().
I have to solve a problem with EV3, using language C with ROBOTC.
I am trying to find a ball in the field, grab it and drop in the triangle area.
I'm using a ultrasonic sensor in front of the robot.
My solution for now is:
Turn 360 degrees and find the closest object. After finding the ball, I would like to drop it in the reserved area. That's ok.
The big problem is:
How can I distinct the balls with the triangle area?
After grabbing the ball, I need to drop in the trinagle.
How about the walls? How can I differentiate?
Steps:
Turn 360 and find the closest ball.
Go to the triangle.
Drop it.
Turn 360 and find the closest ball.
And so on.
But with sonic sensor, I can't distinct what's the triangle area and balls.
Can you help me the best way?
It's following the images:
I have a need to store data from an openCV rotatedRect into a database and also be able to search through them. In short, a rotated rectangle in openCV consists of:
a set of four points representing the four corners of the rectangle
the angle the rect is rotated at
the center point of the rect
the bounding box of the rotated rect
I'm not sure if this is more than one question, but I think they relate to each other nicely:
how would I represent this in PostgreSQL? One record will consist of (among other fields) several hundred rotated rect's in a sequential fashion. Does this look sensible?
// the rotated rect type
CREATE TYPE rotated_rect AS {
angle real,
points point ARRAY[4],
center point,
bounding_box box,
width real,
height real
};
// the item that will have several hundred rotated_rects
CREATE TABLE foo {
...,
rotated_rects rotated_rect[],
...
};
How would I then go about searching this data? I'd like to be able to compare one list of rotated rect's with those stored in the database for each record - quite possibly just the center-point of each rotated rect at this stage - and pick out the record/s which either match exactly, or are the closest in position. Would this require PostGIS for spatial data? Or would I have to read all the records into memory and search position manually?
EDIT: Added a stab at a type for postgresql.
The range of longitude and latitude of Earth sphere are [-180, 180] and [-90, 90] respectively. I want to get equal area grids by 0.5 deg * 0.5 deg (area around the equator).
As the distortion increased when approaching the polar points. The grid should have the same latitude range but different longitude range.
How should I do?
First, what you ask got, if interpreted literally, is impossible for three reasons. One, the area of the surface of a perfect sphere is about 82506.97413 times the area of a portion 30' (thirty seconds, or half a degree) by 30' at the equator. Since that is not an integer, you cannot partition the surface into a whole number of regions of that size. Two, if you constrain the latitude span to be equal, then the rings at different latitudes must have different numbers of segments, so you cannot make a grid. The edges of segments in different rings cannot coincide. Three, the Earth is not a perfect sphere, and regions of equal area on a sphere will not map to equal areas on the Earth. Imperfections in the Earth would prevent us from knowing the area of each region (and those areas would change as the surface changes).
Supposing that what you actually want is an approximate solution that is not a grid, I suggest you examine the Google search results for “partition sphere into equal areas“. One of the top results is this paper, in which Figure 1.1 appears to show a sphere that has been partitioned into regions of similar, possibly equal, latitude span but different longitude spans. Another result is this page, which is a Matlab package for exploring sphere partitioning.
You are trying to put equal area tiles on the earth's surface with fixed extent like the mirrors on a disco ball.
So if you start at the Equator with a 0.5deg*0.5deg tile, your next tile to the north or south would have a longitude extent of 0.5deg/cos(0.5deg) to have the same area, so slightly above 0.5deg.
With that tile you cannot fill the full circle with an integer number of tiles.
Ending at the pole your tile longitude extent would be 0.5deg/cos(89.5deg) = 59,29..deg which also does not fit exactly into 360degs.
If you decrease the size of your tiles you might have an acceptable small error but yet no real "grid" because coming to the poles there will always be less tiles than at the Equator..
Maybe something like "equal area map projection" might help? http://en.wikipedia.org/wiki/Map_projection#Equal-area
Two possible solutions here (formulas in R):
lat<-seq(-89.75,89.75,by=0.5)
Formula 1, based on the area of a grid point in the equator (111.11km2).
r<-(111*10^3*0.5)*(111*10^3*0.5)*cos(lat*pi/180)
Formula 2, based on the radius of the Earth.
ER<-6371*1000
r2<-(ER^2)*(0.5*pi/180)^2*cos(lat*pi/180)