# Export GeoTable to common GIS format and CRS projection

**URL:** https://discourse.julialang.org/t/export-geotable-to-common-gis-format-and-crs-projection/88408
**Category:** Geo
**Created:** [October 7, 2022, 3:30pm UTC](https://discourse.julialang.org/t/export-geotable-to-common-gis-format-and-crs-projection/88408 "2022-10-07T15:30:26Z")
**Posts on this page:** 17
**Page:** 1

<div class="post-metadata">

### Author: ![ErickChacon](https://avatars.discourse-cdn.com/v4/letter/e/9de053/32.png) [@ErickChacon](https://discourse.julialang.org/u/ErickChacon)
#### Post date: [October 7, 2022, 3:30pm UTC](https://discourse.julialang.org/t/export-geotable-to-common-gis-format-and-crs-projection/88408/1 "2022-10-07T15:30:26Z")

</div>

I love working with Meshes.jl and GeoTables.jl.

1. I would like to be able to export a GeoTable object to a standard GIS format (e.g. shapfile, gpkg, so on) so my collaborators can handle the results of my analysis. What would be the suggested approach to export a GeoTable?

2. Also I was wondering how people are handling projection to CRS using GeoTables.jl and Meshes.jl.

---

<div class="post-metadata">

### Author: ![juliohm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/juliohm/32/215266_2.png) [@juliohm](https://discourse.julialang.org/u/juliohm)
#### Post date: [October 7, 2022, 4:20pm UTC](https://discourse.julialang.org/t/export-geotable-to-common-gis-format-and-crs-projection/88408/2 "2022-10-07T16:20:56Z")

</div>

Glad to hear it has been a good experience @ErickChacon ❤ We are working really hard to lower the barriers to entry in GIS. Let me try to address your questions:

> [@ErickChacon](#):
>
> I would like to be able to export a GeoTable object to a standard GIS format (e.g. shapfile, gpkg, so on) so my collaborators can handle the results of my analysis. What would be the suggested approach to export a GeoTable?

Notice that a GeoTable is a type that implements the Tables.jl API. Try to check which packages (Shapefiles.jl, GeoJSON.jl, ArchGDAL.jl) provide a `write` or `save` function to write to disk and we can work on the final ingredients to make it function. We will probably need to write a small code to convert Meshes.jl geometries to whatever geometry types are used by the IO package. The GeoInterface.jl package can be useful to write this conversion code.

> [@ErickChacon](#):
>
> Also I was wondering how people are handling projection to CRS using GeoTables.jl and Meshes.jl.

We are currently working on a generalization in Meshes.jl to lower the barrier to entry here as well. The plan is to have some innovative solutions coming out by the beginning of next year.

---

<div class="post-metadata">

### Author: ![Raf](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/raf/32/3383_2.png) [@Raf](https://discourse.julialang.org/u/Raf)
#### Post date: [October 7, 2022, 4:26pm UTC](https://discourse.julialang.org/t/export-geotable-to-common-gis-format-and-crs-projection/88408/3 "2022-10-07T16:26:11Z")

</div>

Yes Meshes.jl needs to implement GeoInterface at some stage. I’ve had a look at doing this but there have been too many small things with all of the other packages and GeoInterface 1.0 for me to get it finished.

@juliohm If you have time with your understanding of the objects in Meshes.jl would probably be faster at getting the bulk of it in place. I can work with you with more specific details of GeoInterface.jl , as I’ve done a few of these by now.

---

<div class="post-metadata">

### Author: ![juliohm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/juliohm/32/215266_2.png) [@juliohm](https://discourse.julialang.org/u/juliohm)
#### Post date: [October 7, 2022, 4:29pm UTC](https://discourse.julialang.org/t/export-geotable-to-common-gis-format-and-crs-projection/88408/4 "2022-10-07T16:29:51Z")

</div>

@Raf I don’t have the bandwidth right now to work on this, but the implementation should probably live in a separate package given that Meshes.jl is a more general project that goes beyond 2.5D geometries used in GIS. We are still evolving our own geometry types to accommodate more complex use cases and algorithms.

---

<div class="post-metadata">

### Author: ![Raf](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/raf/32/3383_2.png) [@Raf](https://discourse.julialang.org/u/Raf)
#### Post date: [October 7, 2022, 4:35pm UTC](https://discourse.julialang.org/t/export-geotable-to-common-gis-format-and-crs-projection/88408/5 "2022-10-07T16:35:28Z")

</div>

Ok, I get that its a broader package. But you have real users in threads like this asking for interop, and it could “just work” without much effort.

GeoInterface is a tiny dependency, at 0.01 seconds using time on my laptop. Even Geometry basics is fine having as a dep:

> <https://github.com/JuliaGeometry/GeometryBasics.jl/blob/master/Project.toml>

---

<div class="post-metadata">

### Author: ![juliohm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/juliohm/32/215266_2.png) [@juliohm](https://discourse.julialang.org/u/juliohm)
#### Post date: [October 7, 2022, 4:39pm UTC](https://discourse.julialang.org/t/export-geotable-to-common-gis-format-and-crs-projection/88408/6 "2022-10-07T16:39:24Z")

</div>

A scalable solution here is to create a package `GeoConversions.jl` (or similar name) that is maintained by people that are interested in converting back and forth between different geometry types that implement the GeoInterface.jl.

The code doesn’t need to live in Meshes.jl, that is what I am saying. Maintaining this interface is not our priority so people who actually need it can take the lead and implement it in a separate package that others can review and contribute over the years.

---

<div class="post-metadata">

### Author: ![Raf](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/raf/32/3383_2.png) [@Raf](https://discourse.julialang.org/u/Raf)
#### Post date: [October 7, 2022, 4:45pm UTC](https://discourse.julialang.org/t/export-geotable-to-common-gis-format-and-crs-projection/88408/7 "2022-10-07T16:45:38Z")

</div>

You can already do conversion just with GeoInterface.jl, we don’t need another package for that.

---

<div class="post-metadata">

### Author: ![juliohm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/juliohm/32/215266_2.png) [@juliohm](https://discourse.julialang.org/u/juliohm)
#### Post date: [October 7, 2022, 4:51pm UTC](https://discourse.julialang.org/t/export-geotable-to-common-gis-format-and-crs-projection/88408/8 "2022-10-07T16:51:14Z")

</div>

If anyone is willing to submit a PR, I am happy to assess the alternatives. I don’t have the time to work on this myself.

---

<div class="post-metadata">

### Author: ![Raf](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/raf/32/3383_2.png) [@Raf](https://discourse.julialang.org/u/Raf)
#### Post date: [October 7, 2022, 4:55pm UTC](https://discourse.julialang.org/t/export-geotable-to-common-gis-format-and-crs-projection/88408/9 "2022-10-07T16:55:56Z")

</div>

Well, I started a PR a while ago, I’m just also very squeezed for time. I would look at finishing it if it is something wanted in Meshes.jl and will have a good chance of being merged.

(I can’t actually maintain a separate package for this tho)

---

<div class="post-metadata">

### Author: ![juliohm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/juliohm/32/215266_2.png) [@juliohm](https://discourse.julialang.org/u/juliohm)
#### Post date: [October 7, 2022, 5:07pm UTC](https://discourse.julialang.org/t/export-geotable-to-common-gis-format-and-crs-projection/88408/10 "2022-10-07T17:07:07Z")

</div>

If you can share the PR you have started that would be helpful. It would even help com OP with his specific problem right now.

---

<div class="post-metadata">

### Author: ![Raf](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/raf/32/3383_2.png) [@Raf](https://discourse.julialang.org/u/Raf)
#### Post date: [October 7, 2022, 6:21pm UTC](https://discourse.julialang.org/t/export-geotable-to-common-gis-format-and-crs-projection/88408/11 "2022-10-07T18:21:52Z")

</div>

It’s not really at a helpful state at this point as I don’t fully have my head around Meshes.jl types

---

<div class="post-metadata">

### Author: ![juliohm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/juliohm/32/215266_2.png) [@juliohm](https://discourse.julialang.org/u/juliohm)
#### Post date: [October 8, 2022, 2:56am UTC](https://discourse.julialang.org/t/export-geotable-to-common-gis-format-and-crs-projection/88408/12 "2022-10-08T02:56:46Z")

</div>

@ErickChacon please update to GeoTables.jl v1.1, I’ve implemented the minimum interface necessary to save to disk as illustrated in the following example:

```julia
julia> using GeoStats

julia> geotable = georef((a=1:4, b=1:4))
4 MeshData{1,Float64}
  variables (rank 1)
    └─a (Int64)
    └─b (Int64)
  domain: 4 CartesianGrid{1,Float64}

julia> using GeoTables

julia> GeoTables.save("analysis.geojson", geotable)
"analysis.geojson"

julia> GeoTables.load("analysis.geojson")
4 GeoTable{1,Float64}
  variables (rank 1)
    └─a (Int64)
    └─b (Int64)
  domain: 4 GeometrySet{1,Float64}

```

Notice a few things:

1. The GeoInterface.jl cannot represent rich topological information that is needed for geometric processing. Notice how the original `CartesianGrid` is reloaded from disk as a `GeometrySet`, i.e. a soup of disconnected geometries. Many algorithms in Meshes.jl rely on neighborhood information, so I highly recommend that you stay away as much as possible from these geometry types used for IO. My general advise is to design your workflow in terms of Meshes.jl geometries, and only resort to the GeoInterface.jl for loading/saving data from/to disk.

2. The only package I could find that provides the “save” functionality for the GeoInterface.jl is the GeoJSON.jl package. That means that you can only export to geojson at the moment.

3. You may encounter issues saving some types of geometries that are not supported by the GeoInterface.jl. If you have any trouble, please reach out in our community channel:

[https://juliaearth.github.io/GeoStats.jl/stable/about/community.html](https://juliaearth.github.io/GeoStats.jl/stable/about/community.html)

---

<div class="post-metadata">

### Author: ![ErickChacon](https://avatars.discourse-cdn.com/v4/letter/e/9de053/32.png) [@ErickChacon](https://discourse.julialang.org/u/ErickChacon)
#### Post date: [October 8, 2022, 3:40am UTC](https://discourse.julialang.org/t/export-geotable-to-common-gis-format-and-crs-projection/88408/13 "2022-10-08T03:40:53Z")

</div>

@juliohm Thank you so much for the quick implementation. I agree with you that `Meshes.jl` is a more general approach than classical GIS but still there is the need to share our data with other colleagues that are just interested in visualising or performing simple analysis of our results with their own GIS tools. Thank you again for providing a simple way to share our data.

Thank you so much for your advises, I agree with the points you made. In particular, the point 1 is quite interesting and clearly indicates that in several cases this approach would not be ideal. In case of sharing data with Julia users, do you think it is sensible to use JLD2? I have some additional questions with respect to this, I will probably continue the discussion in the GeoStats community.

---

<div class="post-metadata">

### Author: ![juliohm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/juliohm/32/215266_2.png) [@juliohm](https://discourse.julialang.org/u/juliohm)
#### Post date: [October 8, 2022, 9:57am UTC](https://discourse.julialang.org/t/export-geotable-to-common-gis-format-and-crs-projection/88408/14 "2022-10-08T09:57:47Z")

</div>

> [@ErickChacon](#):
>
> In case of sharing data with Julia users, do you think it is sensible to use JLD2?

Depending on the geometries you have in mind, you can maybe use a more standard format like VTK (WriteVTK.jl) or PLY (PlyIO.jl) for your mesh data. I think JLD2.jl is a good fallback for Julia collaborators who just need to load your results and continue the work with all the data structures preserved.

> [@ErickChacon](#):
>
> I have some additional questions with respect to this, I will probably continue the discussion in the GeoStats community.

Happy to continue it over there 🙂

---

<div class="post-metadata">

### Author: ![Raf](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/raf/32/3383_2.png) [@Raf](https://discourse.julialang.org/u/Raf)
#### Post date: [October 8, 2022, 2:13pm UTC](https://discourse.julialang.org/t/export-geotable-to-common-gis-format-and-crs-projection/88408/15 "2022-10-08T14:13:13Z")

</div>

ArchGDAL.jl can write to other formats, although its not as easy as it could be. GeoParquet.jl can also write. I would like to add `write` to Shapefile.jl as well, if people think that’s useful.

Also @juliohm nice work on GeoTabels.jl! There are more efficient methods than using `GI.coordinates`, which will allocate a bunch of Vectors. I can PR at some point to make this more efficient if you like.

---

<div class="post-metadata">

### Author: ![juliohm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/juliohm/32/215266_2.png) [@juliohm](https://discourse.julialang.org/u/juliohm)
#### Post date: [October 8, 2022, 2:34pm UTC](https://discourse.julialang.org/t/export-geotable-to-common-gis-format-and-crs-projection/88408/16 "2022-10-08T14:34:47Z")

</div>

> [@Raf](#):
>
> There are more efficient methods than using `GI.coordinates`, which will allocate a bunch of Vectors. I can PR at some point to make this more efficient if you like.

Yes, that would be helpful.

---

<div class="post-metadata">

### Author: ![juliohm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/juliohm/32/215266_2.png) [@juliohm](https://discourse.julialang.org/u/juliohm)
#### Post date: [February 28, 2024, 12:53pm UTC](https://discourse.julialang.org/t/export-geotable-to-common-gis-format-and-crs-projection/88408/17 "2024-02-28T12:53:30Z")

</div>

Update for those coming late here:

Please replace `GeoTables.load` by `GeoIO.load`.
