question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ERROR 1: Point outside of projection domain

See original GitHub issue

Description

I’m running also into ERROR 1: Point outside of projection domain when using creating a RasterDataset. The error occurs during a call torasterio.vrt.WarpedVRT.

Bit of context: I’m warping a collection of S2 tif files. For many I’m able to warp them without exception, but for some this exception occurs. See snippets in steps to reproduce to reproduce.

Unfortunately I’m not very familar with GDAL debugging. I hope the traceback below is sufficient to indicate where the issue might be coming from. I think it’s related to rasterio._err.CPLE_AppDefinedError: Point outside of projection domain which points to /miniconda3/envs/torchgeo/lib/python3.10/site-packages/rasterio/_err.cpython-310-darwin.so on my machine?. While debugging I came accross this issue which might be related.

Tracking the warning I found that the message is raised in rasterio._warp which points on my machine I think to /Users/calkoen/miniconda3/envs/torchgeo/lib/python3.10/site-packages/rasterio/_warp.cpython-310-darwin.so:

The warning is raised here:

self._log(INFO, msg, args)  # where self is rasterio._warp
print(self)  # <Logger rasterio._warp (WARNING)> 
print(INFO)  # 20
print(msg) # Ignoring error: err=%r
print(args)  # (CPLE_AppDefinedError(3, 1, 'Point outside of projection domain'),)

The exception can be triggered by another exception:

Traceback (most recent call last):
  File "rasterio/_warp.pyx", line 768, in rasterio._warp.auto_create_warped_vrt
  File "rasterio/_err.pyx", line 178, in rasterio._err.exc_wrap
rasterio._err.CPLE_AppDefinedError: Point outside of projection domain

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
NameError: name '_log' is not defined

Steps to reproduce

To download the data:

mkdir -p $HOME/tmp/coasttypes
cd $HOME/tmp/coasttypes
wget -O BOX_028_044_110_T18FWG_20200207T141731_B02_10m.tif https://s3.eu-central-1.amazonaws.com/floris.calkoen.open.data/coasttypes/BOX_028_044_110_T18FWG_20200207T141731_B02_10m.tif
wget -O BOX_029_371_99_T20FPH_20221002T135641_B02_10m.tif https://s3.eu-central-1.amazonaws.com/floris.calkoen.open.data/coasttypes/BOX_029_371_99_T20FPH_20221002T135641_B02_10m.tif
wget -O BOX_166_003_31_T34SEG_20220816T091559_B02_10m.tif https://s3.eu-central-1.amazonaws.com/floris.calkoen.open.data/coasttypes/BOX_166_003_31_T34SEG_20220816T091559_B02_10m.tif

To reproduce and visualize the plot using Python

import pathlib

import matplotlib.pyplot as plt
import rasterio  # rasterio.__version__=='1.3.3'
import rioxarray
import xarray as xr
from torchgeo.datasets import RasterDataset  # torchgeo.__version__=='0.4.0.dev0'

data_dir = pathlib.Path.home().joinpath("tmp", "coasttypes")


class Sentinel2(RasterDataset):
    filename_glob = "BOX_*_T*_B02_10m.tif"
    filename_regex = r"^(?P<transect>BOX_\d{3}_\d{3}_\d{1,3})_.{6}_(?P<date>\d{8}T\d{6})_(?P<band>B0[\d])"
    date_format = "%Y%m%dT%H%M%S"
    is_image = True
    separate_files = True
    all_bands = ["B02", "B03", "B04", "B08"]
    rgb_bands = ["B04", "B03", "B02"]


# when only file is present in the directory the warning doesn't happen.
Sentinel2(str(data_dir))

for fp in data_dir.iterdir():
    xr.open_dataset(
        fp,
        engine="rasterio",
    )["band_data"].squeeze().plot()
    plt.show()

Version

0.4.0.dev0

Issue Analytics

  • State:closed
  • Created 10 months ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
FlorisCalkoencommented, Nov 9, 2022

Following up on the RuntimeError above. This is caused by setting crs=CRS.from_epsg(4326) because the sampler requires the property RandomGeoSampler.areas, which cannot be calculated for a coordinate system (EPSG:4326), but can be calculated for a projection (EPSG:3857). So crs=CRS.from_epsg(3857) fixes it.

0reactions
calebrob6commented, Dec 6, 2022

Thanks for following up @FlorisCalkoen. I’m going to close this, but feel free to reach out if anything else comes up!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Mapproject ERROR 1: Point outside of projection domain - Q&A
I use mapproject to calculate coordinates for lower left and upper right corner for plotting a rectangular map similar to gmt Example 28 ......
Read more >
"Point outside of projection domain" / "tolerance condition ...
My initial analysis: The root cause here is that with this Geostationary Satellite projection the coordinates of the 4 corners of the image...
Read more >
Soilgrids points outside of projection domain
There is definetly something wrong with the CRS declared for the second SpatRaster instance. That is the most likely cause for the error ......
Read more >
#4381 (gdalwarp on MSG-SEVIRI fails) – GDAL - OSGeo Trac
ERROR 1 : Too many points (440 out of 441) failed to transform, unable to compute output bounds. The GEOS projection was fairly...
Read more >
Common errors that may occur during editing—Help
Coordinates or measures are out of bounds ... This error occurs when a coordinate of a feature is beyond the extent of the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found