-
Notifications
You must be signed in to change notification settings - Fork 214
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
Any way to init a projection directly from PROJCS strings? #58
Comments
OK, I actually solved my original problem. I didn't realize import pyproj
x, y = (984533, 213998)
projstr = """+proj=lcc +lat_1=40.66666666666666 +lat_2=41.03333333333333 +lat_0=40.16666666666666 +lon_0=-74
+x_0=300000 +y_0=0 +ellps=GRS80 +datum=NAD83
+to_meter=0.3048006096012192 +units=us-ft +no_defs"""
myproj = pyproj.Proj(projstr, preserve_units=True)
myproj(x, y, inverse=True)
# (-73.99897854592253, 40.75405155302713)
badproj = pyproj.Proj(projstr)
badproj(x, y, inverse=True)
# (-65.75200831429146, 41.80318458470038) I imagine that it's not possible to make This was alluded to in this issue: #40 |
You aren't the only one that was tripped up by that flag. I don't really like the default behavior of the The current code defaults to adding a In [7]: from pyproj import Proj
In [8]: p = Proj(init='epsg:4326')
In [9]: p.srs
Out[9]: '+units=m +init=epsg:4326 '
In [10]: p.is_latlong()
Out[10]: True EPSG:4326 is aka WGS84, which is usually units decimal degrees--I think pyproj has some radian conversions that it uses. It seems that PROJ.4 ignores I assume a pull request would be welcome that better documents the |
I think the function documentation works for what it is, I mean in terms of following a standard docstring. What the problem for me -- and I imagine most new users -- is that Googling around for examples of pyproj yields straightforward examples that don't mention I was thinking of having something on either the README.md or a separate documentation page full of examples. I'd be happy to write a few...maybe throw it in the Wiki, which can then be later converted to a proper documentation page? Just pointing out that while |
Still having three different measurements for feet is great, which is clearly a distinct advantage for feet over meters. 🙈 Feet only has one name and meters can also be spelled, metres, which my browser correctly flags as the incorrect spelling 🙉 . End of sarcasm. How about this. To view, either download the HTML or download the ipynb. For the ipynb, you'll need ipython (with notebooks) and folium installed to see it. Hopefully with the HTML, I don't need to upload anything other files. Also, the x/y order versus lat/long tends to confuse some people. |
@micahcochran Could we do a 2.0 release that breaks the API and changes |
I'm hesitant about doing that. The Proj.init appends a pyproj goes back to atleast 2006, which it added support for Python 2.5 and supported earlier Python version! Sure, the library has a few design decisions that might not be considered Pythonic by today's standards. It'd be nice if the My hesitance is that it could cause some old code to break. How would you notify the user that In summary, I'm hesitant to make that kind of change. |
I'm a little more experienced with GIS now, at least from when I first filed this report :) To give you some context, I was trying to do geospatial analysis of the NYPD Stop and Frisk data found here: http://www.nyc.gov/html/nypd/html/analysis_and_planning/stop_question_and_frisk_report.shtml Here's an example of what such analysis used for, journalistically: http://johnkeefe.net/nypd-stop-frisk-data-for-you The NYPD, and all other NYC agencies, use the New York-Long Island State Plane Coordinate System. I'm not a ArcGIS or QGIS user, so I don't know what the typical convention is to find that info, but as a casual GISer, I just google it and eventually find my way to spatialreference.org: http://www.spatialreference.org/ref/esri/102718/ The "Proj4" link produces this text string, which is what I referenced in my original issue report:
So it wasn't a string that I was hand-encoding, but what I had thought the normal convention for GIS to be: give a string to the projection formula to declare how I want coordinates to be translated. If I instead invoke F = pyproj.Proj(init="ESRI:102718")
T = pyproj.Proj(init="ESRI:102718", preserve_units=True)
x = 1056308
y = 182711
>>> F(x, y, inverse=True)
(-64.93197150112687, 41.459120016286946)
>>> T(x, y, inverse=True)
(-73.74025103331826, 40.66788294565469) I don't know enough about the rest of the GIS scene to know how other projections work, but I can say that for many American encoding systems, feet seems to be the standard, and it's not really about what's best scientific practice...I think we can all agree that the metric system is the way to go :) I think it's fine for pyproj to have the opinion that projections should be using meters as units, as a default. But my quibble is that even when the user does the explicit, painful thing, which is to declare the That said, it's an open question whether it is worth a breaking change to fix the default Maybe one mitigation strategy could be to have |
Hello, I would be interested in the answer of your original question. How can you extract the projection from a WKT string such as: And have it in a pyproj object like pyproj.Proj(wkt_string) I can't find how to do this anywhere and it looks like it should be simple. Thx For broader context: I want to export the projection from a shapefile (or .prj file) in a python object to use pyproj.transform with it. |
@vsasseville GDAL/OGR Python's SpatialReference functions can convert between WKT and PROJ.4 strings (and a few more), but you have to have GDAL installed and that instance of Python has to be able to get to it. |
Didn't know about PyCRS, thanks a lot! |
WKT projection strings will be supported in the pyproj 2.0.0 release. See: #152 |
Master has been updated to 2.0.0, which requires proj4 6.0.0, and changes the default value of |
2.1.0 is released and should resolve this issue. Thanks for the report! |
I know this isn't StackOverflow but just wanted to make sure I wasn't missing something obvious that I didn't see while reading through the source.
I have a PROJCS string that looks like this:
I've seen other projection libraries (such as proj4 for node) handle this, and so I was wondering if
pyproj.Proj()
could as well? Trying to construct it from that raw string gives me this error:Sorry for the support question. I don't know much about GIS systems...
pyproj.Proj()
has worked just fine for me doing this:and:
And so reading from
PROJCS
type strings (or is it referred to as WKT format?) seems like one more translation. But I don't know much about GIS beyond knowing that I'm trying to convert between two systems, so I apologize if I'm asking about something ridiculously apples-to-oranges.The text was updated successfully, but these errors were encountered: