|
16 | 16 | VALID_IMAGE_TYPES = [".tif", ".tiff", ".png", ".jpg", ".jpeg"] |
17 | 17 | VALID_SHAPE_TYPES = [".geojson"] |
18 | 18 |
|
19 | | -__all__ = ["read_generic", "read_geojson", "read_image", "VALID_IMAGE_TYPES", "VALID_SHAPE_TYPES"] |
| 19 | +__all__ = ["generic", "geojson", "image", "VALID_IMAGE_TYPES", "VALID_SHAPE_TYPES"] |
20 | 20 |
|
21 | 21 |
|
22 | 22 | @docstring_parameter( |
23 | 23 | valid_image_types=", ".join(VALID_IMAGE_TYPES), |
24 | 24 | valid_shape_types=", ".join(VALID_SHAPE_TYPES), |
25 | 25 | default_coordinate_system=DEFAULT_COORDINATE_SYSTEM, |
26 | 26 | ) |
27 | | -def read_generic( |
| 27 | +def generic( |
28 | 28 | input: Path, |
29 | 29 | data_axes: Sequence[str] | None = None, |
30 | 30 | coordinate_system: str | None = None, |
@@ -54,21 +54,21 @@ def read_generic( |
54 | 54 | if input.suffix in VALID_SHAPE_TYPES: |
55 | 55 | if data_axes is not None: |
56 | 56 | warnings.warn("data_axes is not used for geojson files", UserWarning, stacklevel=2) |
57 | | - return read_geojson(input, coordinate_system=coordinate_system) |
| 57 | + return geojson(input, coordinate_system=coordinate_system) |
58 | 58 | elif input.suffix in VALID_IMAGE_TYPES: |
59 | 59 | if data_axes is None: |
60 | 60 | raise ValueError("data_axes must be provided for image files") |
61 | | - return read_image(input, data_axes=data_axes, coordinate_system=coordinate_system) |
| 61 | + return image(input, data_axes=data_axes, coordinate_system=coordinate_system) |
62 | 62 | else: |
63 | 63 | raise ValueError(f"Invalid file type. Must be one of {VALID_SHAPE_TYPES + VALID_IMAGE_TYPES}") |
64 | 64 |
|
65 | 65 |
|
66 | | -def read_geojson(input: Path, coordinate_system: str) -> GeoDataFrame: |
| 66 | +def geojson(input: Path, coordinate_system: str) -> GeoDataFrame: |
67 | 67 | """Reads a GeoJSON file and returns a parsed GeoDataFrame spatial element""" |
68 | 68 | return ShapesModel.parse(input, transformations={coordinate_system: Identity()}) |
69 | 69 |
|
70 | 70 |
|
71 | | -def read_image(input: Path, data_axes: Sequence[str], coordinate_system: str) -> DataArray: |
| 71 | +def image(input: Path, data_axes: Sequence[str], coordinate_system: str) -> DataArray: |
72 | 72 | """Reads an image file and returns a parsed Image2D spatial element""" |
73 | 73 | # this function is just a draft, the more general one will be available when |
74 | 74 | # https://github.com/scverse/spatialdata-io/pull/234 is merged |
|
0 commit comments