Skip to content

Instantly share code, notes, and snippets.

@fpsampayo
Created February 8, 2018 16:48
Show Gist options
  • Save fpsampayo/7acc4001f7b49ca49a972169d7ae1f0a to your computer and use it in GitHub Desktop.
Save fpsampayo/7acc4001f7b49ca49a972169d7ae1f0a to your computer and use it in GitHub Desktop.
PostGIS - Modificación de longitud de líneas simples desde punto central

Consulta para obtener una nueva geometría de igual dirección pero de un tamaño fijo, y partiendo del punto central:

SELECT
  ST_Rotate(
  	ST_MakeLine(
	  ST_Translate(center, 0, -len / 2),
	  ST_Translate(center, 0,  len / 2)
	),
	-azm,
	center
  ) as geom
FROM
  (
  SELECT
    2.0 as len,
    ST_Centroid(geom) as center,
    ST_Azimuth(ST_StartPoint(geom), ST_EndPoint(geom)) as azm
  FROM
    table
  )	a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment