crop_domain#

crop_domain(domain, shape=None, handle_intersecting_objects='clip', crop_method='shape', label_name=None)#

Return a new domain, consisting only of elements within domain that are contained by shape or are defined by a category of label.

Parameters:
domaindomain

The spatial domain containing the populations.

shapequery-like, optional

A query which identifies a shape or shapes within the domain. If multiple shapes are identified, crop_domain will return a list of multiple new domains. As domain boundaries containing holes are not currently supported, cropping to a shape with internal voids will only use the outer boundary. Required if crop_method is ‘shape’.

handle_intersecting_objectsstr, optional

Options are ‘clip’, ‘exclude’, or ‘expand’ If ‘clip’, objects which intersect the shape will be cropped so that any parts of their boundaries outside the shape will be removed. If ‘exclude’, any objects intersecting the shape will be excluded from the new domain. If ‘expand’, the objects will retain their original shape, but the boundary of the new domain will be expanded to ensure they are contained in the new domain. Defaults to ‘clip’.

crop_methodstr, optional

Options are ‘label’ or ‘shape’. If ‘label’, the domain will be cropped based on the specified label category. If ‘shape’, the domain will be cropped based on the specified shape. Defaults to ‘label’.

label_namestr, optional

The name of the label to use for cropping when crop_method is ‘label’. Required if crop_method is ‘label’.

Returns:
cropped_domains_dictdict

A dictionary of new spatial domains, cropped to within the specified shapes. Dictionary keys refer to the ID of the shape used to crop that domain. The original domain will remain unaffected.

new_domainsdict

A dictionary where keys are categories (if crop_method is ‘label’) or shape IDs (if crop_method is ‘shape’), and values are new spatial domains cropped accordingly.