Open alirezamdv opened 4 years ago
I'm not sure I understand what exactly you tried. Can you give some minimal example that show the problem?
You should be able to copy and paste the following to reproduce the error :
polarSternTracks={"type": "FeatureCollection",
"features": [{"type": "Feature",
"id": "tracks.fid-4f295163_173b9b5ce93_-6bcd",
"geometry": {"type": "MultiLineString",
"coordinates": [[[58.54856, 88.59774],
[58.49901, 88.59763],
[58.45038, 88.59749],
[58.40218, 88.59735],
[58.35523, 88.59719],
[58.30762, 88.59703],
[58.25885, 88.59687],
[58.20969, 88.59669],
[58.16062, 88.59649],
[58.11175, 88.59629]]]},
"geometry_name": "geom_multi",
"properties": {"platform": "Polarstern",
"platform_id": 9,
"expedition": "PS122/3",
"expedition_id": 5071,
"begin_date": "2020-02-24T00:00:00Z",
"end_date": "2020-05-23T00:00:00Z",
"expedition_alias": false}}],
"timeStamp": "2020-08-04T14:20:17.460Z",
"crs": {"type": "name", "properties": {"name": "urn:ogc:def:crs:EPSG::4326"}}}
import requests
from IPython.display import HTML, JSON
import json
server_url = "http://134.1.4.16:5000/" #or localhost
tracks_geojson = polarSternTracks
transform = {
"aggregation": "mean",
"dim": "time"
}
query = {
"fieldnames": "air",
"transform": transform,
"tracks": tracks_geojson
}
response = requests.post(server_url + "/api/v1.0/datasets/demo/extract_tracks", json=query)
response.json()
@benbovy Do I understand that correctly this nested structure
"coordinates": [[[58.54856, 88.59774],
[58.49901, 88.59763],
[58.45038, 88.59749],
[58.40218, 88.59735],
[58.35523, 88.59719],
[58.30762, 88.59703],
[58.25885, 88.59687],
[58.20969, 88.59669],
[58.16062, 88.59649],
[58.11175, 88.59629]]]},
is not possible with https://github.com/ESM-VFC/esm-vfc-api-demo/blob/master/app/app.py#L63?
Yes, I think right now the API only supports LineString
geometries, not MultiLineString
. This could be easily fixed.
@alirezamdv With LineString
, according shallower nesting, and an explicit track id, it works:
# fixed
#
# - MultiLineString --> LineString (and, accordingly, nesting minus one level)
# false --> False
# - add `features[0].properties.track_id = 1`
fixed_polarSternTracks = {
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"id": "tracks.fid-4f295163_173b9b5ce93_-6bcd",
"geometry": {
"type": "LineString", # MultiLineString --> LineString
"coordinates": [ # reduced nesting level
[58.54856, 88.59774],
[58.49901, 88.59763],
[58.45038, 88.59749],
[58.40218, 88.59735],
[58.35523, 88.59719],
[58.30762, 88.59703],
[58.25885, 88.59687],
[58.20969, 88.59669],
[58.16062, 88.59649],
[58.11175, 88.59629]
] # reduced nesting level
},
"geometry_name": "geom_multi",
"properties": {
"track_id": 1, # Add track id
"platform": "Polarstern",
"platform_id": 9,
"expedition": "PS122/3",
"expedition_id": 5071,
"begin_date": "2020-02-24T00:00:00Z",
"end_date": "2020-05-23T00:00:00Z",
"expedition_alias": False # Fixed typo false --> False
}
}
],
"timeStamp": "2020-08-04T14:20:17.460Z",
"crs": {
"type": "name", "properties": {"name": "urn:ogc:def:crs:EPSG::4326"}
}
}
import requests
import json
server_url = "http://app:5000/" #or localhost
transform = {
"aggregation": "mean",
"dim": "time"
}
query = {
"fieldnames": "air",
"transform": transform,
"tracks": fixed_polarSternTracks
}
response = requests.post(
server_url + "/api/v1.0/datasets/demo/extract_tracks",
json=query
)
display(response.json())
{'data': [{'air': [277.31439208984375,
277.31439208984375,
277.31439208984375,
277.31439208984375,
277.31439208984375,
277.31439208984375,
277.31439208984375,
277.31439208984375,
277.31439208984375,
277.31439208984375],
'track_id': 1}]}
@willirath I think the issue is not fixed yet, and parsing LineString was already possible, but the reason for opening this issue was to make it possible to parse MultiLineString WFS track data. as in example.
there is a bug in parsing Geojson/Json. i have tried to give a track line Geojson(Polarstern) as input, then i got JSONDecodeError error from service. You can reproduce the error with this track line GeoJson