Skip to content
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

Bracket access to projection paramters #30

Open
karimbahgat opened this issue Nov 23, 2018 · 1 comment
Open

Bracket access to projection paramters #30

karimbahgat opened this issue Nov 23, 2018 · 1 comment

Comments

@karimbahgat
Copy link
Owner

@djhoese wrote:

One feature that was brought up on that xarray/geoxarray issue was wanting to be able to take a CRS-like object and use the getitem method to use bracket access to projection parameters like my_crs['lon_0'] or something like that. Not sure if proj.4 parameter naming is the best thing, but yeah it was brought up and I think it could be a good idea. Not sure how to accomplish this with the current interfaces though given how everything is split up in to its own class.

So the requested feature here is perhaps about an easy way to access parameters. Right now how you would do it is by recursively accessing the correct nested sub-elements. E.g. metermultiplier = crs.toplevel.unit.unitmultiplier.value. In a way this would be the correct way to do it, as things would be logically grouped.

I could see the usefulness of also providing more convenient access in a way that kind of "searches" for the parameters for you based on the name, without the user needing to know about their nested structure. As you say, using the proj4 names may not be ideal here, but then again, all naming conventions come from one or another format spec, so it really just depends what you're used to I guess.

One way might be to implement a "get" and "set" method, where you could also supply which format you are using for your search and for the supplied and return values. That way, users more familiar with proj4 could use that, or those familiar with OGC WKT could use that, etc.

@karimbahgat
Copy link
Owner Author

karimbahgat commented Nov 23, 2018

For now, one way around this, for those used to proj4: I have now added an as_dict arg which can be used to get proj4 as a dict. Something like this:

proj4dict = crs.to_proj4(as_dict=True)
proj4dict['lon_0']

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant