Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F110872975
split_tiff.py
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Mon, Apr 28, 13:41
Size
1 KB
Mime Type
text/x-python
Expires
Wed, Apr 30, 13:41 (2 d)
Engine
blob
Format
Raw Data
Handle
25834161
Attached To
R8797 solarPV
split_tiff.py
View Options
import
os
from
osgeo
import
gdal
in_path
=
'/work/hyenergy/raw/SwissTopo/RGB_25cm/data_orig/2014/'
input_filename
=
'SI_25_2014_1164-21'
out_tmp
=
'/work/hyenergy/raw/SwissTopo/RGB_25cm/data_resized/crop_tool/'
os
.
system
(
"mkdir "
+
str
(
out_tmp
)
+
str
(
input_filename
))
out_path
=
out_tmp
+
input_filename
+
"/"
tile_size_x
=
250
tile_size_y
=
250
ds
=
gdal
.
Open
(
in_path
+
input_filename
+
".tif"
)
band
=
ds
.
GetRasterBand
(
1
)
xsize
=
band
.
XSize
ysize
=
band
.
YSize
input_filename_mod
=
input_filename
.
replace
(
'-'
,
'_'
)
for
i
in
range
(
0
,
xsize
,
tile_size_x
):
for
j
in
range
(
0
,
ysize
,
tile_size_y
):
com_string
=
"gdal_translate -of PNG -srcwin "
+
str
(
i
)
+
", "
+
str
(
j
)
+
", "
+
str
(
tile_size_x
)
+
", "
+
str
(
tile_size_y
)
+
" "
+
str
(
in_path
)
+
str
(
input_filename
)
+
".tif"
+
" "
+
str
(
out_path
)
+
str
(
input_filename_mod
)
+
"_"
+
str
(
i
)
+
"_"
+
str
(
j
)
+
".png"
os
.
system
(
com_string
)
#os.system( "ls "+str(out_path) )
os
.
system
(
"rm "
+
str
(
out_path
)
+
"*.aux.xml"
)
#os.system( "mkdir "+str(out_path)+ "original" )
#os.system( "mkdir "+str(out_path)+ "original/PV" )
#os.system( "mkdir "+str(out_path)+ "original/noPV" )
#os.system( "mkdir "+str(out_path)+ "labels" )
#os.system( "mkdir "+str(out_path)+ "labels/PV" )
#os.system( "mkdir "+str(out_path)+ "labels/noPV" )
# com_string = "gdal_translate -of GTIFF -srcwin
Event Timeline
Log In to Comment