Spatial & Regions#
fetchez.spatial#
Lightweight spatial utilities for parsing region strings and files into standard bounding boxes. Adaptded from CUDEM.
- copyright:
2012 - 2026 CIRES Coastal DEM Team
- license:
MIT, see LICENSE for more details.
- class fetchez.spatial.Region(w=None, e=None, s=None, n=None, srs=None)[source]#
Bases:
objectA geospatial bounding box object.
Behaves like a tuple (xmin, xmax, ymin, ymax) for backward compatibility, but provides methods for manipulation and format conversion.
- property w#
- property e#
- property s#
- property n#
- property width#
- property height#
- property xy_region#
- is_valid(check_xy=True)#
Check if region is valid.
- srcwin(geo_transform, x_count, y_count, node='grid')[source]#
Output the appropriate GDAL srcwin (xoff, yoff, xsize, ysize).
- geo_transform(x_inc=0, y_inc=None, node='grid')[source]#
Return dimensions and a geotransform based on the region and a cellsize.
- fetchez.spatial.region_from_vector(fn)[source]#
Parse the bounding box of any OGR-supported vector file using Fiona.
- fetchez.spatial.region_from_place(query, centered=True)[source]#
Resolve ‘loc:PlaceName’ to a bounding box.
- fetchez.spatial.parse_region(input_r)[source]#
Main function to parse region input into a list of Region objects.
- fetchez.spatial.fix_argparse_region(raw_argv)[source]#
Argument Pre-processing for negative coordinates.
- fetchez.spatial.region_to_shapely(region)[source]#
Convert a fetchez region (xmin, xmax, ymin, ymax) to a shapely box.
fetchez regions are like GMT: (west, east, south, north) while shapely regions are not: (minx, miny, maxx, maxy)
- fetchez.spatial.region_to_wkt(region)[source]#
Convert a fetchez region (xmin, xmax, ymin, ymax) to WKT (via shapely)
- fetchez.spatial.region_from_list(r_list)#
- fetchez.spatial.region_from_string(r_str)#
- fetchez.spatial.regions_reduce(region_a, region_b)[source]#
Combine two regions and find their minimum overlapping region.
- fetchez.spatial.transform_increment(dst_inc_x, dst_inc_y, transformer, region_center)[source]#
Transform grid increments from Destination SRS to Source SRS.
- Parameters:
dst_inc_x (float) – X increment in destination units (e.g. 1/3600 for 1s).
dst_inc_y (float) – Y increment in destination units.
transformer (pyproj.transformer.Transformer) – The pipeline transforming Source -> Dest.
region_center (tuple) – (x, y) center of the region in Source CRS.
- Returns:
(float, float) – The estimated (src_inc_x, src_inc_y) in source units.