Skip to content

Commit

Permalink
Added add_mask function
Browse files Browse the repository at this point in the history
  • Loading branch information
Mappboy committed Sep 29, 2016
1 parent 8cf7edf commit 2db8a43
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 9 deletions.
35 changes: 27 additions & 8 deletions frisson/frisson.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,31 @@ def create_mask_vectors(output_filename, input_filename):
return call(args)


def add_mask(input_filename, output_filename, mask_vectors):
"""
$GDAL_PATH/gdal_rasterize -i -burn 17 -b 1 -b 2 -b 3 \
$VECTOR_FILE -l $NAME_OF_VECTOR_FILE_LAYER $TARGET_TIF
"""
args = [path.join(environ["GDAL_HOME"], "gdal_rasterize"),
"-i",
"-burn",
"17",
"-b",
"1",
"-b",
"2",
"-b",
"3",
"-of",
"-l",
mask_vectors,
input_filename,
output_filename,
]
return call(args)


def _points_to_string(gcp_points):
"""
Converts a list of GCP points to a gdal_translate gcp argument string
Expand All @@ -67,17 +92,11 @@ def _points_to_string(gcp_points):
return gcp_s


def add_mask(input_filename, output_filename, mask_vectors):
"""
$GDAL_PATH/gdal_translate -a_srs '+init=epsg:4326' -of VRT \
$CONVERTED_TIF $VIRTUAL_WARPED.vrt $MAGIC_GCP_STRING
"""
pass


def virtual_georeference(input_filename, output_filename, control_points):
"""
Performs the virtual georeferencing using gdal translate
$GDAL_PATH/gdal_translate -a_srs '+init=epsg:4326' -of VRT \
$CONVERTED_TIF $VIRTUAL_WARPED.vrt $MAGIC_GCP_STRING
:param input_filename:
:param output_filename:
:param control_points: should be a list of tuples (x,y,long,lat)
Expand Down
3 changes: 2 additions & 1 deletion tests/unit/test_frisson.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,4 +92,5 @@ def tearDownClass(self):
]
for tf in test_files:
if path.isfile(tf):
remove(tf)
#remove(tf)
pass

0 comments on commit 2db8a43

Please sign in to comment.