Browse Source

geojson single feature handling, cf #12

master
Olivier Courtin 4 months ago
parent
commit
b354027fd9
2 changed files with 13 additions and 11 deletions
  1. +5
    -5
      neat_eo/tools/cover.py
  2. +8
    -6
      neat_eo/tools/rasterize.py

+ 5
- 5
neat_eo/tools/cover.py View File

@@ -96,11 +96,11 @@ def main(args):
print("neo cover from {} at zoom {}".format(args.geojson, args.zoom), file=sys.stderr, flush=True)
feature_map = collections.defaultdict(list)
for geojson_file in args.geojson:
with open(os.path.expanduser(geojson_file)) as f:
feature_collection = json.load(f)
srid = geojson_srid(feature_collection)
for feature in tqdm(feature_collection["features"], ascii=True, unit="feature"):
with open(os.path.expanduser(geojson_file)) as fp:
features = json.load(fp)
srid = geojson_srid(features)
features = features["features"] if "features" in features.keys() else [features]
for feature in tqdm(features, ascii=True, unit="feature"):
feature_map = geojson_parse_feature(args.zoom, srid, feature_map, feature)

cover = feature_map.keys()


+ 8
- 6
neat_eo/tools/rasterize.py View File

@@ -51,15 +51,17 @@ def add_parser(subparser, formatter_class):


def worker_spatial_index(zoom, buffer, add_progress, geojson_path):
geojson = open(os.path.expanduser(geojson_path))
assert geojson, "Unable to open {}".format(geojson_path)
fc = json.load(geojson)
srid = geojson_srid(fc)
fp = open(os.path.expanduser(geojson_path))
assert fp, "Unable to open {}".format(geojson_path)
features = json.load(fp)
srid = geojson_srid(features)
features = features["features"] if "features" in features.keys() else [features]
fp.close()

feature_map = collections.defaultdict(list)
if add_progress:
progress = tqdm(total=len(fc["features"]), ascii=True, unit="feature")
for feature in fc["features"]:
progress = tqdm(total=len(features), ascii=True, unit="feature")
for feature in features:
feature_map = geojson_parse_feature(zoom, srid, feature_map, feature, buffer)
if add_progress:
progress.update()


Loading…
Cancel
Save