diff options
author | Guilhem Moulin <guilhem@fripost.org> | 2023-09-29 01:04:13 +0200 |
---|---|---|
committer | Guilhem Moulin <guilhem@fripost.org> | 2023-09-29 01:04:53 +0200 |
commit | d5e1dccb6864ed691022dd9ed55eae9c116c0185 (patch) | |
tree | 34c67975b56493ec2b58203397116322e334033f | |
parent | 3032a4febd6242154db20ee617957b36c241948f (diff) |
Observations: factor out layername.
-rwxr-xr-x | gis-observation-map | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/gis-observation-map b/gis-observation-map index 8f3f999..ea057e0 100755 --- a/gis-observation-map +++ b/gis-observation-map @@ -440,8 +440,6 @@ def getObservations(taxonLists, taxonRedlistCategories, searchFilter): if obs['type'] == 'FeatureCollection' and 'features' in obs.keys() and type(obs['features']) == list: print(f'{len(obs["features"])} observations found', file=sys.stderr) - if 'name' not in obs.keys() or obs['name'] is None: - obs['name'] = 'Fynd' for feat in obs['features']: if (type(feat) != dict or 'type' not in feat.keys() or feat['type'] != 'Feature' or 'properties' not in feat.keys() or type(feat['properties']) != dict): @@ -506,6 +504,9 @@ def getObservations(taxonLists, taxonRedlistCategories, searchFilter): if args.observation_format is not None and drv.name.lower() != args.observation_format.lower(): print(f'WARN: overwriting observation file format to {drv.name}', file=sys.stderr) + layername = 'fynd' + obs['name'] = layername + if drv.name == geojson_drv.name: # for GeoJSON, don't reproject and pretty-print the output; this # is useful for manual inspection and/or debugging @@ -518,7 +519,7 @@ def getObservations(taxonLists, taxonRedlistCategories, searchFilter): gdal.VectorTranslate( path.as_posix(), fp.name, format=drv.name, - layerName='Fynd', + layerName=layername, geometryType='POINT', accessMode='overwrite', reproject=True, dstSRS=target_srs) @@ -526,7 +527,7 @@ def getObservations(taxonLists, taxonRedlistCategories, searchFilter): if projectInstance is not None: query = '''"IsPositiveObservation" AND "IsNaturalOccurrence" AND "CoordinateUncertaintyInMeters" <= 250''' - layer = QgsVectorLayer(path.as_posix() + f'|subset={query}', 'Fynd', 'ogr') + layer = QgsVectorLayer(f'{path.as_posix()}|layername={layername}|subset={query}', layername.title(), 'ogr') if not layer.isValid(): raise Exception(f'ERROR: {path}: failed to load in QGIS') if args.observation_style is not None: |