In [1]:
import os, sys
os.environ['DJANGO_SETTINGS_MODULE'] = 'geospaas_project.settings'
sys.path.insert(0, '/vagrant/shared/course_vm/geospaas_project/')
import django
django.setup()
from django.conf import settings
In [2]:
from geospaas.catalog.models import Dataset
from geospaas.catalog.models import DatasetURI
In [3]:
# find all images
datasets = Dataset.objects.all()
In [4]:
print datasets.count()
# print info about each image
for ds in datasets:
print ds
In [12]:
# get just one Dataset
ds0 = datasets.first()
print ds0.time_coverage_start
Out[12]:
In [6]:
# print joined fields (Foreign key)
for ds in datasets:
print ds.source.instrument.short_name,
print ds.source.platform.short_name
In [7]:
# get infromation from Foreign key in the opposite direction
print ds0.dataseturi_set.first().uri
In [15]:
# search by time
ds = Dataset.objects.filter(time_coverage_start='2012-03-03 09:38:10.423969')
print ds
ds = Dataset.objects.filter(time_coverage_start__gte='1900-03-01')
print ds
In [16]:
# search by instrument
ds = Dataset.objects.filter(source__instrument__short_name='MODIS')
print ds
In [25]:
# search by spatial location
ds0 = Dataset.objects.first()
ds0_geom = ds0.geographic_location.geometry
ds_ovlp = Dataset.objects.filter(
geographic_location__geometry__intersects=ds0_geom,
time_coverage_start__gte='2015-05-02',
source__platform__short_name='AQUA')
print ds_ovlp
In [26]:
dsovlp0 = ds_ovlp.first()
In [31]:
uri0 = dsovlp0.dataseturi_set.first().uri
print uri0
In [33]:
from nansat import Nansat
n = Nansat(uri0.replace('file://localhost', ''))
print n[1]
In [ ]: