Skip to content

Commit

Permalink
feat: upgrade to MPv5
Browse files Browse the repository at this point in the history
Updated MP API calls to fit v5. soilMaterial & weather discontinued.
  • Loading branch information
AdrienJaussaudGeosys committed Apr 15, 2024
1 parent be46033 commit a0fdf9c
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 10 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,7 @@ dist
*.egg-info
.idea
notebook-dev.ipynb
site
site
image_sentinel-2-l2a_S2A_15TXE_20240407_0_L2A_tiff.zip
test.py
.vscode/launch.json
3 changes: 2 additions & 1 deletion geosyspy/geosys.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,8 @@ def download_image(self, image_reference,
image_reference.season_field_id, image_reference.image_id
)
if path == "":
path = Path.cwd() / f"image_{image_reference.image_id}_tiff.zip"
file_name = image_reference.image_id.replace("|", "_")
path = Path.cwd() / f"image_{file_name}_tiff.zip"
with open(path, "wb") as f:
self.logger.info(f"writing to {path}")
f.write(response_zipped_tiff.content)
Expand Down
11 changes: 5 additions & 6 deletions geosyspy/services/map_product_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,11 @@ def get_satellite_coverage(self, season_field_id: str,
mapType = f"INSEASON_{indicator.upper()}"

parameters = f"?maps.type={mapType}&Image.Sensor=$in:{'|'.join(sensors)}&CoverageType=CLEAR&$limit=9999&$filter=Image.Date >= '{start_date}' and Image.Date <= '{end_date}'"

fields = f"&$fields=coverageType,maps,image.id,image.sensor,image.availableBands,coveragepercent,image.spatialResolution,image.date,seasonField.id"

flm_url: str = urljoin(
self.base_url,
GeosysApiEndpoints.FLM_CATALOG_IMAGERY.value.format(season_field_id) + parameters,
GeosysApiEndpoints.FLM_CATALOG_IMAGERY.value.format(season_field_id) + parameters + fields,
)
response = self.http_client.get(
flm_url,
Expand All @@ -57,10 +58,8 @@ def get_satellite_coverage(self, season_field_id: str,
"maps",
"image.id",
"image.availableBands",
"image.sensor",
"image.soilMaterial",
"image.sensor",
"image.spatialResolution",
"image.weather",
"image.date",
"seasonField.id",
]
Expand All @@ -77,7 +76,7 @@ def get_zipped_tiff(self, field_id: str,
parameters = f"/{image_id}/base-reference-map/INSEASON_{indicator.upper()}/image.tiff.zip?resolution=Sensor"

download_tiff_url: str = urljoin(
self.base_url, GeosysApiEndpoints.FLM_COVERAGE.value.format(field_id) + parameters
self.base_url, GeosysApiEndpoints.FLM_BASE_REFERENCE_MAP.value.format(field_id) + parameters
)

response_zipped_tiff = self.http_client.get(
Expand Down
4 changes: 2 additions & 2 deletions geosyspy/utils/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,8 @@ class GeosysApiEndpoints(Enum):
MASTER_DATA_MANAGEMENT_ENDPOINT = "master-data-management/v6"
VTS_ENDPOINT = "vegetation-time-series/v1/season-fields"
VTS_BY_PIXEL_ENDPOINT = "vegetation-time-series/v1/season-fields/pixels"
FLM_CATALOG_IMAGERY = "field-level-maps/v4/season-fields/{}/catalog-imagery"
FLM_COVERAGE = "field-level-maps/v4/season-fields/{}/coverage"
FLM_CATALOG_IMAGERY = "field-level-maps/v5/season-fields/{}/catalog-imagery"
FLM_BASE_REFERENCE_MAP = "field-level-maps/v5/season-fields/{}/coverage"
WEATHER_ENDPOINT = "Weather/v1/weather"
ANALYTICS_FABRIC_ENDPOINT = "analytics/metrics"
ANALYTICS_FABRIC_LATEST_ENDPOINT = "analytics/metrics-latest"
Expand Down

0 comments on commit a0fdf9c

Please sign in to comment.