-
Notifications
You must be signed in to change notification settings - Fork 807
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Better documentation for the use of proj_trans_get_last_used_operation()
#4391
Comments
That's quite the opposite. We wouldn't just test which operation to use just for the sake of slowing down users :-) For a given source_crs, target_crs tuples there are different alternatives to consider sometimes, each with its own area of use, hence to get the most accurate transformation one has to test if the point to transform fits into the area of use. If you were transforming between NAD83 (geographic) and WGS84 and there are indeed one transformation per US state as candidates to test, hence the 53. |
Okay, thanks for the explanation. So the takeaway is that I think it would be very helpful to have a prominent statement/warning on the migration page about how the v 5/6 |
I wouldn't recommend that unless you are certain all your points fit in the area of use of that transformation. Otherwise that could fail.
pj_transform has been removed for long (PROJ 7 I believe) A better option for people seeking maximum performance is that people use projinfo and fetch a pipeline they find reasonable for their use case and provide it directly to proj_create(). |
Okay, my point remains that many might be surprised by the inefficiency of |
@michaeladamkatz it is not that this method is slower. The whole library was refactored some years ago to produce more accurate results, and honour transformations in epsg. That was a big change. |
@jjimenezshaw, I appreciate that. I don't claim to know what the most common use cases are for the proj library, but my thought has been that Maybe I missed it, but it would be very helpful to have a prominent section of the documentation called "Efficiency Concerns" covering the main ways people may not realize they can get much faster code with a minimal sacrifice. If that covers topics beyond |
I'm using proj 9.5.1.
When reading https://proj.org/en/stable/development/migration.html, I don't think it's made clear enough how important it is to understand and use
proj_trans_get_last_used_operation()
.I have a geotiff file. I open it as a
GDALDataset
withGDALOpen()
, callGDALGetProjectionRef()
to get its SRS (which is below), and create a projection for it withGetProjectionFromWKT()
.When I use this projection with
proj_trans()
, my code is orders of magnitude slower than what it was with withpj_transform()
in proj 4.I stepped into the
proj_trans()
code, and what I see is that huge amounts of time are spent evaluating which of theP->alternativeCoordinateOperations
gives the best result. In my case there are 54alternativeCoordinateOperations
(I don't know how the set is determined and populated).What I see is that
proj_trans()
does this comparison/evaluation for every coordinate. I may be missing something, but from what I can see, the choice of which operation to use is not dependent on the coordinate, so I don't understand why it's doing that comparison/evaluation more than once. I see it does store the best-found index in the PJ structure, but from what I can see it doesn't use that cached value. So a question is why's it doing that?It seems like the purpose of the
proj_trans_get_last_used_operation()
function is to circumvent the evaluation by directly using the previously selected operation (which further adds to the mystery of why it does the evaluation each time, since now you can bypass that evaluation for the remaining points). Thus I have code like this:If that's the idea of how to use
proj_trans_get_last_used_operation()
, I think an example like that should be shown prominently in the migration guide. I note that the pyproj introduces a Transformer concept, which I believe is a wrapping around this pattern.It probably doesn't matter for the purpose of this post but here is the SRS/WKT of my file:
PROJCS["NAD83 / Rhode Island (ftUS)",GEOGCS["NAD83",DATUM["North_American_Datum_1983",SPHEROID["GRS 1980",6378137,298.257222101004,AUTHORITY["EPSG","7019"]],AUTHORITY["EPSG","6269"]],PRIMEM["Greenwich",0],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4269"]],PROJECTION["Transverse_Mercator"],PARAMETER["latitude_of_origin",41.0833333333333],PARAMETER["central_meridian",-71.5],PARAMETER["scale_factor",0.99999375],PARAMETER["false_easting",328083.3333],PARAMETER["false_northing",0],UNIT["US survey foot",0.304800609601219,AUTHORITY["EPSG","9003"]],AXIS["Easting",EAST],AXIS["Northing",NORTH],AUTHORITY["EPSG","3438"]]
The text was updated successfully, but these errors were encountered: