How does SQL STBuffer measure distance around polygons? - sql

How does the STBuffer function measure distances around a polygon?
I am looking at the expression:
select SP_GEOMETRY.STBuffer(100)
and wondering how the 100-meter buffer is calculated around the geometry of polygons.
e.g., is it from the centre of the polygon? or does the buffer start from the edges of the polygon?
I am struggling to find helpful documentation on this so if you have any links let me know!
Thanks heaps
I am wondering because the function is trying to pick up boundaries which are within 100m from each other, but when running the function, not all the properties within 100m are being selected.

Related

ST_BUFFER in google bigquery?

To create a polygon around a pair of lat+lon coordinates I'd expect to be able to buffer the geogpoint:
e.g. ST_BUFFER(ST_GEOGPOINT(lat, lon), 1000)
This creates a circular polygon with a radius of 1000m.
Bigquery doesn't seem to have the buffer function, which seems like a really basic one - am I missing something? Thanks!
As for now, ST_BUFFER function is not supported in query engine yet. All available geography functions in Standard SQL you can see here. Additionally, you can think about using buffer function from the open source library Turf.JS to make buffers and use it in BigQuery:
jslibs.turf.ST_BUFFER(geometry_to_buffer GEOGRAPHY, radius NUMERIC, units STRING, steps NUMERIC)
Please follow carto tutorial to learn more about using this function.
ST_Buffer is now available (in preview)
https://cloud.google.com/bigquery/docs/reference/standard-sql/geography_functions#st_buffer
There is also ST_BufferWithTolerance which allows one to specify approximation tolerance, rather than number of segments in polygon approximating the buffer.

Measuring distance between two objects using CATIA VBA

I have a part which has two exremums on one direction. These extremums can be surface, point or line depending on part shape.
I want to measure the distance between those two extremums on the direction which they are defined by.
I couldn't find anyway to measure distance.
i solved the broblem by creating a formula which is
distance(sadasd\Sketchplane,BOUNDARY BOX\extz-2)

Checking if a Coordinate is Within a Range - BigQuery GIS

I'm looking at the freely available Solar potential dataset on Google BigQuery that may be found here: https://bigquery.cloud.google.com/table/bigquery-public-data:sunroof_solar.solar_potential_by_censustract?pli=1&tab=schema
Each record on the table has the following border definitions:
lat_max - maximum latitude for that region
lat_min - minimum latitude for that region
lng_max - maximum longitude for that region
lng_min - minimum longitude for that region
Now I have a coordinate (lat/lng pair) and I would like to query to see whether or not that coordinate is within the above range. How do I do that with BQ Standard SQL?
I've seen the Geo Functions here: https://cloud.google.com/bigquery/docs/reference/standard-sql/geography_functions
But I'm still not sure how to write this query.
Thanks!
Assuming the points are just latitude and longitude as numbers, why can't you just do a standard numerical comparison?
Note: The first link doesn't work without a google account, so I can't see the data.
But if you want to become spatial, I'd suggest you're going to need to take the border coordinates that you have and turn them into a polygon using one of: ST_MAKEPOLYGON, ST_GEOGFROMGEOJSON, or ST_GEOGFROMTEXT. Then create a point using the coords you wish to test ST_MAKEPOINT.
Now you have two geographies you can compare them both using ST_INTERSECTION or ST_DISJOINT depending on what outcome you want.
If you want to get fancy and see how far aware from the border you are (which I guess means more efficient?) you can use ST_DISTANCE.
Agree with Jonathan, just checking if each of the lat/lon value is within the bounds is simplest way to achieve it (unless there are any issues around antimeridian, but most likely you can just ignore them).
If you do want to use Geography objects for that, you can construct Geography objects for these rectangles, using
ST_MakePolygon(ST_MakeLine(
[ST_GeogPoint(lon_min, lat_min), ST_GeogPoint(lon_max, lat_min),
ST_GeogPoint(lon_max, lat_max), ST_GeogPoint(lon_min, lat_max),
ST_GeogPoint(lon_min, lat_min)]))
And then check if the point is within particular rectangle using
ST_Intersects(ST_GeogPoint(lon, lat), <polygon-above>)
But it will likely be slower and would not provide any benefit for this particular case.

OrientDB Spatial Module Distance Calculation

I need to calculate distance of two positions on OrientDB with new Spatial Module which is available for version 2.2. I have checked documentation (http://orientdb.com/docs/2.2/Spatial-Module.html) but couldn't find anything. I can calculate distance on my own but that time, what is the point to use the Spatial Module if I will not use spatial capabilities?
Also I need to check that if two positions are less than a threshold value. Again I don't have any documentation given by OrientDB.
Here are the two Java method signatures that I'm trying to implement.
double distance(Vertex gateway, Vertex sink);
boolean isInDistance(Vertex from, Vertex to, double distanceX, double distanceY);
Actually out of already implemented SQL-MM functions, ST_DISTANCE is needed to be implemented. I need a solution as a ST_DISTANCE replacement, I guess.
Thank you for your help.

Determining which polygon contains the majority of a line - Oracle Spatial

I have an oracle database (11g spatial) that includes a series of area polygons and water mains. I'm trying to attribute each of these mains to the area in which it is contained and for the most part this is straightforward enough (using the SDO_CONTAINS function) but I'm not sure how to deal with mains that straddle multiple polygons due to errors in digitisation.
In cases like this what I'd ideally like to do is attribute a main to an area polygon if the majority of it's length (>50%) is contained within onit. I know that I can use the SDO_RELATE function to determine every polygon that any given main interacts with, but I don't know how to then go about determining how much of it's length is contained within each area.
The principle is like this:
Correlate mains and areas. Assuming you have many mains and many areas, the most efficient approach is to use SDO_JOIN
For each couple (main/area) returned, compute their intersection (SDO_GEM.SDO_INTERSECTION) and measure the length of that intersection (SDO_GEOM.SDO_LENGTH).
From those results, retain the area for each main where the length is the maximum
If you want a full SQL example, allow me a bit of time to write that using sample data.