RangeX in geoviews, trying to understand x axis range

56 views Asked by At

Can someone please explain to me the meaning of the x axis range retrieved using RangeX for geospatial data?

import geoviews as gv
import holoviews as hv

background = gv.tile_sources.Wikipedia
rng = hv.streams.RangeX(source=background)
background

enter image description here

When I call the rng object I do get None at first for x_range and upon using the wheel zoom, I do get following output:

rng
RangeX(x_range=(-18473547.316975493, 15590216.865764225))

I would expect (-170, 149) but not roughly 1e5 times that value. How can I interpret the output from RangeX in that case?

1

There are 1 answers

1
Moritz On

In case someone else stumbles upon this noob question. The reason lies in different coordinate systems. It is necessary to transform the coordinate system from WGS84 (https://epsg.io/3857) to Mercator (https://epsg.io/4326). This can be done like:

from pyproj import Transformer
transformer = Transformer.from_crs(3857, 4326)
ran = transformer.transform(rng.x_range[0], rng.y_range[0])

EDIT:

I found that using the holoviews utility function a bit easier but the results are the same. Also it is necessary to provide (x, y) pairs to the functions in order to get the correct results. Not only x values.

hv.util.transform.easting_northing_to_lon_lat(x_range[0], y_range[0])