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
51fb573d
Commit
51fb573d
authored
8 years ago
by
benjamin.jakimow@geo.hu-berlin.de
Browse files
Options
Downloads
Patches
Plain Diff
create test image of ~20 MB in total
parent
b9566f89
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
make/make.py
+89
-34
89 additions, 34 deletions
make/make.py
make/testdata_sources2.txt
+5
-0
5 additions, 0 deletions
make/testdata_sources2.txt
with
94 additions
and
34 deletions
make/make.py
+
89
−
34
View file @
51fb573d
import
os
,
sys
,
fnmatch
,
six
,
subprocess
,
re
from
PyQt4.QtSvg
import
*
from
PyQt4.QtCore
import
*
from
qgis
import
*
from
qgis.core
import
*
from
qgis.gui
import
*
from
PyQt4.QtGui
import
*
from
PyQt4.QtCore
import
*
from
PyQt4.QtSvg
import
*
from
PyQt4.QtXml
import
*
from
PyQt4.QtXmlPatterns
import
*
...
...
@@ -23,7 +27,7 @@ def getDOMAttributes(elem):
return
values
def
createTestData
(
pathTS
,
subsetRectangle
,
crs
,
d
irTestData
):
def
createTestData
(
dirTestData
,
pathTS
,
subsetRectangle
,
crs
,
d
rv
=
None
):
lines
=
open
(
pathTS
).
readlines
()
import
tempfile
,
random
from
timeseriesviewer.main
import
TimeSeries
,
TimeSeriesDatum
...
...
@@ -44,53 +48,71 @@ def createTestData(pathTS, subsetRectangle, crs, dirTestData):
max_offset_y
=
sw
/
100
*
max_offset
center
=
subsetRectangle
.
center
()
os
.
mkdir
(
dirTestData
)
pathVRT
=
tempfile
.
mkstemp
(
suffix
=
'
.vrt
'
,
prefix
=
'
tempVRT
'
)
if
not
os
.
path
.
exists
(
dirTestData
):
os
.
mkdir
(
dirTestData
)
dirImages
=
os
.
path
.
join
(
dirTestData
,
'
Images
'
)
if
not
os
.
path
.
exists
(
dirImages
):
os
.
mkdir
(
dirImages
)
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
)
def
random_
offset
():
offset_x
=
random
.
randrange
(
-
max_offset_x
,
max_offset_x
)
if
max_offset_x
>
0
else
0
offset_y
=
random
.
randrange
(
-
max_offset_y
,
max_offset_y
)
if
max_offset_y
>
0
else
0
return
offset_x
,
offset_y
for
TSD
in
TS
:
drvMEM
=
gdal
.
GetDriverByName
(
'
MEM
'
)
from
timeseriesviewer.main
import
transformGeometry
for
TSD
in
TS
.
data
:
assert
isinstance
(
TSD
,
TimeSeriesDatum
)
ox
,
oy
=
random_xy
()
ox
,
oy
=
random_offset
()
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
)
UL
=
transformGeometry
(
UL
,
crs
,
TSD
.
crs
)
LR
=
transformGeometry
(
LR
,
crs
,
TSD
.
crs
)
BBOX
=
QgsRectangle
(
UL
,
LR
)
#crop src dataset to UL-LR box
if
not
BBOX
.
intersects
(
TSD
.
getBoundingBox
()):
print
(
'
Please note: no intersection with BBOX:
'
+
TSD
.
pathImg
)
#crop src dataset to BBOX
#for this we use GDAL
LUT_EXT
=
{
'
ENVI
'
:
'
.bsq
'
}
dsSrc
=
gdal
.
Open
(
TSD
.
pathImg
)
assert
isinstance
(
dsSrc
,
gdal
.
Dataset
)
proj
=
dsSrc
.
GetProjection
()
trans
=
dsSrc
.
GetGeoTransform
()
trans
[
0
]
=
UL
.
x
()
trans
[
3
]
=
UL
.
y
()
filesToCopy
=
[
f
for
f
in
[
TSD
.
pathImg
,
TSD
.
pathMsk
]
if
f
is
not
None
and
os
.
path
.
exists
(
f
)]
for
pathSrc
in
filesToCopy
:
dsSrc
=
gdal
.
Open
(
pathSrc
)
ns
=
BBOX
.
width
()
/
lyr
.
rasterUnitsPerPixelX
()
nl
=
BBOX
.
heigth
()
/
lyr
.
rasterUnitsPerPixelY
()
assert
isinstance
(
dsSrc
,
gdal
.
Dataset
)
proj
=
dsSrc
.
GetProjection
()
trans
=
list
(
dsSrc
.
GetGeoTransform
())
trans
[
0
]
=
UL
.
x
()
trans
[
3
]
=
UL
.
y
()
drv
=
dsSrc
.
GetDriver
()
assert
isinstance
(
drv
,
gdal
.
Driver
)
nsDst
=
int
(
BBOX
.
width
()
/
TSD
.
lyrImg
.
rasterUnitsPerPixelX
()
)
nlDst
=
int
(
BBOX
.
height
()
/
TSD
.
lyrImg
.
rasterUnitsPerPixelY
()
)
dsDst
=
drv
.
Create
(
ns
,
nl
,
dsSrc
.
RasterCount
,
eType
=
dsSrc
.
GetRasterBand
(
1
).)
assert
isinstance
(
dsDst
,
gdal
.
Dataset
)
dsDst
.
SetProjection
(
proj
)
dsDst
.
SetGeoTransform
(
trans
)
dsDst
=
drvMEM
.
Create
(
''
,
nsDst
,
nlDst
,
dsSrc
.
RasterCount
,
eType
=
dsSrc
.
GetRasterBand
(
1
).
DataType
)
assert
isinstance
(
dsDst
,
gdal
.
Dataset
)
dsDst
.
SetProjection
(
proj
)
dsDst
.
SetGeoTransform
(
trans
)
wo
=
gdal
.
WarpOptions
()
r
=
gdal
.
Warp
(
dsDst
,
dsSrc
)
assert
r
>
0
drvDst
=
gdal
.
GetDriverByName
(
drv
)
if
drv
is
not
None
else
dsSrc
.
GetDriver
()
#try to retireve an extension
pathDst
=
os
.
path
.
join
(
dirImages
,
os
.
path
.
splitext
(
os
.
path
.
basename
(
pathSrc
))[
0
])
ext
=
drvDst
.
GetMetadata_Dict
().
get
(
'
DMD_EXTENSION
'
,
''
)
if
ext
==
''
:
ext
=
LUT_EXT
.
get
(
drvDst
.
ShortName
,
''
)
if
not
pathDst
.
endswith
(
ext
):
pathDst
+=
ext
print
(
'
Write {}
'
.
format
(
pathDst
))
drvDst
.
CreateCopy
(
pathDst
,
dsDst
)
...
...
@@ -259,6 +281,39 @@ def png2qrc(icondir, pathQrc, pngprefix='timeseriesviewer/png'):
if
__name__
==
'
__main__
'
:
icondir
=
jp
(
DIR_UI
,
*
[
'
icons
'
])
pathQrc
=
jp
(
DIR_UI
,
'
resources.qrc
'
)
if
True
:
from
qgis
import
*
from
qgis.core
import
*
from
qgis.gui
import
*
if
sys
.
platform
==
'
darwin
'
:
PATH_QGS
=
r
'
/Applications/QGIS.app/Contents/MacOS
'
os
.
environ
[
'
GDAL_DATA
'
]
=
r
'
/usr/local/Cellar/gdal/1.11.3_1/share
'
else
:
# assume OSGeo4W startup
PATH_QGS
=
os
.
environ
[
'
QGIS_PREFIX_PATH
'
]
assert
os
.
path
.
exists
(
PATH_QGS
)
qgsApp
=
QgsApplication
([],
True
)
QApplication
.
addLibraryPath
(
r
'
/Applications/QGIS.app/Contents/PlugIns
'
)
QApplication
.
addLibraryPath
(
r
'
/Applications/QGIS.app/Contents/PlugIns/qgis
'
)
qgsApp
.
setPrefixPath
(
PATH_QGS
,
True
)
qgsApp
.
initQgis
()
pathDirTestData
=
r
'
C:\Users\geo_beja\Repositories\QGIS_Plugins\SenseCarbonTSViewer\example
'
#path Novo Progresso site L7/L8/RE time series
#pathTS = r'C:\Users\geo_beja\Repositories\QGIS_Plugins\SenseCarbonTSViewer\make\testdata_sources2.txt'
pathTS
=
r
'
C:\Users\geo_beja\Repositories\QGIS_Plugins\SenseCarbonTSViewer\make\testdata_sources.txt
'
from
qgis.core
import
QgsCoordinateReferenceSystem
,
QgsPoint
,
QgsRectangle
subset
=
QgsRectangle
(
QgsPoint
(
-
55.36091
,
-
6.79851
),
#UL
QgsPoint
(
-
55.34132
,
-
6.80514
))
#LR
crs
=
QgsCoordinateReferenceSystem
(
'
EPSG:4326
'
)
# lat lon coordinates
createTestData
(
pathDirTestData
,
pathTS
,
subset
,
crs
,
drv
=
'
ENVI
'
)
exit
(
0
)
if
True
:
#convert SVG to PNG and link them into the resource file
#svg2png(icondir, overwrite=True)
...
...
This diff is collapsed.
Click to expand it.
make/testdata_sources2.txt
0 → 100644
+
5
−
0
View file @
51fb573d
#Time series definition file: 2016-02-19T14:13:05Z
#<image path>[;<mask path>]
\\141.20.140.91\SAN_Projects\SenseCarbon\BJ\COS_BACKUP\01_RasterData\02_CuttedVRT\2012-04-07_LE72270652012098EDC00_BOA.vrt
\\141.20.140.91\SAN_RSDBrazil\RapidEye\3A_VRTs\re_2012-06-12.vrt
\\141.20.140.91\SAN_Projects\SenseCarbon\BJ\COS_BACKUP\01_RasterData\02_CuttedVRT\2012-06-26_LE72270652012178EDC00_BOA.vrt
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