Skip to content

Commit

Permalink
export: fix name of polygonization vector layer
Browse files Browse the repository at this point in the history
  • Loading branch information
iona5 committed Oct 14, 2024
1 parent 52381ea commit c1ae622
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion darts-export/src/darts_export/inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def export_polygonized(self, path: Path, filename_prefix="pred_segments"):
# create the vector output datasets
gpkg_drv = ogr.GetDriverByName("GPKG")
gpkg_ds = gpkg_drv.CreateDataSource(path / f"{filename_prefix}.gpkg")
output_layer = gpkg_ds.CreateLayer("filename_prefix", geom_type=ogr.wkbPolygon, srs=dta.GetSpatialRef())
output_layer = gpkg_ds.CreateLayer(filename_prefix, geom_type=ogr.wkbPolygon, srs=dta.GetSpatialRef())

# add the field where to store the polygonization threshold
field = ogr.FieldDefn("DN", ogr.OFTInteger)
Expand Down
4 changes: 4 additions & 0 deletions darts-export/test/test_inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ def test_writeVectors(probabilities: Dataset, tmp_path: Path):
if gdal_has_parquet:
assert (tmp_path / "pred_segments.parquet").is_file()

gpkg_layers = gpd.list_layers(tmp_path / "pred_segments.gpkg")
assert len(gpkg_layers) == 1
assert gpkg_layers.iloc[0]["name"] == "pred_segments"

gdf = gpd.read_file(tmp_path / "pred_segments.gpkg")
assert gdf.shape == (1, 2) # one feature, two attributes (fid, DN)
assert gdf.iloc[0].geometry.wkt == (
Expand Down

0 comments on commit c1ae622

Please sign in to comment.