How can I get Landsat 8 data at southern Latitudes? #35
-
I am trying to use Here is the simplified code I am using to produce this problem. Any help would be greatly appreciated! import stackstac
import pystac_client
import pyproj
import planetary_computer as pc
# Positive lat values work
# Negative lat values fail
lat = -5
lon = 20
catalog = pystac_client.Client.open('https://planetarycomputer.microsoft.com/api/stac/v1')
search = catalog.search(
collections=['landsat-8-c2-l2'],
intersects=dict(type="Point", coordinates=[lon, lat]),
datetime="2020-01-01/2020-05-01",
query={"eo:cloud_cover": {"lt": 10}}
)
items = pc.sign(search)
stack = stackstac.stack(items, assets=["SR_B4", "SR_B3", "SR_B2"])
x_utm, y_utm = pyproj.Proj(stack.crs)(lon, lat)
# I added this based on the link above. This helps subset the image correctly
# but I am still getting all NA values
if lat < 0:
y_utm = y_utm - 10000000
else:
pass
buffer = 2000 # meters
aoi = stack.loc[..., y_utm+buffer:y_utm-buffer, x_utm-buffer:x_utm+buffer]
data = aoi.compute() I also get a warning after the above chunk
data.plot.imshow(row="time", rgb="band", robust=True, size=6) |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 5 replies
-
Hmmm, |
Beta Was this translation helpful? Give feedback.
-
Hi @cullen-molitor @TomAugspurger, try using the # Read a shapefile thar covers the city of Brasilia
shp_file <- system.file("extdata/shapefiles/df_bsb/df_bsb.shp",
package = "sits")
sf_bsb <- sf::read_sf(shp_file)
# select the cube
s2_L8_cube_MSPC <- sits_cube(
source = "MSPC",
collection = "LANDSAT-C2-L2",
roi = sf_bsb,
platform = "LANDSAT-8",
start_date = "2019-06-01",
end_date = "2019-10-01",
bands = c("BLUE", "NIR08", "SWIR16", "CLOUD")
)
|
Beta Was this translation helpful? Give feedback.
Hmmm,
stack.crs
is epsg:32734 while the data crs (e.g. crs returned by rasterio if you open one of the tiffs) is epsg:32634. If you usex_utm, y_utm = pyproj.Proj("epsg:32634")(lon, lat)
thenstack.loc
behaves as expected (without the need to subtract 10000000).