Skip to content

Slow opening and clipping of files #234

Answered by snowman2
nkorinek asked this question in Q&A
Discussion options

You must be logged in to vote

There are several ways to speed things up.

  1. Use from_disk=True when clipping. This will reduce the amount of data loaded in. (rioxarray 0.2+)
  2. With rioxarray 0.2+ and rasterio 1.2+ you don't need .apply(mapping) anymore.
  3. Enable global context with pyproj 3+ with rioxarray < 0.3 (https://pyproj4.github.io/pyproj/stable/api/global_context.html#global-context) - be very careful with this option. With rioxarray 0.3+ use rioxarray.set_options(export_grid_mapping=False)

Putting it all together:

import os
from glob import glob

import earthpy.spatial as es
import numpy as np
import pandas as pd
import geopandas as gpd
import rioxarray as rxr
import pyproj

# use for rioxarray < 0.3
# pyproj.set_…

Replies: 4 comments 28 replies

Comment options

You must be logged in to vote
13 replies
@lwasser
Comment options

@snowman2
Comment options

@lwasser
Comment options

@snowman2
Comment options

@lwasser
Comment options

Answer selected by snowman2
Comment options

You must be logged in to vote
9 replies
@snowman2
Comment options

@nkorinek
Comment options

@snowman2
Comment options

@nkorinek
Comment options

@lwasser
Comment options

Comment options

You must be logged in to vote
5 replies
@snowman2
Comment options

@snowman2
Comment options

@lwasser
Comment options

@lwasser
Comment options

@snowman2
Comment options

Comment options

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

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