-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
load signage: raise error when year is NaN, move update_gis function
- Loading branch information
Showing
4 changed files
with
54 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
from typing import Dict | ||
|
||
import fiona | ||
|
||
|
||
def update_gis(input_file_path: str, output_file_path: str, new_properties: Dict): | ||
''' | ||
Utility function that reads a GIS file (GeoPackage or Shapefile), update some properties, | ||
then write a new shapefile (typically in /tmp). Useful to test specific property values. | ||
''' | ||
|
||
with fiona.open(input_file_path) as source: | ||
with fiona.open(output_file_path, | ||
mode='w', | ||
crs=source.crs, | ||
driver=source.driver, | ||
schema=source.schema) as dest: | ||
for feat in source: | ||
dest.write(fiona.Feature( | ||
geometry=feat.geometry, | ||
properties={**feat.properties, **new_properties} | ||
)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters