Skip to content

Commit

Permalink
Improved frontend, displayed proper alerts,SRTM & Aster DEM included
Browse files Browse the repository at this point in the history
  • Loading branch information
SinghCoder committed Jun 18, 2019
1 parent fddf016 commit ce240d0
Show file tree
Hide file tree
Showing 17 changed files with 247 additions and 2,570 deletions.
Binary file added myproject/ASTGTM2_N29E079/ASTGTM2_N29E079_dem.tif
Binary file not shown.
Binary file added myproject/ASTGTM2_N29E079/ASTGTM2_N29E079_num.tif
Binary file not shown.
Binary file added myproject/ASTGTM2_N29E079/README.pdf
Binary file not shown.
Binary file added myproject/__pycache__/datacube.cpython-36.pyc
Binary file not shown.
Binary file modified myproject/db.sqlite3
Binary file not shown.
Binary file added myproject/myapp/__pycache__/datacube.cpython-36.pyc
Binary file not shown.
Binary file modified myproject/myapp/__pycache__/urls.cpython-36.pyc
Binary file not shown.
Binary file modified myproject/myapp/__pycache__/views.cpython-36.pyc
Binary file not shown.
132 changes: 23 additions & 109 deletions myproject/myapp/datacube.py
Original file line number Diff line number Diff line change
@@ -1,109 +1,23 @@
import gdal
import affine
import numpy as np
import rasterio
import utm

urls = [
'./19971001/19971001_B1.TIF',
'./19971017/19971017_B1.TIF',
'./19971102/19971102_B1.TIF',
'./19971118/19971118_B1.TIF',
'./19981004/19981004_B1.TIF',
'./19981020/19981020_B1.TIF',
'./19981105/19981105_B1.TIF',
'./19981121/19981121_B1.TIF',
'./19981207/19981207_B1.TIF',
'./19981223/19981223_B1.TIF',
'./19991124/19991124_B1.TIF',
'./19991226/19991226_B1.TIF',
'./20081015/20081015_B1.TIF',
'./20081031/20081031_B1.TIF',
'./20081116/20081116_B1.TIF',
'./20081202/20081202_B1.TIF',
'./20081218/20081218_B1.TIF',
'./20091102/20091103_B1.TIF',
'./20091119/20091119_B1.TIF',
'./20091205/20091205_B1.TIF',
'./20101021/20101021_B1.TIF',
'./20101106/20101106_B1.TIF',
'./20101208/20101208_B1.TIF',
'./20101224/20101224_B1.TIF',
'./20111024/20111024_B1.TIF',
'./20111109/20111109_B1.TIF',
'./20171016/20171016_B1.TIF',
'./20171101/20171101_B1.TIF',
'./20171117/20171117_B1.TIF',
'./20171203/20171203_B1.TIF',
'./20171219/20171219_B1.TIF',
'./20181003/20181003_B1.TIF',
'./20181010/20181010_B1.TIF',
'./20181019/20181019_B1.TIF',
'./20181026/20181026_B1.TIF',
'./20181104/20181104_B1.TIF',
'./20181127/20181127_B1.TIF',
'./20181222/20181222_B1.TIF'
]

def pixel2coord(col, row, a):
"""Returns global coordinates to pixel center using base-0 raster index"""
xp = a[1] * col + a[2] * row + a[1]* 0.5 + a[2] * 0.5 + a[0]
yp = a[4]* col + a[5] * row + a[4]* 0.5 + a[5]* 0.5 + a[3]
return(xp, yp)


# latitudes and longitude values of the rectangular region
lat1=29+(23/60)+(29/3600)
lng1=79+(27/60)+(58/3600)
lat2=29+(23/60)+(28/3600)
lng2=79+(27/60)+(9/3600)

lat3=29+(22/60)+(45/3600)
lng3=79+(27/60)+(9/3600)
lat4=29+(22/60)+(44/3600)
lng4=79+(27/60)+(59/3600)

[easting1,northing1,zoneNumber1,zoneLetter1] = utm.from_latlon(lat1, lng1)
[easting2,northing2,zoneNumber2,zoneLetter2] = utm.from_latlon(lat2, lng2)
[easting3,northing3,zoneNumber3,zoneLetter3] = utm.from_latlon(lat3, lng3)
[easting4,northing4,zoneNumber4,zoneLetter4] = utm.from_latlon(lat4, lng4)

e=easting1-easting2
n=northing2-northing3

imgNum = 3
bandnum = [1,2,3,4,5,6,7]
year= 1



cube=np.full((1350,1350,20,7),None)

for x in range(0,imgNum):

img = gdal.Open(urls[x])
imgGeoTransf = img.GetGeoTransform()

row = img.RasterYSize
col = img.RasterXSize

bandNo = int(urls[x][-5])

for i in range(0,row):
for j in range(0,col):
utm=pixel2coord(j,i,imgGeoTransf)
utmX=int(utm[0])
utmY=int(utm[1])
if((utmY>easting1 and utmY<easting2) and (utmX>northing1 and utmX<northing4)):
cube[utmX][utmY][year][bandNo]=img.GetRasterBand(1).ReadAsArray()[i][j]
print(cube[utmX][utmY][year][bandNo],end=' ')
else:
print('sed',end=' ')








import json
import numpy as np
import datacube
import requests
import xarray
import pandas as pd
import geopy.distance
from osgeo import gdal,ogr
import datacube

dc = datacube.Datacube()
lat = 10
lng = 10
query = {
'time': ('1995-01-01', '2219-12-12'),
'lat': (lat,lat),
'lon': (lng,lng)
}
products = ['ls7_level1_usgs', 'ls5_level1_usgs']
# find similarly named measurements
measurements = set(dc.index.products.get_by_name(products[0]).measurements.keys())
for prod in products[1:]:
measurements.intersection(dc.index.products.get_by_name(products[0]).measurements.keys())
21 changes: 21 additions & 0 deletions myproject/myapp/datacubee.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import json
import numpy as np
import datacube
import requests
import xarray
import pandas as pd
import geopy.distance
from osgeo import gdal,ogr
import datacube

dc = datacube.Datacube()
query = {
'time': ('1995-01-01', '2219-12-12'),
'lat': (lat,lat),
'lon': (lng,lng)
}
products = ['ls7_level1_usgs', 'ls5_level1_usgs']
# find similarly named measurements
measurements = set(dc.index.products.get_by_name(products[0]).measurements.keys())
for prod in products[1:]:
measurements.intersection(dc.index.products.get_by_name(products[0]).measurements.keys())
93 changes: 58 additions & 35 deletions myproject/myapp/templates/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
<script src="https://code.jquery.com/jquery-3.4.1.js" integrity="sha256-WpOohJOqMqqyKL9FccASB9O0KwACQJpFTUBLTYOVvVU=" crossorigin="anonymous"></script>
<script src="https://cdn-geoweb.s3.amazonaws.com/esri-leaflet/0.0.1-beta.5/esri-leaflet.js"></script>
<script src="https://cdn-geoweb.s3.amazonaws.com/esri-leaflet-geocoder/0.0.1-beta.5/esri-leaflet-geocoder.js"></script>
<script src="https://unpkg.com/sweetalert/dist/sweetalert.min.js"></script>
<script>
function CheckIndex(val){
console.log(val);
Expand Down Expand Up @@ -48,55 +49,77 @@
x: []
}], {
margin: { t: 0 } } );
// document.getElementsByClassName('svg-container')[0].classList.toggle('hide');
}
function loaded(){
populateIndices();
var element = document.getElementById('showGraphLink');
element.click();
sendRequest("/myapp/loadCube/","GET")
.then(function (response) {
console.log('cube loaded');
}).catch(function(e){
console.log('error');
});
}
function closeIndexDiv(){
document.getElementById('indexInputField').style.display = 'none';
$('select.indexSelect').val('NDVI');
}
function toggleDivClass(){
console.log('ji');
var element = document.getElementById('tester');
if(element.style.display != 'none')
element.style.display = 'none';
else
element.style.display = 'block';
return false;
}
</script>
</head>
<body onload='populateIndices();'>
<body onload='loaded();'>
<div class='overlay'></div>
<div id='logoDiv'>
<a href='/myapp/home/'><img src="{% static '/images/isroLogo.png' %}" id='logoImg'></a>
</div>
<!-- Container to hold the map -->
<div>
<div id = "map"></div>
<div id = "tester"></div>
<div id='loader'>
<div class="container">
<div class="planet">
<div class="spots">
<div class="spot"></div>
<div class="spot"></div>
<div class="spot"></div>
<span style="font-size: 20px;color:white;">Loading.... Please wait</span>
<div class="spot"></div>
<div class="spot"></div>
<div class="spot"></div>
</div>
</div>
<div class="orbit">
<div class="satelite">
<div class="head"></div>
<div class="body"></div>
<div class="wings">
<div class="wing"></div>
<div class="wing"></div>
</div>
<div class="tail"></div>
<div class="antena">
<div class="waves">
<div class="wave"></div>
<div class="wave"></div>
<div class="wave"></div>
</div>
</div>
<div id='loader'>
<div class="container">
<div class="planet">
<div class="spots">
<div class="spot"></div>
<div class="spot"></div>
<div class="spot"></div>
<span style="font-size: 20px;color:white;">Loading.... Please wait</span>
<div class="spot"></div>
<div class="spot"></div>
<div class="spot"></div>
</div>
</div>
<div class="orbit">
<div class="satelite">
<div class="head"></div>
<div class="body"></div>
<div class="wings">
<div class="wing"></div>
<div class="wing"></div>
</div>
<div class="tail"></div>
<div class="antena">
<div class="waves">
<div class="wave"></div>
<div class="wave"></div>
<div class="wave"></div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div id="mapNGraphContainer">
<a class="slide" href="javascript:void(0)" onclick="toggleDivClass();" id="showGraphLink">Slide Out</a>
<div id = "map" class="showDiv"></div>
<div id = "tester" class="showDiv"></div>
</div>
<div id='logout' style='position: absolute;top:0;left:45vw;'>
<pre>
Expand Down
1 change: 1 addition & 0 deletions myproject/myapp/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@
url(r'^register/$',views.register,name='register'),
url(r'^user_login/$',views.user_login,name='user_login'),
url(r'^getElevations/',myapp.views.getElevations, name = 'getElevations'),
url(r'^loadCube/$',myapp.views.loadCube,name='loadCube'),
]
Loading

0 comments on commit ce240d0

Please sign in to comment.