Search code examples
javapythongogeometrys2

Convert longitude, latitude to cell id from s2 geometry-library python


I am following this tutorials.

As explained I can convert the cell id from degrees like below

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

But I want to get the cell id from lat lng values (Not from degrees)

latlng = s2.S2LatLng.ToLATLANG(51.577106, 1.067254)

How can I do it (no need to be python)?


Solution

  • If you already have latlng object, just use it in the second code line.

    If not, choose needed constructor from repository file (or documentation if exists).