aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuilhem Moulin <guilhem@fripost.org>2023-09-28 15:39:04 +0200
committerGuilhem Moulin <guilhem@fripost.org>2023-09-28 15:40:54 +0200
commitee0d38dd8dce3572fd572ac532f1185ae84a0437 (patch)
treeab0b5883c841d1aa90248c1139a03202709c8457
parentd068cc2a1058ba23515593a6e2fb8bd178946f5d (diff)
Allow overwriting an existing observation file.
(Or creating such file without creating a matching project.) In this mode, --observation-file is mandatory and --project-name is left unset. The file is silently overwritten.
-rwxr-xr-xgis-observation-map15
1 files changed, 11 insertions, 4 deletions
diff --git a/gis-observation-map b/gis-observation-map
index dd8f5fe..ffeff5d 100755
--- a/gis-observation-map
+++ b/gis-observation-map
@@ -78,7 +78,8 @@ class geometryAction(argparse.Action):
parser = argparse.ArgumentParser(
description='Create a QGIS project with observations from Artdatabanken.',
prog = programName,
- usage='''%(prog)s --project-home=DIR --project-name=NAME {--geometry=FILE|--point=X,Y} ...'''
+ usage='''%(prog)s --project-home=DIR --project-name=NAME {--geometry=FILE|--point=X,Y} ...
+ %(prog)s --observation-file=NAME {--geometry=FILE|--point=X,Y} ...'''
)
parser.add_argument('--project-name', metavar='NAME',
help='Project filename (and title)')
@@ -140,6 +141,9 @@ if args.project_home is not None and args.project_name is not None:
if args.observation_file is None:
args.observation_file = Path('observations')
+elif args.observation_file is not None:
+ projectInstance = None
+
elif args.project_home is None or args.project_name is None:
parser.print_usage()
exit(1)
@@ -329,7 +333,7 @@ for geom in args.geometry:
geometries.append(geometry)
feature = layer.GetNextFeature()
-if len(args.geometry) == 0:
+if len(args.geometry) == 0 and projectInstance is not None:
r = geometries[0].GetGeometryRef(0)
pt0X, pt0Y = r.GetPoint_2D(0)
pt1X, pt1Y = r.GetPoint_2D(2)
@@ -502,7 +506,10 @@ def getObservations(taxonLists, taxonRedlistCategories, searchFilter):
json.dump(obs, fp)
fp.flush()
- gdal.VectorTranslate(path.as_posix(), fp.name, format=drv.name, reproject=True, dstSRS=target_srs)
+ gdal.VectorTranslate(
+ path.as_posix(), fp.name, format=drv.name,
+ accessMode='overwrite',
+ reproject=True, dstSRS=target_srs)
obs = None
if projectInstance is not None:
@@ -796,7 +803,7 @@ if args.since is not None or args.until is not None:
getObservations(taxonLists, taxonRedlistCategories, searchFilter)
topo_maps = ['Topografi 10', 'Topografi 50', 'Topografi 100']
-if args.topo_basedir is not None:
+if args.topo_basedir is not None and projectInstance is not None:
idxContains = {}
for topo in topo_maps:
qlr_paths = []