Commit de49e1e1 authored by Mario Chirinos Colunga's avatar Mario Chirinos Colunga 💬

ndvi sh p3

parent 0241d74a
#!/usr/bin/python
# -*- coding: utf-8 -*-
from osgeo import ogr
def getWKTPolygonBoundingBox(polygon):
'''!
Get the bounding box of a WKT polygon.
@param polygon: WKT polygon
@return bounding box string in format ulx uly lrx lry
>>> g = getWKTPolygonBoundingBox("POLYGON((-89.96360136135893 20.754157792347172,-89.24078398227726 20.754157792347172,-89.24078398227726 21.295577631081912,-89.96360136135893 21.295577631081912,-89.96360136135893 20.754157792347172))")
>>> print (g)
-89.96360136135893 21.295577631081912 -89.24078398227726 20.754157792347172
'''
box = ogr.CreateGeometryFromWkt(polygon).GetEnvelope() #(minX, maxX, minY, maxY)
ulx = box[0]
uly = box[3]
lrx = box[1]
lry = box[2]
# ulx uly lrx lry
return str(ulx) +" "+ str(uly) +" "+ str(lrx) +" "+ str(lry)
def main(argv):
getWKTPolygonBoundingBox(argv[1])
if __name__ == "__main__":
main(sys.argv)
#g = getWKTPolygonBoundingBox("POLYGON((-89.96360136135893 20.754157792347172,-89.24078398227726 20.754157792347172,-89.24078398227726 21.295577631081912,-89.96360136135893 21.295577631081912,-89.96360136135893 20.754157792347172))")
#print (g)
......@@ -30,17 +30,6 @@ do
echo "NIR-"$NIR
echo "VIR-"$VIR
# if [ ! -e $filepattern"04.jpg" ]; then
# gdal_translate -projwin $3 -projwin_srs WGS84 -ot Byte -scale 0 4096 0 255 -of JPEG $NIR ndvi/$filepattern"04.jpg"
# fi
# if [ ! -e $filepattern"08jpg" ]; then
# gdal_translate -projwin $3 -projwin_srs WGS84 -ot Byte -scale 0 4096 0 255 -of JPEG $VIR ndvi/$filepattern"08.jpg"
# fi
if [ ! -d "ndvi" ]; then
mkdir ndvi
fi
......@@ -49,13 +38,12 @@ do
fileout2=$(echo $filepattern | cut -d"_" -f2)
python3 $HOME/git/GeoSentinel/geosentinel/ndvi.py $NIR $VIR ndvi/$fileout2"_"$fileout1".tiff"
# convert $filepattern"04.jpg" $filepattern"03.jpg" $filepattern"02.jpg" -resize 640x480\! -combine video/$fileout2"_"$fileout1".jpg"
if [ ! -d "video" ]; then
mkdir video
fi
gdal_translate -projwin $3 -projwin_srs WGS84 -ot Byte -scale 0 4096 0 255 -of JPEG ndvi/$fileout2"_"$fileout1".tiff" video/$fileout2"_"$fileout1".jpg"
BOX = $(python3 "$HOME/git/GeoSentinel/geosentinel/getWKTPolygonBoundingBox.py" $3)
gdal_translate -projwin $BOX -projwin_srs WGS84 -ot Byte -scale 0 4096 0 255 -of JPEG ndvi/$fileout2"_"$fileout1".tiff" video/$fileout2"_"$fileout1".jpg"
cd ..
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment