pytroll / pyresample

Geospatial image resampling in Python
http://pyresample.readthedocs.org
GNU Lesser General Public License v3.0
344 stars 95 forks source link

How should this warning be addressed? #547

Closed yhyxzx closed 10 months ago

yhyxzx commented 10 months ago

Code Sample, a minimal, complete, and verifiable piece of code


projection = '+proj=utm +zone=33 +ellps=WGS84 +datum=WGS84 +units=m +no_defs'
area_def_therm = get_area_def(area_id, description, proj_id, projection, patch_size_m / 1000, patch_size_m / 1000, \
                                      area_extent)

Problem description

D:\anaconda3\envs\NewsstsrPredata\lib\site-packages\pyproj\crs\crs.py:1293: UserWarning: You will likely lose important projection information when converting to a PROJ string from another format. See: https://proj.org/faq.html#what-is-the-best-format-for-describing-coordinate-reference-systems proj = self._crs.to_proj4(version=version)

djhoese commented 10 months ago

Short answer: Don't use get_area_def, just create an AreaDefinition yourself with:

from pyresample.geometry import AreaDefinition
area_def_therm = AreaDefinition(...)

Long answer:

The get_area_def function is there for historical reasons. It uses a conversion from a PROJ.4 string to a PROJ.4 dictionary of parameters which results in the warning you're seeing. That conversion is no longer needed as pyresample's AreaDefinition now depends on pyproj's CRS object which can take many common ways of describing a projection and have it "just work" and with no warning. I'm 99% sure I can remove that conversion from that function and no user would notice a problem.

Second long answer: You could also use the create_area_def (create_ versus get_) which allows for different variations of parameters and will "do the math" for you to create the area you're trying to describe. For example, you have the size of the pixels for the area you want to make and the number of pixels in that area, but you don't want to calculate the extents. create_area_def will accept the information you have and compute any values it needs from that information.

I will plan on making a PR to remove that conversion in get_area_def, but as I said creating your AreaDefinition directly should work just as well (better in fact).

yhyxzx commented 10 months ago

Thank you for your patient response!