本文整理汇总了Python中sentinelsat.sentinel.SentinelAPI.get_footprints方法的典型用法代码示例。如果您正苦于以下问题:Python SentinelAPI.get_footprints方法的具体用法?Python SentinelAPI.get_footprints怎么用?Python SentinelAPI.get_footprints使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sentinelsat.sentinel.SentinelAPI
的用法示例。
在下文中一共展示了SentinelAPI.get_footprints方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: query_and_create
# 需要导入模块: from sentinelsat.sentinel import SentinelAPI [as 别名]
# 或者: from sentinelsat.sentinel.SentinelAPI import get_footprints [as 别名]
def query_and_create(self, start=None, end=None):
'''Query the last scene available on period filtered by start time
and end dates. By default start is current time and end is 7 days ago.'''
end = end or datetime.utcnow()
start = start or datetime.utcnow() - timedelta(days=7)
coords = ','.join([('%f %f' % coord) for coord in self.geom.coords[0]])
scenes_created = []
try:
api = SentinelAPI(settings.SENTINEL_USER, settings.SENTINEL_PASSWORD, settings.SENTINEL_API_URL)
print('sentinel initialized on %s, with %s - %s' %
(settings.SENTINEL_API_URL, settings.SENTINEL_USER, settings.SENTINEL_PASSWORD))
except AttributeError:
api = SentinelAPI(settings.SENTINEL_USER, settings.SENTINEL_PASSWORD)
print('sentinel initialized on %s, with %s - %s' %
(settings.SENTINEL_API_URL, ettings.SENTINEL_USER, settings.SENTINEL_PASSWORD))
print('sentinelsat query -s %s -e %s coords %s q %s' % (start, end, coords, self.query))
if self.query:
query = dict([i.split('=') for i in self.query.split(',')])
api.query(coords, start, end, **query)
else:
api.query(coords, start, end)
features = api.get_footprints()['features']
print('%s features found' % len(features))
for feature in features:
product_id = feature['properties']['product_id']
try:
Scene.objects.get(product=product_id)
print('Scene of product %s already exists' % product_id)
except Scene.DoesNotExist:
print('Creating scene with data: %s' % feature)
scene = Scene.objects.create(
product=product_id,
identifier=feature['properties']['identifier'],
date=datetime.strptime(
feature['properties']['date_beginposition'],
'%Y-%m-%dT%H:%M:%S.%fZ'
),
polarisation=feature['properties']['polarisationmode'],
orbit_direction=feature['properties']['orbitdirection'],
sensor_mode=feature['properties']['sensoroperationalmode'],
product_type=feature['properties']['producttype'],
sat=feature['properties']['platformname'],
geom=Polygon(feature['geometry']['coordinates'][0]))
print('Scene of product %s created' % product_id)
scenes_created.append(scene)
return scenes_created
示例2: test_footprints_s2
# 需要导入模块: from sentinelsat.sentinel import SentinelAPI [as 别名]
# 或者: from sentinelsat.sentinel.SentinelAPI import get_footprints [as 别名]
def test_footprints_s2():
api = SentinelAPI(**_api_auth)
api.query(
get_coordinates('tests/map.geojson'),
"20151219", "20151228", platformname="Sentinel-2"
)
with open('tests/expected_search_footprints_s2.geojson', 'r') as geojson_file:
expected_footprints = geojson.loads(geojson_file.read())
# to compare unordered lists (JSON objects) they need to be sorted or changed to sets
assert set(api.get_footprints()) == set(expected_footprints)
示例3: test_footprints_s1
# 需要导入模块: from sentinelsat.sentinel import SentinelAPI [as 别名]
# 或者: from sentinelsat.sentinel.SentinelAPI import get_footprints [as 别名]
def test_footprints_s1():
api = SentinelAPI(**_api_auth)
api.query(
get_coordinates('tests/map.geojson'),
datetime(2014, 10, 10), datetime(2014, 12, 31), producttype="GRD"
)
with open('tests/expected_search_footprints_s1.geojson', 'r') as geojson_file:
expected_footprints = geojson.loads(geojson_file.read())
# to compare unordered lists (JSON objects) they need to be sorted or changed to sets
assert set(api.get_footprints()) == set(expected_footprints)
示例4: test_footprints
# 需要导入模块: from sentinelsat.sentinel import SentinelAPI [as 别名]
# 或者: from sentinelsat.sentinel.SentinelAPI import get_footprints [as 别名]
def test_footprints():
api = SentinelAPI(
environ.get('SENTINEL_USER'),
environ.get('SENTINEL_PASSWORD')
)
api.query(get_coordinates('tests/map.geojson'), datetime(2014, 10, 10), datetime(2014, 12, 31), producttype="GRD")
expected_footprints = geojson.loads(open('tests/expected_search_footprints.geojson', 'r').read())
# to compare unordered lists (JSON objects) they need to be sorted or changed to sets
assert set(api.get_footprints()) == set(expected_footprints)
示例5: search
# 需要导入模块: from sentinelsat.sentinel import SentinelAPI [as 别名]
# 或者: from sentinelsat.sentinel.SentinelAPI import get_footprints [as 别名]
def search(
user, password, geojson, start, end, download, md5,
sentinel1, sentinel2, cloud, footprints, path, query, url):
"""Search for Sentinel products and, optionally, download all the results
and/or create a geojson file with the search result footprints.
Beyond your SciHub user and password, you must pass a geojson file
containing the polygon of the area you want to search for. If you
don't specify the start and end dates, it will search in the last 24 hours.
"""
api = SentinelAPI(user, password, url)
search_kwargs = {}
if cloud:
search_kwargs.update(
{"platformname": "Sentinel-2",
"cloudcoverpercentage": "[0 TO %s]" % cloud})
elif sentinel2:
search_kwargs.update({"platformname": "Sentinel-2"})
elif sentinel1:
search_kwargs.update({"platformname": "Sentinel-1"})
if query is not None:
search_kwargs.update(dict([i.split('=') for i in query.split(',')]))
api.query(get_coordinates(geojson), start, end, **search_kwargs)
if footprints is True:
footprints_geojson = api.get_footprints()
with open(os.path.join(path, "search_footprints.geojson"), "w") as outfile:
outfile.write(gj.dumps(footprints_geojson))
if download is True:
result = api.download_all(path, checksum=md5)
if md5 is True:
corrupt_scenes = [(path, info["id"]) for path, info in result.items() if info is not None]
if len(corrupt_scenes) > 0:
with open(os.path.join(path, "corrupt_scenes.txt"), "w") as outfile:
for corrupt_tuple in corrupt_scenes:
outfile.write("%s : %s\n" % corrupt_tuple)
else:
for product in api.get_products():
print('Product %s - %s' % (product['id'], product['summary']))
print('---')
print(
'%s scenes found with a total size of %.2f GB' %
(len(api.get_products()), api.get_products_size()))
示例6: search
# 需要导入模块: from sentinelsat.sentinel import SentinelAPI [as 别名]
# 或者: from sentinelsat.sentinel.SentinelAPI import get_footprints [as 别名]
def search(user, password, geojson, start, end, download, footprints, path, query):
"""Search for Sentinel-1 products and, optionally, download all the results
and/or create a geojson file with the search result footprints.
Beyond your SciHub user and password, you must pass a geojson file
containing the polygon of the area you want to search for. If you
don't specify the start and end dates, it will search in the last 24 hours.
"""
api = SentinelAPI(user, password)
if query is not None:
query = dict([i.split('=') for i in query.split(',')])
api.query(get_coordinates(geojson), start, end, **query)
else:
api.query(get_coordinates(geojson), start, end)
if footprints is True:
footprints_geojson = api.get_footprints()
with open(os.path.join(path, "search_footprints.geojson"), "w") as outfile:
outfile.write(gj.dumps(footprints_geojson))
if download is True:
api.download_all(path)
else:
for product in api.get_products():
print('Product %s - %s' % (product['id'], product['summary']))