Thursday, 28 November 2019

intersection - PostGIS > Intersect two circles. Each Circle must be built from Long/Lat degrees plus radius


I'm trying to figure this out, so I wanted to try asking to the experts.


This question is related to PostGIS (from postgresql).


What I want is:


1) Based on a longitude and latitude I want project a single point (similar on how you can pass the lat and lon to a google map and then have a single point projected).


2) Create a circle geometry around that with a radius. (I'm going to determine the radius based on the horizontal accuracy of the Lat/Lon)


3) Then, I want to do 1 and 2 again to another Lat/Lon combination. And see if those two circles touch.




I suppose for point 2), I could use a constructor like ST_GeomFromText, however I dont quite understand yet how I can project a single point based on two spherical angles (lat/lon).



Then for point 3, I guess I could use something like ST_Touches



Answer



I'll post this code to solve part of the problem, as I don't know what you're trying to do with the map part, but here goes:


SELECT 
ST_Touches(temp.point1, temp.point2) as geom_touches
, ST_Intersects(temp.point1, temp.point2) as geom_intersect

FROM (

SELECT * FROM

ST_Buffer(ST_Transform(ST_GeomFromText('POINT(-105.05083 39.74823)', 4326), 2877), 1500) as point1
, ST_Buffer(ST_Transform(ST_GeomFromText('POINT(-105.04428 39.74779)', 4326), 2877), 1500) as point2

)as temp

This will:
- create 2 geometries in a temp table, both in SRID:4326 using ST_GeomFromText
- transform those two geometries to a projected coordinate system in Feet (state plane Colorado)
- buffer those points by a distance (1500 feet)
- use an outer SQL statement to test if they touch, and if they intersect



And the results look like this:


enter image description here


And the geometries look like this:


enter image description here


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...