Commit 3fa28e6d authored by Mario Chirinos Colunga's avatar Mario Chirinos Colunga 💬

update after crash

parent 61b71a60
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
import sys, os import sys, os
import json import json
sys.path.append('/home/geoint/GeoSentinel') sys.path.append('/home/mario/git/GeoSentinel')
from geosentinel import APISentinel from geosentinel import APISentinel
from geosentinel import polygonToBox from geosentinel import polygonToBox
......
...@@ -32,28 +32,30 @@ def getPolygonArray(image, wkt_geom): ...@@ -32,28 +32,30 @@ def getPolygonArray(image, wkt_geom):
# sr.ImportFromWkt(image.GetProjection()) # sr.ImportFromWkt(image.GetProjection())
# shapefile # shapefile
driverShp = ogr.GetDriverByName("ESRI Shapefile") # driverShp = ogr.GetDriverByName("ESRI Shapefile")
data_source = driverShp.CreateDataSource("myShape.shp") # data_source = driverShp.CreateDataSource("myShape.shp")
# srs = osr.SpatialReference() # srs = osr.SpatialReference()
# srs.ImportFromEPSG(4326) # srs.ImportFromEPSG(4326)
layer = data_source.CreateLayer("wkt", sr, ogr.wkbPolygon) # layer = data_source.CreateLayer("wkt", sr, ogr.wkbPolygon)
geometry = ogr.CreateGeometryFromWkt(wkt_geom) # geometry = ogr.CreateGeometryFromWkt(wkt_geom)
feature = ogr.Feature(layer.GetLayerDefn()) # feature = ogr.Feature(layer.GetLayerDefn())
# feature.SetStyleString("PEN(c:#FF0000,w:5px);") # feature.SetStyleString("PEN(c:#FF0000,w:5px);")
feature.SetGeometry(geometry) # feature.SetGeometry(geometry)
layer.CreateFeature(feature) # layer.CreateFeature(feature)
data_source = None # data_source = None
rast_ogr_ds = ogr.GetDriverByName('Memory').CreateDataSource( 'wrk' ) rast_ogr_ds = ogr.GetDriverByName('Memory').CreateDataSource('out')
rast_mem_lyr = rast_ogr_ds.CreateLayer( 'poly', srs=sr ) rast_mem_lyr = rast_ogr_ds.CreateLayer("wkt", sr, ogr.wkbPolygon)
# rast_mem_lyr = rast_ogr_ds.CreateLayer( 'poly', srs=sr )
feat = ogr.Feature( rast_mem_lyr.GetLayerDefn() ) feat = ogr.Feature( rast_mem_lyr.GetLayerDefn() )
feat.SetGeometryDirectly( ogr.Geometry(wkt = wkt_geom) ) feat.SetGeometry(ogr.CreateGeometryFromWkt(wkt_geom))
# feat.SetGeometryDirectly( ogr.Geometry(wkt = wkt_geom) )
rast_mem_lyr.CreateFeature( feat ) rast_mem_lyr.CreateFeature( feat )
...@@ -92,6 +94,7 @@ def rasterWkt(wkt, inputfile, outputfile): ...@@ -92,6 +94,7 @@ def rasterWkt(wkt, inputfile, outputfile):
Draw WKT Polygon into a Image Draw WKT Polygon into a Image
''' '''
print (wkt) print (wkt)
# return
print (inputfile) print (inputfile)
print (outputfile) print (outputfile)
inputImage = gdal.Open(inputfile) inputImage = gdal.Open(inputfile)
...@@ -145,7 +148,7 @@ def rasterWkt(wkt, inputfile, outputfile): ...@@ -145,7 +148,7 @@ def rasterWkt(wkt, inputfile, outputfile):
for b in range(1, output.RasterCount+1): for b in range(1, output.RasterCount+1):
np_input = inputImage.GetRasterBand(b).ReadAsArray(0,0,cols,rows) np_input = inputImage.GetRasterBand(b).ReadAsArray(0,0,cols,rows)
output.GetRasterBand(b).SetNoDataValue(-99) output.GetRasterBand(b).SetNoDataValue(-99)
output.GetRasterBand(b).WriteArray(np_input) output.GetRasterBand(b).WriteArray(np_polygon)
output.GetRasterBand(b).FlushCache() output.GetRasterBand(b).FlushCache()
# output.SetGeoTransform(geotransform) # output.SetGeoTransform(geotransform)
......
#!/bin/sh #!/bin/sh
FILE=$1 FILE=$1
JP2DIR=$2 #JP2 Output Directory JP2DIR=$2 #JP2 Output Directory
BYTILE=${3:-0}
#S2A_MSIL2A_60170515T162341_N0605_R040_T16QBJ_60170515T163103.zip #S2A_MSIL2A_60170515T162341_N0605_R040_T16QBJ_60170515T163103.zip
filepattern=$(echo $FILE | cut -d"_" -f6)"_"$(echo $FILE | cut -d"_" -f3)"_" #T16QBJ_60170515T162341_ filepattern=$(echo $FILE | cut -d"_" -f6)"_"$(echo $FILE | cut -d"_" -f3)"_" #T16QBJ_60170515T162341_
...@@ -10,21 +10,28 @@ tile=$(echo $filepattern | cut -d"_" -f1) #T16QBJ ...@@ -10,21 +10,28 @@ tile=$(echo $filepattern | cut -d"_" -f1) #T16QBJ
datetime=$(echo $filepattern | cut -d"_" -f2) #60170515T162341 datetime=$(echo $filepattern | cut -d"_" -f2) #60170515T162341
dateText=$(echo $datetime | cut -d"T" -f1) #60170515 dateText=$(echo $datetime | cut -d"T" -f1) #60170515
if [ $BYTILE -ne "0" ]; then
outDir=$JP2DIR$tile"/"$dateText
if [ ! -d $JP2DIR$tile"/" ]; then
mkdir $JP2DIR$tile"/"
fi
else
outDir=$JP2DIR$dateText
fi
outDir=$JP2DIR$dateText"/" filePrefix=$outDir"/"$filepattern
filePrefix=$outDir$filepattern
echo $filePrefix echo $filePrefix
echo $outDir echo $outDir
if [ ! -d $outDir ]; then if [ ! -d $outDir ]; then
mkdir $outDir mkdir $outDir
fi fi
if [ ! -e $filePrefix"TCI_10m.jp2" -o ! -e $filePrefix"TCI_60m.jp2" -o ! -e $filePrefix"SCL_60m.jp2" ]; then if [ ! -e $filePrefix"TCI_10m.jp2" -o ! -e $filePrefix"TCI_60m.jp2" -o ! -e $filePrefix"SCL_60m.jp2" ]; then
unzip -n -j $FILE *TCI_10m.jp2 *TCI_60m.jp2 *SCL_60m.jp2 -d $JP2DIR$dateText unzip -n -j $FILE *TCI_10m.jp2 *TCI_60m.jp2 *SCL_60m.jp2 -d $outDir
TCI10m=$outDir"L2A_"$filepattern"TCI_10m.jp2" TCI10m=$outDir"/L2A_"$filepattern"TCI_10m.jp2"
TCI60m=$outDir"L2A_"$filepattern"TCI_60m.jp2" TCI60m=$outDir"/L2A_"$filepattern"TCI_60m.jp2"
SCL60m=$outDir"L2A_"$filepattern"SCL_60m.jp2" SCL60m=$outDir"/L2A_"$filepattern"SCL_60m.jp2"
if [ -e $TCI10m ]; then if [ -e $TCI10m ]; then
mv $TCI10m $filePrefix"TCI_10m.jp2" mv $TCI10m $filePrefix"TCI_10m.jp2"
......
...@@ -5,7 +5,7 @@ JOBS=${3:-1} ...@@ -5,7 +5,7 @@ JOBS=${3:-1}
cd $PRODCUTSDIR cd $PRODCUTSDIR
ls *.zip | parallel --jobs $JOBS ExtractData.sh {} $JP2DIR ls *.zip | parallel --jobs $JOBS ExtractData.sh {} $JP2DIR 1
......
This diff is collapsed.
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