Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
EO Time Series Viewer
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Analyze
Contributor analytics
CI/CD analytics
Repository analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Benjamin Jakimow
EO Time Series Viewer
Commits
a38769ae
Commit
a38769ae
authored
8 years ago
by
Benjamin Jakimow
Browse files
Options
Downloads
Patches
Plain Diff
method to create a test data set
parent
eea2288f
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
make/make.py
+77
-0
77 additions, 0 deletions
make/make.py
with
77 additions
and
0 deletions
make/make.py
+
77
−
0
View file @
a38769ae
...
...
@@ -5,6 +5,10 @@ from PyQt4.QtGui import *
from
PyQt4.QtXml
import
*
from
PyQt4.QtXmlPatterns
import
*
from
PyQt4.uic.Compiler.qtproxies
import
QtGui
import
gdal
from
timeseriesviewer
import
DIR_UI
,
file_search
jp
=
os
.
path
.
join
...
...
@@ -18,6 +22,79 @@ def getDOMAttributes(elem):
values
[
str
(
attr
.
nodeName
())]
=
attr
.
nodeValue
()
return
values
def
createTestData
(
pathTS
,
subsetRectangle
,
crs
,
dirTestData
):
lines
=
open
(
pathTS
).
readlines
()
import
tempfile
,
random
from
timeseriesviewer.main
import
TimeSeries
,
TimeSeriesDatum
from
qgis.core
import
QgsRectangle
,
QgsPoint
,
QgsPointV2
,
QgsCoordinateReferenceSystem
max_offset
=
0
#in %
assert
isinstance
(
subsetRectangle
,
QgsRectangle
)
assert
isinstance
(
crs
,
QgsCoordinateReferenceSystem
)
TS
=
TimeSeries
()
TS
.
loadFromFile
(
pathTS
)
sw
=
subsetRectangle
.
width
()
sh
=
subsetRectangle
.
height
()
max_offset_x
=
sw
/
100
*
max_offset
max_offset_y
=
sw
/
100
*
max_offset
center
=
subsetRectangle
.
center
()
os
.
mkdir
(
dirTestData
)
pathVRT
=
tempfile
.
mkstemp
(
suffix
=
'
.vrt
'
,
prefix
=
'
tempVRT
'
)
def
random_xy
():
offset_x
=
center
.
x
()
+
random
.
randrange
(
-
max_offset_x
,
max_offset_x
)
offset_y
=
center
.
y
()
+
random
.
randrange
(
-
max_offset_y
,
max_offset_y
)
return
offset_x
,
offset_y
for
TSD
in
TS
:
assert
isinstance
(
TSD
,
TimeSeriesDatum
)
ox
,
oy
=
random_xy
()
UL
=
QgsPoint
(
subsetRectangle
.
xMinimum
()
+
ox
,
subsetRectangle
.
yMaximum
()
+
oy
)
LR
=
QgsPoint
(
subsetRectangle
.
xMaximum
()
+
ox
,
subsetRectangle
.
yMinimum
()
+
oy
)
lyr
=
QgsRasterLayer
(
TSD
.
pathImg
)
crsDS
=
lyr
.
dataProvider
().
crs
()
assert
isinstance
(
crsDS
,
QgsCoordinateReferenceSystem
)
transform
=
QgsCoordinateTransform
(
crs
,
crsDS
)
#transform UL and LR into CRS of source data set
UL
=
transform
.
transform
(
UL
)
LR
=
transform
.
transform
(
LR
)
BBOX
=
QgsRectangle
(
UL
,
LR
)
#crop src dataset to UL-LR box
#for this we use GDAL
dsSrc
=
gdal
.
Open
(
TSD
.
pathImg
)
assert
isinstance
(
dsSrc
,
gdal
.
Dataset
)
proj
=
dsSrc
.
GetProjection
()
trans
=
dsSrc
.
GetGeoTransform
()
trans
[
0
]
=
UL
.
x
()
trans
[
3
]
=
UL
.
y
()
ns
=
BBOX
.
width
()
/
lyr
.
rasterUnitsPerPixelX
()
nl
=
BBOX
.
heigth
()
/
lyr
.
rasterUnitsPerPixelY
()
drv
=
dsSrc
.
GetDriver
()
assert
isinstance
(
drv
,
gdal
.
Driver
)
dsDst
=
drv
.
Create
(
ns
,
nl
,
dsSrc
.
RasterCount
,
eType
=
dsSrc
.
GetRasterBand
(
1
).)
assert
isinstance
(
dsDst
,
gdal
.
Dataset
)
dsDst
.
SetProjection
(
proj
)
dsDst
.
SetGeoTransform
(
trans
)
def
make
(
ROOT
):
#find ui files
ui_files
=
file_search
(
ROOT
,
'
*.ui
'
,
recursive
=
True
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment