Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

speed up download for "infinite" basemap #231

Open
mikilterribile opened this issue Jan 12, 2024 · 9 comments
Open

speed up download for "infinite" basemap #231

mikilterribile opened this issue Jan 12, 2024 · 9 comments

Comments

@mikilterribile
Copy link

Dear contextily Team,

Good evening. Since last year, I have been developing a GIS and hydraulic software, which is freely available at www.hydro-gis.com. I have been utilizing your contextily package in Python to download online basemaps from various sources. I find contextily to be simple, effective, and user-friendly, and I would like to express my gratitude for your excellent work.

I am now looking to advance a step further by creating an "infinite" basemap using contextily. The idea is to have a background where, as the user pans or zooms in/out, the software automatically downloads the correct tiles and displays them, creating the impression of a seamless, infinite basemap.

However, I am encountering a challenge: the download speed of contextily tiles is too slow for this purpose. I have explored several methods to expedite this process, such as using bounds2img instead of bounds2raster, but I haven't observed any significant time difference. I also tried implementing multithreading to enable multiple simultaneous requests to the server, which showed some improvement but was still insufficient.

Could you provide any advice or suggestions on how I might speed up the tile download process using contextily? Any guidance or insights would be greatly appreciated.

Thank you for your attention to this matter.

Best regards,

Michele Zucchelli

@martinfleis
Copy link
Member

I am not sure contextily is built for this kind of a use case. It would probably be interesting to see some profiling of the download to understand where the bottleneck is but it may be better to switch something more suitable (and probably written in JavaScript if that is an option).

@mikilterribile
Copy link
Author

I know nothing about JavaScript, and even if I did, I wouldn't know how to use JavaScript libraries within a Python program. So, I don't think JavaScript is a good option for me. I could try to access the Python code of the 'Bound2Draster' function in Contextily and try to understand how to speed it up and optimize it. However, honestly, I don't think I am capable of doing it.

Thank you for your answer.

Best regards,

Michele Zucchelli.

@darribas
Copy link
Collaborator

Depending on your application, something like geopandas.GeoDataFrame.explore() might be a Python solution that provides what you want? Under the hood, it is using Leafmap, which is a javascript framework, but you do not need to touch it directly. My sense is that this would be the best way to provide an "infinite map" than contextily, which is designed for static (finite) maps.

@mikilterribile
Copy link
Author

mikilterribile commented Jan 21, 2024 via email

@darribas
Copy link
Collaborator

Ahhh I see. I'm not sure I have an answer for this, I'm sorry. This is not a use case we had in mind when developing contextily so it is possible it's not ideally suited. Best luck!

@mikilterribile
Copy link
Author

Hi, trying to develop this functionality for my gis application, I had to improve some contextily functionalities, speeding up the download of the tiles and the reproject (warp) function. I'll be very glad to share this improvement with you, the contextily team, but I don't know what is the best way to do it or wheter if you are interested in. Let me know about it. Best regards, Michele Zucchelli.

@martinfleis
Copy link
Member

We are surely interested! Ideally, open a pull request within this repository. Alternatively, you can point us to the code uploaded somewhere if you're not comfortable with PRs.

@mikilterribile
Copy link
Author

mikilterribile commented Jan 25, 2024 via email

@mikilterribile
Copy link
Author

mikilterribile commented Jan 26, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants