Commit 95b2d119 authored by Alfonso Ramire Pedraza's avatar Alfonso Ramire Pedraza

Update

parents 91a051b0 ea55ecf9
...@@ -9,4 +9,11 @@ area = "POLYGON((-89.79030210118333 21.122657323983717,-89.77308220413153 21.122 ...@@ -9,4 +9,11 @@ area = "POLYGON((-89.79030210118333 21.122657323983717,-89.77308220413153 21.122
footprint = "Intersects(POLYGON((-89.79030210118333 21.122657323983717,-89.77308220413153 21.122657323983717,-89.77308220413153 21.140540053466538,-89.79030210118333 21.140540053466538,-89.79030210118333 21.122657323983717)))" footprint = "Intersects(POLYGON((-89.79030210118333 21.122657323983717,-89.77308220413153 21.122657323983717,-89.77308220413153 21.140540053466538,-89.79030210118333 21.140540053466538,-89.79030210118333 21.122657323983717)))"
products = sentinel.getProducts(area, ('20150101', '20180517'), {"platformname":"Sentinel-2", "cloudcoverpercentage":"[0 TO 10]"}) products = sentinel.getProducts(area, ('20150101', '20180517'), {"platformname":"Sentinel-2", "cloudcoverpercentage":"[0 TO 10]"})
print len(products) print len(products)
for p in products:
print products[p]['filename']
print len(products)
products=sentinel.filterProducts(products)
for p in products:
print products[p]['filename']
print len(products)
#sentinel.downloadProducts(products,dir) #sentinel.downloadProducts(products,dir)
#!/bin/python
# Copyright (C) 2018 Adan Salazar <asalazargaribay@gmail.com>
#
#
# This file is part of GeoSentinel
#
#
# GeoSentinel is free software you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# GeoSentinel is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with StereoVision. If not, see <http://www.gnu.org/licenses/>.
"""
Example of dowloading Sentinel images from the Copernicus Open Access Hub < https://scihub.copernicus.eu/dhus/#/home >
"""
from sentinelsat.sentinel import read_geojson, geojson_to_wkt
from argparse import ArgumentParser
from geosentinel.ui_utils import (download_sentinel_mages)
from geosentinel.arguments import SENTINEL_ARGUMENTS
def main():
"""
Download all Sentinel images from the Copernicus Hub and save them in the folder specified by the user.
Please run: python dowload_images --help before usage
First, parse arguments provided by the user. Then choose the images that are in the
dates and polygon provided by the user, then remove the images that do not overlap more than 30 %
of the input polygon and the polygon of the image. Finally, download the remaining images.
"""
parser = ArgumentParser(description="Download Sentinel images from the Copernicus Hub",
parents=[SENTINEL_ARGUMENTS])
args = parser.parse_args()
path_json=args.input_file
args.footprint = geojson_to_wkt(read_geojson(path_json))
download_sentinel_mages(args)
if __name__ == "__main__":
main()
...@@ -82,8 +82,13 @@ class APISentinel(object): ...@@ -82,8 +82,13 @@ class APISentinel(object):
self.api.download_all(products) self.api.download_all(products)
# def filterProducts(self, products_list, user_footprint, threshold): def filterProducts(self, productList):
# products_down = OrderedDict() #, user_footprint, threshold):
products = productList.copy()
for p in productList:
if productList[p]['filename'].find("OPER_PRD") != -1:
del products[p]
# products_down = products_list.copy() # products_down = products_list.copy()
# products_df = self.api.to_dataframe(products_list) # products_df = self.api.to_dataframe(products_list)
...@@ -104,6 +109,6 @@ class APISentinel(object): ...@@ -104,6 +109,6 @@ class APISentinel(object):
# # Deleting element # # Deleting element
# del products_down[products_df.uuid[i]] # del products_down[products_df.uuid[i]]
# return products_down return products
...@@ -184,9 +184,9 @@ jas_matrix_t *imgData[nChannels]; ...@@ -184,9 +184,9 @@ jas_matrix_t *imgData[nChannels];
{ {
for (unsigned int x = 0; x < width; ++x) for (unsigned int x = 0; x < width; ++x)
{ {
//int delta = max-min; float delta = max-min;
//jas_matrix_set(imgData[i], y, x, (unsigned char)(255* (data[nChannels*(y*width+x)+i]-min)/delta) ); jas_matrix_set(imgData[i], y, x, (unsigned char)(255* ((float)data[nChannels*(y*width+x)+i]-min)/delta) );
jas_matrix_set(imgData[i], y, x, (unsigned char)(255*data[nChannels*(y*width+x)+i]/(pow(2,12))) ); //jas_matrix_set(imgData[i], y, x, (unsigned char)(255*data[nChannels*(y*width+x)+i]/(pow(2,12))) );
} }
} }
} }
......
...@@ -7,21 +7,42 @@ ext=.jpg ...@@ -7,21 +7,42 @@ ext=.jpg
cd $BASEDIR cd $BASEDIR
for f in $(find . -type f -name '*.zip') for f in $(find . -type f -name '*.zip')
do do
unzip -j $f *B02.jp2 *B03.jp2 *B04.jp2 -d $OUTDIR
filepattern=$(echo $f | cut -d"_" -f6)"_"$(echo $f | cut -d"_" -f3)"_B"
filename=$OUTDIR$filepattern
echo $filename
if [ ! -e $filename"02.jp2" -o ! -e $filename"03.jp2" -o ! -e $filename"04.jp2" ]; then
unzip -n -j $f *B02.jp2 *B03.jp2 *B04.jp2 -d $OUTDIR
else
echo PASS $f
fi
cd $OUTDIR cd $OUTDIR
red=$(ls *B04.jp2 -t |head -1) red=$(ls $filepattern"04.jp2" -t |head -1)
green=$(ls *B03.jp2 -t |head -1) green=$(ls $filepattern"03.jp2" -t |head -1)
blue=$(ls *B02.jp2 -t |head -1) blue=$(ls $filepattern"02.jp2" -t |head -1)
echo "red-"$red
echo "gre-"$green
echo "blu-"$blue
# m=$(pwd) # m=$(pwd)
# red=$m/$red # red=$m/$red
# green=$m/$green # green=$m/$green
# blue=$m/$blue # blue=$m/$blue
# ./jp2ToJPGandStretch $red if [ ! -e $filepattern"04.jpg" ]; then
# ./jp2ToJPGandStretch $green jp2ToJPGandStretch $red
# ./jp2ToJPGandStretch $blue fi
if [ ! -e $filepattern"03.jpg" ]; then
jp2ToJPGandStretch $green
fi
if [ ! -e $filepattern"02.jpg" ]; then
jp2ToJPGandStretch $blue
fi
# red=$(ls *B04.jpg -t |head -1) # red=$(ls *B04.jpg -t |head -1)
# green=$(ls *B03.jpg -t |head -1) # green=$(ls *B03.jpg -t |head -1)
# blue=$(ls *B02.jpg -t |head -1) # blue=$(ls *B02.jpg -t |head -1)
...@@ -29,12 +50,16 @@ do ...@@ -29,12 +50,16 @@ do
# red=$m/$red # red=$m/$red
# green=$m/$green # green=$m/$green
# blue=$m/$blue # blue=$m/$blue
# convert $red $green $blue -combine $(OUTDIR)/$count$ext if [ ! -d "video" ]; then
mkdir video
fi
fileout=$(echo $filepattern | cut -d"_" -f2)
convert $filepattern"04.jpg" $filepattern"02.jpg" $filepattern"02.jpg" -combine video/$fileout".jpg"
# rm *.jp2 # rm *.jp2
# rm *B04.jpg # rm *B04.jpg
# rm *B03.jpg # rm *B03.jpg
# rm *B02.jpg # rm *B02.jpg
# count=$((count+1)) # count=$((count+1))
cd .. cd ..
done
done
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