Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

import_single_local_xyz_file: add separator for XYZ files #31

Merged
merged 1 commit into from
May 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions src/grass_gis_helpers/data_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,11 +217,12 @@ def import_local_raster_data(
return imported_local_data


def get_xyz_file_infos(xyz_file):
def get_xyz_file_infos(xyz_file, separator="space"):
"""Get the infos of a XYZ file to resolution, bounding box and pixelcenter

Args:
xyz_file (str): XYZ file path to import
separator (str): Separator of XYZ file; default is "space"
Returns:
res (float): Resolution of the XYZ file
xyz_reg (dict): Dictionary with region of the XYZ file
Expand Down Expand Up @@ -264,7 +265,7 @@ def get_xyz_file_infos(xyz_file):
output="dummy",
input=xyz_file,
flags="sg",
separator="space",
separator=separator,
)
xyz_reg = {
item.split("=")[0]: float(item.split("=")[1])
Expand All @@ -277,7 +278,9 @@ def get_xyz_file_infos(xyz_file):
return res, xyz_reg, shift_needed


def import_single_local_xyz_file(xyz_file, output, use_cur_reg=False):
def import_single_local_xyz_file(
xyz_file, output, use_cur_reg=False, separator="space"
):
"""Import single XYZ file

Args:
Expand All @@ -286,10 +289,13 @@ def import_single_local_xyz_file(xyz_file, output, use_cur_reg=False):
use_cur_reg (bool): If True the XYZ file will only be imported if it
overlaps with the current region, otherwise it
will not be imported
separator (str): Separator of XYZ file; default is "space"
Returns:
output (str): If the output is imported, otherwise return None
"""
res, xyz_reg, shift_needed = get_xyz_file_infos(xyz_file)
res, xyz_reg, shift_needed = get_xyz_file_infos(
xyz_file, separator=separator
)
# check if aoi overlaps
if use_cur_reg:
cur_reg = grass.region()
Expand Down Expand Up @@ -328,7 +334,7 @@ def import_single_local_xyz_file(xyz_file, output, use_cur_reg=False):
input=xyz_file,
output=output,
method="mean",
separator="space",
separator=separator,
quiet=True,
overwrite=True,
)
Expand Down