Skip to content

Commit

Permalink
Initial Project Version
Browse files Browse the repository at this point in the history
  • Loading branch information
SinghCoder committed Jun 14, 2019
0 parents commit 6a86525
Show file tree
Hide file tree
Showing 70 changed files with 33,761 additions and 0 deletions.
Binary file added myproject/db.sqlite3
Binary file not shown.
21 changes: 21 additions & 0 deletions myproject/manage.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/env python
"""Django's command-line utility for administrative tasks."""
import os
import sys


def main():
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'myproject.settings')
try:
from django.core.management import execute_from_command_line
except ImportError as exc:
raise ImportError(
"Couldn't import Django. Are you sure it's installed and "
"available on your PYTHONPATH environment variable? Did you "
"forget to activate a virtual environment?"
) from exc
execute_from_command_line(sys.argv)


if __name__ == '__main__':
main()
Empty file added myproject/myapp/__init__.py
Empty file.
Binary file added myproject/myapp/__pycache__/__init__.cpython-36.pyc
Binary file not shown.
Binary file added myproject/myapp/__pycache__/admin.cpython-36.pyc
Binary file not shown.
Binary file added myproject/myapp/__pycache__/forms.cpython-36.pyc
Binary file not shown.
Binary file added myproject/myapp/__pycache__/models.cpython-36.pyc
Binary file not shown.
Binary file added myproject/myapp/__pycache__/urls.cpython-36.pyc
Binary file not shown.
Binary file added myproject/myapp/__pycache__/views.cpython-36.pyc
Binary file not shown.
5 changes: 5 additions & 0 deletions myproject/myapp/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Register your models here.
from django.contrib import admin
from myapp.models import UserProfileInfo, User
# Register your models here.
admin.site.register(UserProfileInfo)
5 changes: 5 additions & 0 deletions myproject/myapp/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from django.apps import AppConfig


class MyappConfig(AppConfig):
name = 'myapp'
109 changes: 109 additions & 0 deletions myproject/myapp/datacube.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
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=' ')








14 changes: 14 additions & 0 deletions myproject/myapp/forms.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from django import forms
from myapp.models import UserProfileInfo
from django.contrib.auth.models import User
class UserForm(forms.ModelForm):
password = forms.CharField(widget=forms.PasswordInput())
class Meta():
model = User
fields = ('username','password','email')


class UserProfileInfoForm(forms.ModelForm):
class Meta():
model = UserProfileInfo
fields = ('portfolio_site','profile_pic')
22 changes: 22 additions & 0 deletions myproject/myapp/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Generated by Django 2.2.2 on 2019-06-10 08:51

from django.db import migrations, models


class Migration(migrations.Migration):

initial = True

dependencies = [
]

operations = [
migrations.CreateModel(
name='Indices',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('indexName', models.CharField(max_length=10)),
('indexFormula', models.CharField(max_length=100)),
],
),
]
25 changes: 25 additions & 0 deletions myproject/myapp/migrations/0002_userprofileinfo.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Generated by Django 2.2.2 on 2019-06-12 16:28

from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('myapp', '0001_initial'),
]

operations = [
migrations.CreateModel(
name='UserProfileInfo',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('portfolio_site', models.URLField(blank=True)),
('profile_pic', models.ImageField(blank=True, upload_to='profile_pics')),
('user', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
],
),
]
19 changes: 19 additions & 0 deletions myproject/myapp/migrations/0003_userprofileinfo_indiceslist.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Generated by Django 2.2.2 on 2019-06-12 18:50

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('myapp', '0002_userprofileinfo'),
]

operations = [
migrations.AddField(
model_name='userprofileinfo',
name='indicesList',
field=models.CharField(default="'NDVI':(nir-r)/(nir+r)", max_length=20000),
preserve_default=False,
),
]
18 changes: 18 additions & 0 deletions myproject/myapp/migrations/0004_auto_20190613_0915.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 2.2.2 on 2019-06-13 03:45

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('myapp', '0003_userprofileinfo_indiceslist'),
]

operations = [
migrations.AlterField(
model_name='userprofileinfo',
name='indicesList',
field=models.CharField(default="'NDVI':((nir-r)/(nir+r))", max_length=20000),
),
]
18 changes: 18 additions & 0 deletions myproject/myapp/migrations/0005_auto_20190613_0938.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 2.2.2 on 2019-06-13 04:08

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('myapp', '0004_auto_20190613_0915'),
]

operations = [
migrations.AlterField(
model_name='userprofileinfo',
name='indicesList',
field=models.CharField(default='NDVI:((nir-r)/(nir+r))', max_length=20000),
),
]
Empty file.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
18 changes: 18 additions & 0 deletions myproject/myapp/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
from django.db import models
from django.contrib.auth.models import User

# Create your models here.
class indices(models.Model):
indexName = models.CharField(max_length = 10)
indexFormula = models.CharField(max_length = 100)

def __str__(self):
return self.indexName

class UserProfileInfo(models.Model):
user = models.OneToOneField(User,on_delete=models.CASCADE)
portfolio_site = models.URLField(blank=True)
profile_pic = models.ImageField(upload_to='profile_pics',blank=True)
indicesList = models.CharField(max_length = 20000,default = "NDVI:((nir-r)/(nir+r))")
def __str__(self):
return self.user.username
Binary file added myproject/myapp/static/images/first.TIF
Binary file not shown.
31 changes: 31 additions & 0 deletions myproject/myapp/templates/base.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Base</title>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
</head>
<body>
<nav class="navbar navbar-default navbar-static-top">
<div class="container">
<ul class="nav navbar-nav">
{# Django Home Link / Admin Link / Register Link#}
<li><a class="navbar-brand" href="{% url 'index' %}">DJANGO</a></li>
<li><a class="navbar-link" href="{% url 'admin:index' %}">Admin</a></li>
<li><a class="navbar-link" href="{% url 'myapp:register' %}">Register</a></li>
{# Some logic on what to display for last item#}
{% if user.is_authenticated %}
<li><a href="{% url 'logout' %}">Logout</a></li>
{% else %}
<li><a class="navbar-link" href="{% url 'myapp:user_login' %}">Login</a></li>
{% endif %}
</ul>
</div>
</nav>
<div class="container">
{% block body_block %}
{% endblock %}
</div>
</body>
</html>
Empty file.
Loading

0 comments on commit 6a86525

Please sign in to comment.