stac-utils / pystac

Python library for working with any SpatioTemporal Asset Catalog (STAC)
https://pystac.readthedocs.io
Other
358 stars 120 forks source link

How to create geometry for satellite swath using gml:posList #943

Closed zxdawn closed 1 year ago

zxdawn commented 1 year ago

I'm trying to read the geometry of TROPOMI NO2 data which is downloaded from S5P-PAL. The API download method on the website is based on pystac.

It's easy to get the geometry when search the item:

import requests
import hashlib
import xarray as xr
from pystac import Collection
from pystac_client import ItemSearch
from shapely.geometry import shape

timefilter = "2019-08-10"

s5pcoll = Collection.from_file(
    "https://data-portal.s5p-pal.com/cat/sentinel-5p/S5P_L2__NO2___/catalog.json"
)
endpoint = s5pcoll.get_single_link("search").target

items = ItemSearch(endpoint, datetime=timefilter).items()

item = list(items)[-1]

shape(item.geometry)
image

However, I want to generate a similar geometry using the downloaded netcdf file:

# download data
download_url = item.assets["download"].href
product_filename = item.properties["physical_name"]
product_hash = item.properties["hash"]

print(f"Downloading {product_filename}...")
r = requests.get(download_url)
with open(f"./{product_filename}", "wb") as product_file:
    product_file.write(r.content)
file_hash = "md5:" + hashlib.md5(open(product_filename, "rb").read()).hexdigest()
print("Checking hash...")
assert file_hash == product_hash
print("Product was downloaded correctly")

# read poslist
metadata = 'METADATA/EOP_METADATA/om:featureOfInterest/eop:multiExtentOf/gml:surfaceMembers/gml:exterior'
poslist = xr.open_dataset(product_filename, group=metadata).attrs['gml:posList']

# generate geom
import pygml

#   copy api from https://sentinelsat.readthedocs.io/en/v1.1.1/api_overview.html
geom = pygml.parse(f"""<gml:Polygon srsName="http://www.opengis.net/gml/srs/epsg.xml#4326" xmlns:gml="http://www.opengis.net/gml">
<gml:exterior><gml:LinearRing><gml:posList>{poslist}</gml:posList></gml:LinearRing></gml:exterior></gml:Polygon>""")

# get the polygon
polygon_swath = shape(geom.__geo_interface__)

Then, I check the polygon_swath and it's wrong:

image

I suppose there should be some tricks for creating geometry using gml:posList.

Here are detailed values in case you wanna check them without downloading data. Thanks for your help!

poslist ``` '51.702038 49.610016 52.94394 51.01299 54.166298 52.503414 55.366966 54.0892 56.54364 55.778553 57.693607 57.580452 58.814045 59.503914 59.90187 61.558575 60.952957 63.755463 61.96344 66.10437 62.928852 68.615036 63.844116 71.29686 64.7041 74.15731 65.50247 77.20298 66.23337 80.43615 66.89038 83.85569 67.467155 87.45515 67.95721 91.22266 68.3547 95.13931 68.65447 99.18 68.85244 103.31237 68.945786 107.500275 68.93306 111.703575 68.81441 115.881714 68.59158 119.995186 68.26782 124.00822 67.847694 127.89088 67.3364 131.61931 66.73979 135.17621 66.064606 138.55106 65.31692 141.73866 64.50329 144.73924 63.62978 147.55606 62.702198 150.19583 61.72575 152.66656 60.705215 154.97762 59.645348 157.13954 58.54975 159.16205 57.422207 161.05547 56.265892 162.82954 55.083527 164.49341 53.87775 166.05579 52.650826 167.52486 51.404835 168.90799 50.14136 170.2121 48.8622 171.44348 47.56856 172.60777 46.261955 173.71053 44.943287 174.75618 43.6138 175.74937 42.274166 176.69377 40.92526 177.59311 39.56804 178.45091 38.202946 179.2699 36.830643 -179.9472 35.45172 -179.19763 34.066658 -178.47934 32.675938 -177.79007 31.279902 -177.12813 29.879005 -176.49168 28.473516 -175.87917 27.063877 -175.28883 25.650331 -174.71983 24.233177 -174.17036 22.812666 -173.63972 21.388971 -173.1267 19.962389 -172.63036 18.533195 -172.14955 17.101381 -171.6837 15.667246 -171.23222 14.231025 -170.79407 12.792814 -170.36867 11.352718 -169.95576 9.911045 -169.5542 8.467765 -169.16383 7.0230436 -168.78418 5.5771675 -168.41461 4.129959 -168.05511 2.6818724 -167.70464 1.2327191 -167.36348 -0.21725322 -167.03116 -1.6679472 -166.70721 -3.1192677 -166.3915 -4.5711927 -166.08391 -6.023487 -165.78374 -7.4761825 -165.49132 -8.929155 -165.20627 -10.382393 -164.92842 -11.835696 -164.65752 -13.289056 -164.39372 -14.742453 -164.13687 -16.195707 -163.88661 -17.64882 -163.64307 -19.101753 -163.40642 -20.554422 -163.17642 -22.006695 -162.953 -23.458603 -162.73619 -24.910103 -162.52649 -26.360989 -162.3232 -27.811409 -162.12709 -29.261166 -161.9379 -30.710295 -161.75607 -32.158745 -161.58147 -33.60651 -161.41481 -35.05337 -161.25578 -36.499462 -161.10516 -37.944675 -160.96307 -39.388977 -160.83008 -40.832317 -160.70634 -42.27467 -160.59283 -43.715965 -160.49 -45.156227 -160.39873 -46.59529 -160.31926 -48.033295 -160.25368 -49.470036 -160.202 -50.90555 -160.1664 -52.33968 -160.14778 -53.7725 -160.1481 -55.20383 -160.16957 -56.63361 -160.21416 -58.061806 -160.28535 -59.48826 -160.38583 -60.91285 -160.52089 -62.335415 -160.69386 -63.75571 -160.91165 -65.17356 -161.18176 -66.58865 -161.5127 -68.00061 -161.91605 -69.4089 -162.40646 -70.81293 -163.00266 -72.21183 -163.72867 -73.60449 -164.61661 -74.98933 -165.71136 -76.36417 -167.07208 -77.72577 -168.7863 -79.06952 -170.97989 -80.38809 -173.84282 -81.66968 -177.6704 -82.89469 177.07292 -84.02808 169.64104 -84.13447 168.74101 -84.18268 169.47952 -84.866486 -174.9634 -84.97181 -145.05681 -84.4018 -128.51079 -83.59613 -116.88854 -82.89573 -110.1891 -82.13626 -104.68907 -81.506836 -101.00197 -80.81718 -97.58405 -80.229004 -95.05255 -79.6168 -92.707985 -79.56094 -92.50668 -78.96835 -90.482994 -78.26648 -88.31617 -77.61542 -86.49006 -76.80546 -84.42254 -76.01154 -82.58172 -74.957245 -80.37894 -73.83833 -78.30165 -72.186775 -75.65186 -70.15045 -72.94698 -68.35873 -70.97637 -68.35873 -70.97637 -67.9932 -74.90061 -67.53469 -78.68576 -66.98882 -82.3114 -66.36156 -85.7638 -65.65964 -89.03559 -64.8886 -92.1229 -64.055 -95.02791 -63.164646 -97.755196 -62.222633 -100.31119 -61.2344 -102.70504 -60.20434 -104.94605 -59.136566 -107.043724 -58.034912 -109.00831 -56.902607 -110.84923 -55.74281 -112.57618 -54.558243 -114.197784 -53.35097 -115.72203 -52.123577 -117.157394 -50.877483 -118.50988 -49.614567 -119.78652 -48.336643 -120.993866 -47.044666 -122.136536 -45.73994 -123.21971 -44.423542 -124.24811 -43.096584 -125.22598 -41.759663 -126.15675 -40.413765 -127.04384 -39.059486 -127.89091 -37.69767 -128.70059 -36.328594 -129.47511 -34.95315 -130.21753 -33.571423 -130.92935 -32.184277 -131.61314 -30.791653 -132.27017 -29.394314 -132.90282 -27.992514 -133.5122 -26.58645 -134.09973 -25.176401 -134.66656 -23.762665 -135.21431 -22.345657 -135.74391 -20.925377 -136.25604 -19.50223 -136.75223 -18.07635 -137.233 -16.647902 -137.69923 -15.217007 -138.15158 -13.78397 -138.59077 -12.348912 -139.01758 -10.911923 -139.43248 -9.473176 -139.83598 -8.032804 -140.22845 -6.5910053 -140.61098 -5.147803 -140.98314 -3.7033153 -141.34596 -2.2577176 -141.69969 -0.8111446 -142.04451 0.6364474 -142.38077 2.08482 -142.70877 3.5339684 -143.02888 4.98374 -143.34134 6.434145 -143.64613 7.8849235 -143.94374 9.336228 -144.23438 10.787847 -144.5179 12.239685 -144.79463 13.691687 -145.06479 15.143835 -145.32838 16.596067 -145.5855 18.04829 -145.83609 19.500433 -146.08063 20.952421 -146.31877 22.40436 -146.55034 23.855988 -146.7757 25.307415 -146.99475 26.75843 -147.20738 28.209133 -147.4136 29.659483 -147.61324 31.109331 -147.806 32.558628 -147.99207 34.007523 -148.1709 35.455795 -148.34258 36.903416 -148.50659 38.35047 -148.66267 39.79687 -148.81049 41.242542 -148.94948 42.68748 -149.07956 44.13167 -149.19974 45.57509 -149.30939 47.0177 -149.4078 48.459362 -149.49413 49.900196 -149.5674 51.34013 -149.62633 52.77905 -149.66948 54.21696 -149.69524 55.653767 -149.7017 57.08949 -149.68686 58.523964 -149.64781 59.957123 -149.58128 61.388927 -149.4837 62.819195 -149.35025 64.24773 -149.17496 65.67438 -148.95131 67.09897 -148.67021 68.52104 -148.32114 69.94026 -147.88898 71.356026 -147.35602 72.7677 -146.69774 74.17423 -145.88167 75.57426 -144.86232 76.96568 -143.57558 78.34572 -141.92943 79.70983 -139.78325 81.05079 -136.92006 82.35663 -132.98654 83.605804 -127.38667 84.75781 -119.102005 85.733284 -106.51747 86.3862 -87.9803 86.52973 -64.91008 86.10684 -43.599743 85.26702 -28.207735 84.188156 -18.042818 82.9794 -11.284399 81.69733 -6.6260324 80.37099 -3.2919695 79.01628 -0.8275803 77.64243 1.043294 76.255135 2.4935496 74.8578 3.6346073 73.45301 4.543778 72.04231 5.274626 70.62695 5.864872 69.20775 6.344059 67.785286 6.7308598 66.3601 7.043411 64.93254 7.2932906 63.502907 7.4908624 62.071407 7.643044 60.63824 7.7570615 59.203598 7.837409 59.060005 7.8438516 59.04922 8.002876 58.795647 11.145475 58.293922 15.714073 57.912148 18.533953 57.5352 21.033106 57.24614 22.830679 56.950253 24.601126 56.71313 25.984163 56.458817 27.44097 56.245102 28.647604 56.024834 29.876347 56.00482 29.987253 55.79319 31.153336 55.54368 32.51221 55.31277 33.754414 55.02529 35.278393 54.74197 36.751106 54.360546 38.675583 53.945015 40.678333 53.30203 43.55667 52.44617 46.974476 51.702038 49.610016 51.702038 49.610016' ```
item.geometry ``` {'type': 'MultiPolygon', 'coordinates': [[[[-180.0, -84.64510401188912], [-174.9634, -84.866486], [-145.05681, -84.97181], [-128.51079, -84.4018], [-116.88854, -83.59613], [-110.1891, -82.89573], [-104.68907, -82.13626], [-101.00197, -81.506836], [-97.58405, -80.81718], [-95.05255, -80.229004], [-92.707985, -79.6168], [-92.50668, -79.56094], [-90.482994, -78.96835], [-88.31617, -78.26648], [-86.49006, -77.61542], [-84.42254, -76.80546], [-82.58172, -76.01154], [-80.37894, -74.957245], [-78.30165, -73.83833], [-75.65186, -72.186775], [-72.94698, -70.15045], [-70.97637, -68.35873], [-70.97637, -68.35873], [-74.90061, -67.9932], [-78.68576, -67.53469], [-82.3114, -66.98882], [-85.7638, -66.36156], [-89.03559, -65.65964], [-92.1229, -64.8886], [-95.02791, -64.055], [-97.755196, -63.164646], [-100.31119, -62.222633], [-102.70504, -61.2344], [-104.94605, -60.20434], [-107.043724, -59.136566], [-109.00831, -58.034912], [-110.84923, -56.902607], [-112.57618, -55.74281], [-114.197784, -54.558243], [-115.72203, -53.35097], [-117.157394, -52.123577], [-118.50988, -50.877483], [-119.78652, -49.614567], [-120.993866, -48.336643], [-122.136536, -47.044666], [-123.21971, -45.73994], [-124.24811, -44.423542], [-125.22598, -43.096584], [-126.15675, -41.759663], [-127.04384, -40.413765], [-127.89091, -39.059486], [-128.70059, -37.69767], [-129.47511, -36.328594], [-130.21753, -34.95315], [-130.92935, -33.571423], [-131.61314, -32.184277], [-132.27017, -30.791653], [-132.90282, -29.394314], [-133.5122, -27.992514], [-134.09973, -26.58645], [-134.66656, -25.176401], [-135.21431, -23.762665], [-135.74391, -22.345657], [-136.25604, -20.925377], [-136.75223, -19.50223], [-137.233, -18.07635], [-137.69923, -16.647902], [-138.15158, -15.217007], [-138.59077, -13.78397], [-139.01758, -12.348912], [-139.43248, -10.911923], [-139.83598, -9.473176], [-140.22845, -8.032804], [-140.61098, -6.5910053], [-140.98314, -5.147803], [-141.34596, -3.7033153], [-141.69969, -2.2577176], [-142.04451, -0.8111446], [-142.38077, 0.6364474], [-142.70877, 2.08482], [-143.02888, 3.5339684], [-143.34134, 4.98374], [-143.64613, 6.434145], [-143.94374, 7.8849235], [-144.23438, 9.336228], [-144.5179, 10.787847], [-144.79463, 12.239685], [-145.06479, 13.691687], [-145.32838, 15.143835], [-145.5855, 16.596067], [-145.83609, 18.04829], [-146.08063, 19.500433], [-146.31877, 20.952421], [-146.55034, 22.40436], [-146.7757, 23.855988], [-146.99475, 25.307415], [-147.20738, 26.75843], [-147.4136, 28.209133], [-147.61324, 29.659483], [-147.806, 31.109331], [-147.99207, 32.558628], [-148.1709, 34.007523], [-148.34258, 35.455795], [-148.50659, 36.903416], [-148.66267, 38.35047], [-148.81049, 39.79687], [-148.94948, 41.242542], [-149.07956, 42.68748], [-149.19974, 44.13167], [-149.30939, 45.57509], [-149.4078, 47.0177], [-149.49413, 48.459362], [-149.5674, 49.900196], [-149.62633, 51.34013], [-149.66948, 52.77905], [-149.69524, 54.21696], [-149.7017, 55.653767], [-149.68686, 57.08949], [-149.64781, 58.523964], [-149.58128, 59.957123], [-149.4837, 61.388927], [-149.35025, 62.819195], [-149.17496, 64.24773], [-148.95131, 65.67438], [-148.67021, 67.09897], [-148.32114, 68.52104], [-147.88898, 69.94026], [-147.35602, 71.356026], [-146.69774, 72.7677], [-145.88167, 74.17423], [-144.86232, 75.57426], [-143.57558, 76.96568], [-141.92943, 78.34572], [-139.78325, 79.70983], [-136.92006, 81.05079], [-132.98654, 82.35663], [-127.38667, 83.605804], [-119.102005, 84.75781], [-106.51747, 85.733284], [-87.9803, 86.3862], [-64.91008, 86.52973], [-43.599743, 86.10684], [-28.207735, 85.26702], [-18.042818, 84.188156], [-11.284399, 82.9794], [-6.6260324, 81.69733], [-3.2919695, 80.37099], [-0.8275803, 79.01628], [1.043294, 77.64243], [2.4935496, 76.255135], [3.6346073, 74.8578], [4.543778, 73.45301], [5.274626, 72.04231], [5.864872, 70.62695], [6.344059, 69.20775], [6.7308598, 67.785286], [7.043411, 66.3601], [7.2932906, 64.93254], [7.4908624, 63.502907], [7.643044, 62.071407], [7.7570615, 60.63824], [7.837409, 59.203598], [7.8438516, 59.060005], [8.002876, 59.04922], [11.145475, 58.795647], [15.714073, 58.293922], [18.533953, 57.912148], [21.033106, 57.5352], [22.830679, 57.24614], [24.601126, 56.950253], [25.984163, 56.71313], [27.44097, 56.458817], [28.647604, 56.245102], [29.876347, 56.024834], [29.987253, 56.00482], [31.153336, 55.79319], [32.51221, 55.54368], [33.754414, 55.31277], [35.278393, 55.02529], [36.751106, 54.74197], [38.675583, 54.360546], [40.678333, 53.945015], [43.55667, 53.30203], [46.974476, 52.44617], [49.610016, 51.702038], [49.610016, 51.702038], [49.610016, 51.702038], [49.610016, 51.702038], [51.01299, 52.94394], [52.503414, 54.166298], [54.0892, 55.366966], [55.778553, 56.54364], [57.580452, 57.693607], [59.503914, 58.814045], [61.558575, 59.90187], [63.755463, 60.952957], [66.10437, 61.96344], [68.615036, 62.928852], [71.29686, 63.844116], [74.15731, 64.7041], [77.20298, 65.50247], [80.43615, 66.23337], [83.85569, 66.89038], [87.45515, 67.467155], [91.22266, 67.95721], [95.13931, 68.3547], [99.18, 68.65447], [103.31237, 68.85244], [107.500275, 68.945786], [111.703575, 68.93306], [115.881714, 68.81441], [119.995186, 68.59158], [124.00822, 68.26782], [127.89088, 67.847694], [131.61931, 67.3364], [135.17621, 66.73979], [138.55106, 66.064606], [141.73866, 65.31692], [144.73924, 64.50329], [147.55606, 63.62978], [150.19583, 62.702198], [152.66656, 61.72575], [154.97762, 60.705215], [157.13954, 59.645348], [159.16205, 58.54975], [161.05547, 57.422207], [162.82954, 56.265892], [164.49341, 55.083527], [166.05579, 53.87775], [167.52486, 52.650826], [168.90799, 51.404835], [170.2121, 50.14136], [171.44348, 48.8622], [172.60777, 47.56856], [173.71053, 46.261955], [174.75618, 44.943287], [175.74937, 43.6138], [176.69377, 42.274166], [177.59311, 40.92526], [178.45091, 39.56804], [179.2699, 38.202946], [180.0, 36.923193259803284], [180.0, 90.0], [-180.0, 90.0], [-180.0, 36.923193259803284], [-179.9472, 36.830643], [-179.19763, 35.45172], [-178.47934, 34.066658], [-177.79007, 32.675938], [-177.12813, 31.279902], [-176.49168, 29.879005], [-175.87917, 28.473516], [-175.28883, 27.063877], [-174.71983, 25.650331], [-174.17036, 24.233177], [-173.63972, 22.812666], [-173.1267, 21.388971], [-172.63036, 19.962389], [-172.14955, 18.533195], [-171.6837, 17.101381], [-171.23222, 15.667246], [-170.79407, 14.231025], [-170.36867, 12.792814], [-169.95576, 11.352718], [-169.5542, 9.911045], [-169.16383, 8.467765], [-168.78418, 7.0230436], [-168.41461, 5.5771675], [-168.05511, 4.129959], [-167.70464, 2.6818724], [-167.36348, 1.2327191], [-167.03116, -0.21725322], [-166.70721, -1.6679472], [-166.3915, -3.1192677], [-166.08391, -4.5711927], [-165.78374, -6.023487], [-165.49132, -7.4761825], [-165.20627, -8.929155], [-164.92842, -10.382393], [-164.65752, -11.835696], [-164.39372, -13.289056], [-164.13687, -14.742453], [-163.88661, -16.195707], [-163.64307, -17.64882], [-163.40642, -19.101753], [-163.17642, -20.554422], [-162.953, -22.006695], [-162.73619, -23.458603], [-162.52649, -24.910103], [-162.3232, -26.360989], [-162.12709, -27.811409], [-161.9379, -29.261166], [-161.75607, -30.710295], [-161.58147, -32.158745], [-161.41481, -33.60651], [-161.25578, -35.05337], [-161.10516, -36.499462], [-160.96307, -37.944675], [-160.83008, -39.388977], [-160.70634, -40.832317], [-160.59283, -42.27467], [-160.49, -43.715965], [-160.39873, -45.156227], [-160.31926, -46.59529], [-160.25368, -48.033295], [-160.202, -49.470036], [-160.1664, -50.90555], [-160.14778, -52.33968], [-160.1481, -53.7725], [-160.16957, -55.20383], [-160.21416, -56.63361], [-160.28535, -58.061806], [-160.38583, -59.48826], [-160.52089, -60.91285], [-160.69386, -62.335415], [-160.91165, -63.75571], [-161.18176, -65.17356], [-161.5127, -66.58865], [-161.91605, -68.00061], [-162.40646, -69.4089], [-163.00266, -70.81293], [-163.72867, -72.21183], [-164.61661, -73.60449], [-165.71136, -74.98933], [-167.07208, -76.36417], [-168.7863, -77.72577], [-170.97989, -79.06952], [-173.84282, -80.38809], [-177.6704, -81.66968], [-180.0, -82.21256701157384], [-180.0, -84.64510401188912]]], [[[180.0, -82.21256701157384], [177.07292, -82.89469], [169.64104, -84.02808], [168.74101, -84.13447], [169.47952, -84.18268], [180.0, -84.64510401188912], [180.0, -82.21256701157384]]]]} ```
geom.__geo_interface__ ``` {'type': 'Polygon', 'coordinates': [[(49.610016, 51.702038), (51.01299, 52.94394), (52.503414, 54.166298), (54.0892, 55.366966), (55.778553, 56.54364), (57.580452, 57.693607), (59.503914, 58.814045), (61.558575, 59.90187), (63.755463, 60.952957), (66.10437, 61.96344), (68.615036, 62.928852), (71.29686, 63.844116), (74.15731, 64.7041), (77.20298, 65.50247), (80.43615, 66.23337), (83.85569, 66.89038), (87.45515, 67.467155), (91.22266, 67.95721), (95.13931, 68.3547), (99.18, 68.65447), (103.31237, 68.85244), (107.500275, 68.945786), (111.703575, 68.93306), (115.881714, 68.81441), (119.995186, 68.59158), (124.00822, 68.26782), (127.89088, 67.847694), (131.61931, 67.3364), (135.17621, 66.73979), (138.55106, 66.064606), (141.73866, 65.31692), (144.73924, 64.50329), (147.55606, 63.62978), (150.19583, 62.702198), (152.66656, 61.72575), (154.97762, 60.705215), (157.13954, 59.645348), (159.16205, 58.54975), (161.05547, 57.422207), (162.82954, 56.265892), (164.49341, 55.083527), (166.05579, 53.87775), (167.52486, 52.650826), (168.90799, 51.404835), (170.2121, 50.14136), (171.44348, 48.8622), (172.60777, 47.56856), (173.71053, 46.261955), (174.75618, 44.943287), (175.74937, 43.6138), (176.69377, 42.274166), (177.59311, 40.92526), (178.45091, 39.56804), (179.2699, 38.202946), (-179.9472, 36.830643), (-179.19763, 35.45172), (-178.47934, 34.066658), (-177.79007, 32.675938), (-177.12813, 31.279902), (-176.49168, 29.879005), (-175.87917, 28.473516), (-175.28883, 27.063877), (-174.71983, 25.650331), (-174.17036, 24.233177), (-173.63972, 22.812666), (-173.1267, 21.388971), (-172.63036, 19.962389), (-172.14955, 18.533195), (-171.6837, 17.101381), (-171.23222, 15.667246), (-170.79407, 14.231025), (-170.36867, 12.792814), (-169.95576, 11.352718), (-169.5542, 9.911045), (-169.16383, 8.467765), (-168.78418, 7.0230436), (-168.41461, 5.5771675), (-168.05511, 4.129959), (-167.70464, 2.6818724), (-167.36348, 1.2327191), (-167.03116, -0.21725322), (-166.70721, -1.6679472), (-166.3915, -3.1192677), (-166.08391, -4.5711927), (-165.78374, -6.023487), (-165.49132, -7.4761825), (-165.20627, -8.929155), (-164.92842, -10.382393), (-164.65752, -11.835696), (-164.39372, -13.289056), (-164.13687, -14.742453), (-163.88661, -16.195707), (-163.64307, -17.64882), (-163.40642, -19.101753), (-163.17642, -20.554422), (-162.953, -22.006695), (-162.73619, -23.458603), (-162.52649, -24.910103), (-162.3232, -26.360989), (-162.12709, -27.811409), (-161.9379, -29.261166), (-161.75607, -30.710295), (-161.58147, -32.158745), (-161.41481, -33.60651), (-161.25578, -35.05337), (-161.10516, -36.499462), (-160.96307, -37.944675), (-160.83008, -39.388977), (-160.70634, -40.832317), (-160.59283, -42.27467), (-160.49, -43.715965), (-160.39873, -45.156227), (-160.31926, -46.59529), (-160.25368, -48.033295), (-160.202, -49.470036), (-160.1664, -50.90555), (-160.14778, -52.33968), (-160.1481, -53.7725), (-160.16957, -55.20383), (-160.21416, -56.63361), (-160.28535, -58.061806), (-160.38583, -59.48826), (-160.52089, -60.91285), (-160.69386, -62.335415), (-160.91165, -63.75571), (-161.18176, -65.17356), (-161.5127, -66.58865), (-161.91605, -68.00061), (-162.40646, -69.4089), (-163.00266, -70.81293), (-163.72867, -72.21183), (-164.61661, -73.60449), (-165.71136, -74.98933), (-167.07208, -76.36417), (-168.7863, -77.72577), (-170.97989, -79.06952), (-173.84282, -80.38809), (-177.6704, -81.66968), (177.07292, -82.89469), (169.64104, -84.02808), (168.74101, -84.13447), (169.47952, -84.18268), (-174.9634, -84.866486), (-145.05681, -84.97181), (-128.51079, -84.4018), (-116.88854, -83.59613), (-110.1891, -82.89573), (-104.68907, -82.13626), (-101.00197, -81.506836), (-97.58405, -80.81718), (-95.05255, -80.229004), (-92.707985, -79.6168), (-92.50668, -79.56094), (-90.482994, -78.96835), (-88.31617, -78.26648), (-86.49006, -77.61542), (-84.42254, -76.80546), (-82.58172, -76.01154), (-80.37894, -74.957245), (-78.30165, -73.83833), (-75.65186, -72.186775), (-72.94698, -70.15045), (-70.97637, -68.35873), (-70.97637, -68.35873), (-74.90061, -67.9932), (-78.68576, -67.53469), (-82.3114, -66.98882), (-85.7638, -66.36156), (-89.03559, -65.65964), (-92.1229, -64.8886), (-95.02791, -64.055), (-97.755196, -63.164646), (-100.31119, -62.222633), (-102.70504, -61.2344), (-104.94605, -60.20434), (-107.043724, -59.136566), (-109.00831, -58.034912), (-110.84923, -56.902607), (-112.57618, -55.74281), (-114.197784, -54.558243), (-115.72203, -53.35097), (-117.157394, -52.123577), (-118.50988, -50.877483), (-119.78652, -49.614567), (-120.993866, -48.336643), (-122.136536, -47.044666), (-123.21971, -45.73994), (-124.24811, -44.423542), (-125.22598, -43.096584), (-126.15675, -41.759663), (-127.04384, -40.413765), (-127.89091, -39.059486), (-128.70059, -37.69767), (-129.47511, -36.328594), (-130.21753, -34.95315), (-130.92935, -33.571423), (-131.61314, -32.184277), (-132.27017, -30.791653), (-132.90282, -29.394314), (-133.5122, -27.992514), (-134.09973, -26.58645), (-134.66656, -25.176401), (-135.21431, -23.762665), (-135.74391, -22.345657), (-136.25604, -20.925377), (-136.75223, -19.50223), (-137.233, -18.07635), (-137.69923, -16.647902), (-138.15158, -15.217007), (-138.59077, -13.78397), (-139.01758, -12.348912), (-139.43248, -10.911923), (-139.83598, -9.473176), (-140.22845, -8.032804), (-140.61098, -6.5910053), (-140.98314, -5.147803), (-141.34596, -3.7033153), (-141.69969, -2.2577176), (-142.04451, -0.8111446), (-142.38077, 0.6364474), (-142.70877, 2.08482), (-143.02888, 3.5339684), (-143.34134, 4.98374), (-143.64613, 6.434145), (-143.94374, 7.8849235), (-144.23438, 9.336228), (-144.5179, 10.787847), (-144.79463, 12.239685), (-145.06479, 13.691687), (-145.32838, 15.143835), (-145.5855, 16.596067), (-145.83609, 18.04829), (-146.08063, 19.500433), (-146.31877, 20.952421), (-146.55034, 22.40436), (-146.7757, 23.855988), (-146.99475, 25.307415), (-147.20738, 26.75843), (-147.4136, 28.209133), (-147.61324, 29.659483), (-147.806, 31.109331), (-147.99207, 32.558628), (-148.1709, 34.007523), (-148.34258, 35.455795), (-148.50659, 36.903416), (-148.66267, 38.35047), (-148.81049, 39.79687), (-148.94948, 41.242542), (-149.07956, 42.68748), (-149.19974, 44.13167), (-149.30939, 45.57509), (-149.4078, 47.0177), (-149.49413, 48.459362), (-149.5674, 49.900196), (-149.62633, 51.34013), (-149.66948, 52.77905), (-149.69524, 54.21696), (-149.7017, 55.653767), (-149.68686, 57.08949), (-149.64781, 58.523964), (-149.58128, 59.957123), (-149.4837, 61.388927), (-149.35025, 62.819195), (-149.17496, 64.24773), (-148.95131, 65.67438), (-148.67021, 67.09897), (-148.32114, 68.52104), (-147.88898, 69.94026), (-147.35602, 71.356026), (-146.69774, 72.7677), (-145.88167, 74.17423), (-144.86232, 75.57426), (-143.57558, 76.96568), (-141.92943, 78.34572), (-139.78325, 79.70983), (-136.92006, 81.05079), (-132.98654, 82.35663), (-127.38667, 83.605804), (-119.102005, 84.75781), (-106.51747, 85.733284), (-87.9803, 86.3862), (-64.91008, 86.52973), (-43.599743, 86.10684), (-28.207735, 85.26702), (-18.042818, 84.188156), (-11.284399, 82.9794), (-6.6260324, 81.69733), (-3.2919695, 80.37099), (-0.8275803, 79.01628), (1.043294, 77.64243), (2.4935496, 76.255135), (3.6346073, 74.8578), (4.543778, 73.45301), (5.274626, 72.04231), (5.864872, 70.62695), (6.344059, 69.20775), (6.7308598, 67.785286), (7.043411, 66.3601), (7.2932906, 64.93254), (7.4908624, 63.502907), (7.643044, 62.071407), (7.7570615, 60.63824), (7.837409, 59.203598), (7.8438516, 59.060005), (8.002876, 59.04922), (11.145475, 58.795647), (15.714073, 58.293922), (18.533953, 57.912148), (21.033106, 57.5352), (22.830679, 57.24614), (24.601126, 56.950253), (25.984163, 56.71313), (27.44097, 56.458817), (28.647604, 56.245102), (29.876347, 56.024834), (29.987253, 56.00482), (31.153336, 55.79319), (32.51221, 55.54368), (33.754414, 55.31277), (35.278393, 55.02529), (36.751106, 54.74197), (38.675583, 54.360546), (40.678333, 53.945015), (43.55667, 53.30203), (46.974476, 52.44617), (49.610016, 51.702038), (49.610016, 51.702038)]], 'crs': {'type': 'name', 'properties': {'name': 'http://www.opengis.net/gml/srs/epsg.xml#4326'}}} ```
zxdawn commented 1 year ago

The problem maybe the splitting of Polygon by the 180 deg line. Actually, I checked this tutorial, but failed ... It seems the poslist order is wrong as mentioned in this StackOverflow question.

gml:posList NC_STRING The Polygon geometry shall be encoded in the EPSG:4326 geographic coordinate reference system (WGS-84) and the coordinate pairs shall be ordered as latitude/longitude. Polygons enclose areas with points listed in counter-clockwise direction.

gadomski commented 1 year ago

This doesn't seem to be a PySTAC issue -- more an issue around creating valid geometries around the antimeridian. In addition to the blog post you mentioned, stactools has some utilities for working with shapes that cross the antimeridian. You could check those out and see if they help you out.

Closing as invalid, as it's not an issue with PySTAC.