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

update after crash

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