larshei

larshei

Merging and minifiying geo polygon data in elixir?

I am looking for an option to merge multiple geojson polygons to a single polygon, but could not find a library to do that with. I understand that merging minified shapes might lead to all kinds of artifacts (except if the polygons can be inflated a bit).

Checked out GitHub - felt/geo: A collection of GIS functions for Elixir, but could not find a function to merge shapes and GitHub - pkinney/topo: A Geometry library for Elixir that calculates spatial relationships between two geometries, which is more about finding relations between shapes.

Does a library to merge/minify polygons exists or is there a gap I am having in understanding the current libraries?

Marked As Solved

joddm

joddm

Would probably then just export it as WKT from Elixir then, and fire up PostGIS and import the WKT and do the merging, export from PostGIS to WKT and to Elixir again

Also Liked

entone

entone

I haven’t found one that does it, but if you are utilizing PostGIS, there are some functions there that can do it. ST_Union for example, ST_Union

There is the elixir library geo_postgis that wraps up quite a few of the functions into Ecto, Geo.PostGIS — GeoPostGIS v3.7.1

D4no0

D4no0

Good point!

In addition to this, if the GeoPostGIS library is missing a function from a newer postgis version, creating it on your own is very trivial, example from the library itself:

 defmacro st_transform(wkt, srid) do
    quote do: fragment("ST_Transform(?, ?)", unquote(wkt), unquote(srid))
  end
D4no0

D4no0

Postgis is the best overall option, this is the better supported library out there for dealing with geo data.

If you want to simplify the process so that you can run livebooks without having a pg + postgis installed on each dev machine, you can deploy a dev instance and have everybody connect to it remotely, in this way you will have to setup it only once.

axelson

axelson

Scenic Core Team

I’m not aware of a library to merge polygons together, but there is GitHub - pkinney/simplify_ex that will simplify a polygon using Ramer–Douglas–Peucker.

tme_317

tme_317

I haven’t looked at this stuff since 2019 but in the past when not having PostGIS to help I’ve shelled out to GDAL/OGR (ogr2ogr) command line utilities from Elixir apps to do a wide variety of vector and raster geo manipulation on files. It’s amazing what these OSS tools can do and I’d be shocked if they wouldn’t work for your use case.

I don’t have time to research now but I believe ogr2ogr may be able to do this for you:

Or you can use the tools to convert your GeoJSON to Spatialite or another format which may help also if you don’t want to bring PostGIS in. Enjoy the rabbit hole! :slight_smile:

Where Next?

Popular in Questions Top

aalberti333
As the title describes, I’m trying to run Enum.map() over a list of key/value pairs, where the value is a map. My data looks like this: ...
New
sergio_101
I am VERY much an elixir newbie. I have taken one elixir course and one phoenix course on Udemy. During that course, I saw the instructor...
New
ycv005
I have followed this StackOverflow post to install the specific version of Erlang. And When I am running mix ecto.setup then getting fol...
New
tduccuong
Hi, is there any work on GUI with Elixir, that is similar to Electron/Javascript? My idea is to bundle Phoenix and BEAM into a single se...
New
vac
Hi, I'm quite new in Elixir and I'm trying to format a string to a PEM format. I have the certificate value like MIIDBTCCAe2...... and ...
New
alice
Hey, Just curious what are the main benefits of Elixir compared to Clojure? When is Elixir more useful than Clojure and vice versa? Th...
New
qwerescape
Is there a way to get the call stack or stack trace at any point in the code? Not from exceptions, but an expression that returns how the...
New
chewm
Hi guys, nice to meet you to the whole forum, I’m new here, I’m trying to configure visual studio code for elixir, right now the intellis...
New
belgoros
I’m not a pro in using Regex and can’t figure out why the following behaviour happens, especially if we take into account the difference ...
New
lanycrost
Hi everyone! I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
New

Other popular topics Top

shahryarjb
Hello, I get Persian date from my client and convert it to normal calendar like this: def jalali_string_to_miladi_english_number(persi...
New
polypush135
As many of you may have realized by now (sorry for all the posts here) I’ve been working on a db problem where I’m trying to aggregate a ...
New
hariharasudhan94
I would like to know what is the best IDE for elixir development?
New
vertexbuffer
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
alice
Hey, Just curious what are the main benefits of Elixir compared to Clojure? When is Elixir more useful than Clojure and vice versa? Th...
New
fayddelight
I tried installing elixir 1.11.2 erlang 23.3.4 via asdf in my zsh shell. Enabled the versions locally and globally. When I list them ...
New
vonH
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
New
johnnyicon
Hi all, I've just started learning Elixir and Phoenix Framework, so please pardon my n00bness at this stage. I'm trying to use Postg...
New
WestKeys
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New
AstonJ
by Lance Halvorsen Elixir and Phoenix are generating tremendous excitement as an unbeatable platform for building modern web application...
460 27162 124
New

We're in Beta

About us Mission Statement