Skip to content

Running nlcd_bycoords for many coordinates #119

Answered by cheginit
ablythed asked this question in Q&A
Discussion options

You must be logged in to vote

Hi! The issue with large requests is that it hammers the web service and can lead to the service blocking the request. I recommend an approach similar to your for-loop but submitting your requests in batches, instead. For example, for a batch size of 100, you do something like this:

from pathlib import Path
import cytoolz as tlz

for i, c in enumerate(tlz.partition_all(100, lookup)):
    if not Path(f"nlcd_{i}.parquet").exists():
        gh.nlcd_bycoords(coords=c).to_parquet(f"nlcd_{i}.parquet")

Whenever it fails, you can rerun it again, and it will continue from where it failed. You can run this a couple of times, until it finishes. Once it's done, you can just read and concat all the fi…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@ablythed
Comment options

Answer selected by ablythed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants