![]() See if two geometries overlap, touch, cross, intersect, contain, etc. Find geometries within a certain distanceįind geometries within a certain distance of another geometry, commonly used in aggregation queries or WHERE clauses: # PostGIS, BigQuery, Redshift, and Snowflake ST_Difference(geom_1, geom_2) as intersectionįROM table Spatial Relationships 16. Or if you want to find the leftover parts of a geometry relations ship you can use ST_Difference: # PostGIS, BigQuery, Redshift, and Snowflake ST_Intersection(geom_1, geom_2) as intersection Find the resulting polygon of an intersectionĬommonly know as a clip in GIS, use this function to return the resulting intersecting area from two geometries: # PostGIS, BigQuery, Redshift, and Snowflake ST_VoronoiPolygons(geom) as voronoi_polygonsįROM table 15. Create Voronoi polygonsĬreate Voronoi polygons around your geometries, returning new geometries: # PostGIS If you want to union your geometries, use ST_Union to return a new geometry: # PostGIS and BigQuery ST_ConvexHull(ST_Collect(geom)) as convex_hull, You can also do this by grouping geometries: # ST_Collect will collect the matching geometries together into a Geometr圜ollection You can create a concave or convex hull from a geometry or group of geometries, which will return a new geometry: # PostGIS, BigQuery, and Redshift If you want to find the centroid of a geometry you can use this query to return a point of the centroid of a geometry: # PostGIS, BigQuery, Snowflake, and RedshiftįROM table 12. # PostGIS, BigQuery, and RedshiftįROM table 11. The number in the function below is the distance in meters for the buffer. Create a buffer around a geometryĬreate a buffer around a geometry, which returns a new geometry. ![]() ST_ClosestPoint(geom_1, geom_2) as closest_pointįROM table Transform geometries 10. The function will return a new point that represents the closest point on the second geometry to the first geometry. Given two geometries, find the closest point on geometry 2 to geometry 1. Find the shortest distance, to a specific point, between two geometries Each of the different functions has a different signature for using the spheroid, or curved earth, calculation so make sure to check the docs in this case. Returns the distance in meters between two geometries. Similar to above but perimeter of a polygon in meters # PostGIS, BigQuery, Snowflake, and RedshiftĬalculate the length of a line in meters # PostGIS, BigQuery, Snowflake, and RedshiftįROM table 8. Find the area of a polygonįind the area of a polygon in square meters # PostGIS, BigQuery, Snowflake, and RedshiftįROM table 6. Using a point geometry you can extract the latitude and longitude as numeric values: # PostGIS, BigQuery, Snowflake, and RedshiftįROM table Measurements 5. Get a latitude and longitude from a geometry You can re-project your data using a simple function to a new projection using this query: # PostGIS and RedshiftįROM table 4. Change your data to a different projection Similar to above, this will create a geometry from a WKT string: # PostGIS, Redshift ST_SetSRID(ST_MakePoint(lng, lat), 4326) as point_geomĢ. This query will create a geometry from numeric columns that contain latitude and longitude values. Create a point geometry from a latitude/longitude pair
0 Comments
Leave a Reply. |