1

I would like to use Google's S2 library to convert geospatial data (for instance shapefiles or geojson files) to S2 cell IDs. The data I want to convert is made of polygons. I saw there exists this repository which enables the use of the S2 library in Python, but the S2Polygon object is not implemented. Otherwise, I found this very nice tool which converts shapefiles to S2 IDs, but can't make it work on files other than those given in the example, it might be due to my files. I have also found a Go implementation of the library, but it doesn't fully implement the S2Polygon object either.

Is there such a tool or function, other than the C++ S2 library ?

1

You can use this repository
https://github.com/micolous/s2-geometry-library

Some examples:

import s2

latlng = s2.S2LatLng.FromDegrees(-30.043800, -51.140220)
cell = s2.S2CellId.FromLatLng(latlng)

cell.level()
30

cell.id()
10743750136202470315

cell.ToToken()
951977d377e723ab
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.