Oreilles / polars-st

Spatial extension for Polars DataFrames
https://oreilles.github.io/polars-st/
GNU Lesser General Public License v2.1
12 stars 1 forks source link

To_srid fails, proj can't be created #1

Open ion-elgreco opened 2 weeks ago

ion-elgreco commented 2 weeks ago

I was trying to convert some values to a different crs since I need to add a buffer, but I noticed that it fails because a proj can't be created. I guess the coordinates data is missing, any idea on how to pre fetch this?

Haven't gotten the ability to dive into proj crate to much

(Cool project btw, it's a great alternative considering the state of GeoPolars atm)

Oreilles commented 2 weeks ago

Would you mind giving a minimal reproducible example ?

Oreilles commented 2 weeks ago

You might have faced the following error:

ComputeError: the plugin failed with message: generic error: Couldn't create transformation from EPSG:0 to [...]

This error message might be improved, but EPSG:0 is not a valid CRS, it means that your data don't have a SRID assigned and therefore cannot be projected. If that is the case, you would need to assign an SRID to your geometries first:

df = df.with_columns(st.geom().st.set_srid(4326))
ion-elgreco commented 2 weeks ago

You might have faced the following error:

ComputeError: the plugin failed with message: generic error: Couldn't create transformation from EPSG:0 to [...]

This error message might be improved, but EPSG:0 is not a valid CRS, it means that your data don't have a SRID assigned and therefore cannot be projected. If that is the case, you would need to assign an SRID to your geometries first:

df = df.with_columns(st.geom().st.set_srid(4326))

Currently don't have access to a system to create a reproducible example. Was working in an air gapped environment.

Regarding the set_srid, I did set everything to 4326.

I saw some prints in stdout when trying to convert the srid about a "proj db missing"

Oreilles commented 2 weeks ago

I managed to reproduce the issue. It is strange that it happens considering Proj and Sqlite are statically linked...

ion-elgreco commented 2 weeks ago

Hmm, do you think it's solvable? Or maybe you can give some pointers then I can take a look next weekend

Currently it's a key thing we need to continue otherwise we have to still do manual projections :p which would defeat the purpose of staying in polars

Oreilles commented 1 week ago

It should be solvable yeah, but that would require diving a bit into how maturin does the packaging.

In the meantime, I'm working on a more general solution allowing yourself to apply any python transform function to the coordinates, so you may be able to use pyproj for that soon.

ion-elgreco commented 1 week ago

It should be solvable yeah, but that would require diving a bit into how maturin does the packaging.

In the meantime, I'm working on a more general solution allowing yourself to apply any python transform function to the coordinates, so you may be able to use pyproj for that soon.

A native expression would be preferred though for perf