LibPQ.jl icon indicating copy to clipboard operation
LibPQ.jl copied to clipboard

Example / Docs for working with PostGIS

Open Nosferican opened this issue 5 years ago • 3 comments

Would be great to know how to work with geometries in Julia. For example,

data = execute(conn,
               """
               SELECT ST_SetSRID(ST_MakePoint(lon, lat), 4326) AS geom
               FROM tbl;
               """,
               not_null = true) |>
    DataFrame

Which package in Julia would be recommended to parse the String to a geometry in Julia?

Nosferican avatar May 23 '20 12:05 Nosferican

You would probably want to use https://github.com/JuliaGeo/LibGEOS.jl

I would recommend using the PostgreSQL function ST_AsEWKT in your query and then parsing with readgeom from LibGEOS.jl. Or you could use ST_SetSRID(ST_MakePoint(lon, lat), 4326)::bytea in your query and parse with readgeom.

iamed2 avatar Jun 01 '20 22:06 iamed2

This would be a good example case to talk about how to do type conversions in LibPQ.jl

iamed2 avatar Jun 01 '20 22:06 iamed2