question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

tiling render problems unprojecting mercator units with pyproj

See original GitHub issue

Description

Experimenting with the tiling renderer my first attempt at a load_data_func I figured I’d take the x_range and y_range passed in and transform it to lat/lon so as to constrain the postGIS query that loads the tile data.

  • What went wrong, or what were you unable to do?

pyproj appears to not correctly transform the ranges generated by the tiler:

from pyproj.proj import Proj

proj = Proj(init="epsg:3857", preserve_units=False)

# these extents are passed to the tiling load_data_func                                                                                                                              
print(proj((-20037508.34, 20037508.345578488), (-20037508.34, 20037508.345578488), inverse=True))
# ((-179.9999999749438, -179.9999999749438), (-85.05112877764508, 85.05112878196812))                                                                                        

#these extents are the bounds described on https://epsg.io/3857                                                                                                              
print(proj((-20026376.39, 20026376.39), (-20048966.10, 20048966.10), inverse=True))
# ((-179.89999996667325, 179.89999996667325), (-85.04249459864828, 85.04249459864828))
  • What did you expect to happen?

that the extents would match those returned by pyproj:

In [2]: proj((-180, 180), (-85.06, 85.06))
Out[2]: 
((-20037508.342789244, 20037508.342789244),
 (-20048966.1040146, 20048966.104014594))

I am not a GIS expert so the above could be wrong, but maybe someone has an idea that can shed some light on it. I was able to work around the problem by running one large sql query and making one big dataframe that all the tiling operations used (similar to the tiling notebook example) and it’s actually faster, so it’s not like this is a pressing issue for me, just a stumbling block.

How to reproduce

The tiling notebook can be used to generate the ranges:

https://github.com/pyviz/datashader/blob/master/examples/tiling.ipynb

Your environment

pip3 installed datashader and pyproj.

  • What operating system and version?

Debian stretch with python3.5, libproj-dev

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
brendancolcommented, Feb 8, 2021

@ppwadhwa hey yes definitely. I’ll be pushing to deprecate tiles.py from within datashader.

0reactions
ppwadhwacommented, Mar 22, 2021

@brendancol thanks. we’ll close this issue and follow up in mapshader.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Mapserver tiles - trouble with projection
Resolved, I just set projection in MAP file to Mercator: ... my map started to use meters as units and projection changed to...
Read more >
Support rendering in multiple CRS · Issue #168 · maplibre ...
First you'd need to support the rendering and placement of non-web mercator tiles. Then you'd need to create your own basemap because the ......
Read more >
Re-project Web Mercator tiles to arbitrary projection with D3?
The goal of this answer is not to present a finalized resource, but a rough demonstration of how one might be put together...
Read more >
Look, Ma, No More Mercator Tiles
This problem and limitation is avoidable in client side rendering of vector data as stated here before, the hard dependency between the geo ......
Read more >
Local Projections in a World of Spherical Mercator - liedman.net
We first have to agree on how large each tile is, both in pixels and in projected coordinates. Deciding the tile size in...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found