import geopandas as gpd
import pandas as pd
import rasterio as rio
#set working directory
import os
os.chdir('C:\\Users\\jtrum\\world_bank\\data')
#read in files
luanda = gpd.read_file('luanda2clean.geojson')
with rio.open('ESA_WorldCover_10m_2021_v200_S12E012_Map.tif') as src:
landCover = src.read()
profile = src.profile
# convert to dataframe
landCover = pd.DataFrame(landCover[0])
landCover
0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | ... | 35990 | 35991 | 35992 | 35993 | 35994 | 35995 | 35996 | 35997 | 35998 | 35999 | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | ... | 20 | 20 | 20 | 20 | 20 | 10 | 10 | 10 | 10 | 10 |
1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | ... | 20 | 20 | 20 | 20 | 20 | 10 | 10 | 10 | 10 | 10 |
2 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | ... | 20 | 20 | 20 | 20 | 20 | 20 | 20 | 20 | 10 | 10 |
3 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | ... | 20 | 20 | 20 | 20 | 20 | 20 | 20 | 20 | 10 | 10 |
4 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | ... | 20 | 20 | 30 | 30 | 20 | 20 | 20 | 10 | 10 | 10 |
... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
35995 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | ... | 30 | 30 | 30 | 30 | 30 | 30 | 30 | 30 | 30 | 30 |
35996 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | ... | 30 | 30 | 30 | 30 | 30 | 30 | 30 | 30 | 30 | 30 |
35997 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | ... | 30 | 30 | 30 | 30 | 30 | 30 | 30 | 30 | 30 | 30 |
35998 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | ... | 30 | 30 | 30 | 30 | 30 | 30 | 30 | 30 | 30 | 30 |
35999 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | ... | 30 | 30 | 30 | 30 | 30 | 30 | 30 | 30 | 30 | 30 |
36000 rows × 36000 columns
from sentinelsat import SentinelAPI, read_geojson
username = 'jtrummler'
password = 'Cf5lvg0503!'
api = SentinelAPI(username, password, 'https://scihub.copernicus.eu/dhus')
footprint = read_geojson('luanda2clean.geojson')
products = api.query(footprint,
date=('20/01/31', '20/01/01'),
platformname='Sentinel-2',
cloudcoverpercentage=(0, 10))
--------------------------------------------------------------------------- ValueError Traceback (most recent call last) File c:\Users\jtrum\miniconda3\envs\wash_scan\lib\site-packages\sentinelsat\sentinel.py:1299, in format_query_date(in_date) 1298 try: -> 1299 return datetime.strptime(in_date, "%Y%m%d").strftime("%Y-%m-%dT%H:%M:%SZ") 1300 except ValueError: File c:\Users\jtrum\miniconda3\envs\wash_scan\lib\_strptime.py:568, in _strptime_datetime(cls, data_string, format) 566 """Return a class cls instance based on the input string and the 567 format string.""" --> 568 tt, fraction, gmtoff_fraction = _strptime(data_string, format) 569 tzname, gmtoff = tt[-2:] File c:\Users\jtrum\miniconda3\envs\wash_scan\lib\_strptime.py:349, in _strptime(data_string, format) 348 if not found: --> 349 raise ValueError("time data %r does not match format %r" % 350 (data_string, format)) 351 if len(data_string) != found.end(): ValueError: time data '20/01/31' does not match format '%Y%m%d' During handling of the above exception, another exception occurred: ValueError Traceback (most recent call last) Cell In[26], line 1 ----> 1 products = api.query(footprint, 2 date=('20/01/31', '20/01/01'), 3 platformname='Sentinel-2', 4 cloudcoverpercentage=(0, 10)) File c:\Users\jtrum\miniconda3\envs\wash_scan\lib\site-packages\sentinelsat\sentinel.py:261, in SentinelAPI.query(self, area, date, raw, area_relation, order_by, limit, offset, **keywords) 184 def query( 185 self, 186 area=None, (...) 193 **keywords 194 ): 195 """Query the OpenSearch API with the coordinates of an area, a date interval 196 and any other search keywords accepted by the API. 197 (...) 259 the product's attributes (a dictionary) as the value. 260 """ --> 261 query = self.format_query(area, date, raw, area_relation, **keywords) 263 if query.strip() == "": 264 # An empty query should return the full set of products on the server, which is a bit unreasonable. 265 # The server actually raises an error instead and it's better to fail early in the client. 266 raise ValueError("Empty query.") File c:\Users\jtrum\miniconda3\envs\wash_scan\lib\site-packages\sentinelsat\sentinel.py:320, in SentinelAPI.format_query(area, date, raw, area_relation, **keywords) 318 query_parts.append("({})".format(" OR ".join(sub_parts))) 319 else: --> 320 value = _format_query_value(attr, value) 321 if value is not None: 322 query_parts.append(f"{attr}:{value}") File c:\Users\jtrum\miniconda3\envs\wash_scan\lib\site-packages\sentinelsat\sentinel.py:1223, in _format_query_value(attr, value) 1221 pass 1222 elif isinstance(value, (list, tuple)) and len(value) == 2: -> 1223 value = (format_query_date(value[0]), format_query_date(value[1])) 1224 else: 1225 raise ValueError( 1226 f"Date-type query parameter '{attr}' expects either a two-element tuple of " 1227 f"str or datetime objects or a '[<from> TO <to>]'-format string. Received {value}." 1228 ) File c:\Users\jtrum\miniconda3\envs\wash_scan\lib\site-packages\sentinelsat\sentinel.py:1301, in format_query_date(in_date) 1299 return datetime.strptime(in_date, "%Y%m%d").strftime("%Y-%m-%dT%H:%M:%SZ") 1300 except ValueError: -> 1301 raise ValueError("Unsupported date value {}".format(in_date)) ValueError: Unsupported date value 20/01/31