-
Notifications
You must be signed in to change notification settings - Fork 9
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
Would be good to add a to_epsg implimentation #88
Comments
Isn't this already present? Lines 129 to 133 in d88918c
Although it looks like this doesn't use |
I believe this is a very limited version of to_epsg as it can only find an EPSG code if the Authority and code is contained in the CRS. For example it can't infer the EPSG code from a ProjString or wkt that does not include the authority. This is the same limitation as my ArchGDAL PR. |
I think we'll need to use Proj.proj_identify |
Can someone provide an example of how to use Proj.proj_identify, I can't seem to figure out how to assign and retrieve the C objects. |
This seems to work: using Proj
import GeoFormatTypes as GFT
# create a CRS from the proj string that represents EPSG:4326
crs = Proj.CRS("+proj=longlat +datum=WGS84 +no_defs +type=crs")
# attempt to identify the corresponding EPSG code using proj_identify
out_confidence = Ref(Ptr{Cint}(C_NULL))
pj_list = Proj.proj_identify(crs, "EPSG", out_confidence)
# TODO use these to check for error and list length
pj_list == C_NULL
Proj.proj_list_get_count(pj_list)
# get the first resulting CRS
pj_1 = Proj.proj_list_get(pj_list, 0)
crs_1 = Proj.CRS(pj_1)
confidence_1 = unsafe_load(out_confidence[])
# use i in unsafe_load(p::Ptr{T}, i::Integer=1) for other indices
# doesn't work: https://github.com/JuliaGeo/Proj.jl/issues/88#issuecomment-1645894753
GFT.EPSG(crs)
# does work:
GFT.EPSG(crs_1) == GFT.EPSG(4326)
|
Should we introduce this into proj as |
Yeah perhaps we can create a Then for I just noticed my use of |
In the example above how should |
Hmm yeah I'm also not great with this stuff, but managed to figure it out, see the updated example. So you need a reference to a pointer of the right type. We can initialize this with a null pointer, PROJ will point it to an array that it allocates itself. After calling the function we can see that |
I'll work on a PR |
@visr for the higher level |
@visr I think this is good to merge. If you agree I will work on to_EPSG next |
Left some comments on #92. For |
robustly retrieving the epsg from a crs requires an implementation of pyproj's to_epsg
The text was updated successfully, but these errors were encountered: