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

Add converter from WKT2 to PROJJSON strings

Open juliohm opened this issue 8 months ago • 16 comments

Issue

The GeoParquet specification does not adhere to OGC WKT-CRS standards, and instead relies on PROJJSON strings.

Therefore, we need to convert from our native CoordRefSystems.wkt2 strings added in https://github.com/JuliaEarth/CoordRefSystems.jl/issues/245 to the PROJJSON encoding in order to save data in GeoParquet format.

Bounty

Our current implementation, which can be found here, relies on external calls to GDAL:

function projjsonstring(code; multiline=false)
  spref = spatialref(code)
  wktptr = Ref{Cstring}()
  options = ["MULTILINE=$(multiline ? "YES" : "NO")"]
  GDAL.osrexporttoprojjson(spref, wktptr, options)
  unsafe_string(wktptr[])
end

We need to rewrite this function in terms of CoordRefSystems.wkt2(code), parsing the resulting string into a valid PROJJSON.

A Julia-native solution that

  1. satisfies the PROJJSON schema
  2. matches the GDAL results to the best extent possible
  3. adheres to our code style and is tested with most relevant CRS codes

will get a /bounty $250.

Tips

  • The opposite operation from PROJSON to WKT2 has been implemented in different languages. One example implementation in Python is https://github.com/rouault/projjson_to_wkt

juliohm avatar Mar 23 '25 12:03 juliohm

💎 $400 bounty • JuliaEarth

Steps to solve:

  1. Start working: Comment /attempt #150 with your implementation plan
  2. Submit work: Create a pull request including /claim #150 in the PR body to claim the bounty
  3. Receive payment: 100% of the bounty is received 2-5 days post-reward. Make sure you are eligible for payouts

❗ Important guidelines:

  • To claim a bounty, you need to provide a short demo video of your changes in your pull request
  • If anything is unclear, ask for clarification before starting as this will help avoid potential rework
  • Low quality AI PRs will not receive review and will be closed
  • Do not ask to be assigned unless you've contributed before

Thank you for contributing to JuliaEarth/GeoIO.jl!

Attempt Started (UTC) Solution Actions
🟢 @jealteris Apr 04, 2025, 07:14:38 AM WIP
🟢 @dharmitpatel81 Apr 13, 2025, 12:39:47 AM #154 Reward
🟢 @zelosleone Apr 20, 2025, 08:49:24 AM #155 Reward
🟢 @nsajko Apr 20, 2025, 09:54:21 AM #157 Reward
🟢 @Omar-Elrefaei May 22, 2025, 02:00:33 PM #156 Reward
🟢 @Kishan-Patel-dev Mar 23, 2025, 12:13:36 PM WIP
🟢 @Gmin2 Mar 23, 2025, 11:04:15 PM WIP
🟢 @onyedikachi-david Mar 26, 2025, 12:17:31 AM #152 Reward

algora-pbc[bot] avatar Mar 23 '25 12:03 algora-pbc[bot]

/attempt #150

Options

thekishandev avatar Mar 23 '25 12:03 thekishandev

/attempt #150

Algora profile Completed bounties Tech Active attempts Options
@Gmin2 17 bounties from 8 projects
TypeScript, Rust,
JavaScript & more
Cancel attempt

Gmin2 avatar Mar 23 '25 23:03 Gmin2

💡 @onyedikachi-david submitted a pull request that claims the bounty. You can visit your bounty board to reward.

algora-pbc[bot] avatar Mar 26 '25 00:03 algora-pbc[bot]

/attempt #150

Options

dharmitpatel81 avatar Mar 29 '25 18:03 dharmitpatel81

/attempt #150

jealteris avatar Apr 04 '25 07:04 jealteris

I will chime in and say a few things about the bounty, maybe some advice as well specially regarding the GDAL testing, since i spent last 2 days working through it. It's actually very easy to do a complete parser (and not use regex or hardcoded matching) using tree discovery, but GDAL (in this case Arch GDAL) uses a different numbering system internally, which messes up the whole flow of testing.

zelosleone avatar Apr 08 '25 13:04 zelosleone

Thank you for sharing @zelosleone. Could you please elaborate on the different numbering system? Our ultimate goal is to completely eliminate the dependency on GDAL. So we would be happy to adjust the tests accordingly if we see there is no point in trying to match GDAL's output. The main concern we have is correctness of the PROJJSON string, and adherence to the schema.

juliohm avatar Apr 08 '25 13:04 juliohm

Thank you for sharing @zelosleone. Could you please elaborate on the different numbering system? Our ultimate goal is to completely eliminate the dependency on GDAL. So we would be happy to adjust the tests accordingly if we see there is no point in trying to match GDAL's output. The main concern we have is correctness of the PROJJSON string, and adherence to the schema.

I didn't exactly test like onyedi, I used manual datas to load up the WKT2 files (since your testing builds were built exactly like this) Sample datas were taken from official sources as well, then used their authority numbers and turns out, Arch GDAL uses a different numbering system.

zelosleone avatar Apr 08 '25 13:04 zelosleone

Sample datas were taken from official sources as well, then used their authority numbers and turns out, Arch GDAL uses a different numbering system.

If you can share examples of mismatch, that can help us decide the next steps.

juliohm avatar Apr 08 '25 13:04 juliohm

Increasing to /bounty $400.

juliohm avatar Apr 17 '25 11:04 juliohm

/attempt #150

zelosleone avatar Apr 20 '25 08:04 zelosleone

Sample datas were taken from official sources as well, then used their authority numbers and turns out, Arch GDAL uses a different numbering system.

If you can share examples of mismatch, that can help us decide the next steps.

I will provide example data and a PR (i spent the full day on this! haha, but all things aside it was a really experimental attempt because of C calls, but my testing shows up-to-date conversion so it was a success. it will be okay even if you guys reject it tbh, though hopefully not. Small PR as well, happy easter!)

zelosleone avatar Apr 20 '25 08:04 zelosleone

/attempt #150

working on a pure Julia solution

nsajko avatar Apr 20 '25 09:04 nsajko

is tested with most relevant CRS codes

What do "most" and "relevant" mean here? Is it not necessary to support all EPSG definitions?

nsajko avatar Apr 22 '25 05:04 nsajko

What do "most" and "relevant" mean here? Is it not necessary to support all EPSG definitions?

Hi @nsajko , we need to support the EPSG codes currently mapped to CRS types here:

https://github.com/JuliaEarth/CoordRefSystems.jl/blob/ae9c4d5e038e36761a0516db53a62d4237d84172/src/get.jl#L46-L106

juliohm avatar Apr 22 '25 10:04 juliohm

🎉 The pull request of @Omar-Elrefaei has been merged. The bounty can be rewarded here

cc @JuliaEarth

algora-pbc[bot] avatar May 26 '25 18:05 algora-pbc[bot]

Fixed by #156

juliohm avatar May 26 '25 18:05 juliohm

🎉🎈 @Omar-Elrefaei has been awarded $400 by JuliaEarth! 🎈🎊

algora-pbc[bot] avatar May 26 '25 18:05 algora-pbc[bot]