How to use the earthpy.spatial.crop_all function in earthpy

To help you get started, we’ve selected a few earthpy examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github earthlab / earthpy / examples / plot_raster_stack_crop.py View on Github external
crop_raster_profile = raster_crs.profile
    crop_bound_utm13N = crop_bound.to_crs(crop_raster_profile["crs"])

#############################################################################
# Crop Each Band
# --------------
# When you need to crop and stack a set of images, it is  most efficient to first
# crop each image, and then stack it. 
# `es.crop_all()` is an efficient way to crop all bands in an image quickly.
# The function will write out cropped rasters to a
# directory and return a list of file paths that can then be used with
# `es.stack()`.

os.chdir(os.path.join(et.io.HOME, "earth-analytics"))

band_paths_list = es.crop_all(
    stack_band_paths, output_dir, crop_bound_utm13N, overwrite=True
)

#############################################################################
# Stack All Bands
# ---------------
# Once the data are cropped, you are ready to create a new stack.

os.chdir(os.path.join(et.io.HOME, "earth-analytics"))

cropped_array, array_raster_profile = es.stack(band_paths_list, nodata=-9999)
crop_extent = plotting_extent(
    cropped_array[0], array_raster_profile["transform"]
)

# Plotting the cropped image

earthpy

A set of helper functions to make working with spatial data in open source tools easier. This package is maintained by Earth Lab and was originally designed to support the earth analytics education program.

BSD-3-Clause
Latest version published 3 years ago

Package Health Score

54 / 100
Full package analysis

Similar packages