pyproj4 / pyproj

Python interface to PROJ (cartographic projections and coordinate transformations library)
https://pyproj4.github.io/pyproj
MIT License
1.06k stars 214 forks source link

pyproj2.2.2 can not match with geopandas0.4.1 or geopandas0.5.1. #421

Closed pengguanjun closed 5 years ago

pengguanjun commented 5 years ago

Installation method/steps

No error, always stuck. Or flashback.

Environment Information

jorisvandenbossche commented 5 years ago

Can you clarify the "the result is wrong" ? What is different between 2.2.0 and 2.2.2 ?

pengguanjun commented 5 years ago

stuck or flashback. 2.2.0 is ok. No bug message.

snowman2 commented 5 years ago

Sorry, still cannot understand what the issue is. Would you mind showing a code example where you run the code and show the expected output? Also, can you show an example with code where you get the incorrect output or error? Showing the input and outputs with a traceback would be very important to help us address the problem.

pengguanjun commented 5 years ago

http://geopandas.org/geocoding.html?highlight=**to_crs** We can attempt to run this link code.

Pyproj2.2.2 can not match with geopandas0.4.1 or geopandas0.5.1.

After have a try, we can not get the result. So do three people .

As following, correct result graph.

pyproj2.2.0 can match with geopandas0.4.1 or geopandas0.5.1.

In [1]: boros = geopandas.read_file(geopandas.datasets.get_path("nybb"))

In [2]: boros.BoroName Out[2]: 0 Staten Island 1 Queens 2 Brooklyn 3 Manhattan 4 Bronx Name: BoroName, dtype: object

In [3]: boro_locations = geopandas.tools.geocode(boros.BoroName)

In [4]: boro_locations Out[4]: geometry address 0 POINT (-74.1502012148768 40.5795366485504) Staten Island, NY, USA 1 POINT (-73.7948512090548 40.7282266729122) Queens, NY, USA 2 POINT (-73.94415121150099 40.6781766647127) Brooklyn, NY, USA 3 POINT (-73.9712412119449 40.7830666818965) Manhattan, New York, NY, USA 4 POINT (-73.8648212102013 40.844786692009) Bronx, NY, USA

In [5]: import matplotlib.pyplot as plt

In [6]: fig, ax = plt.subplots()

In [7]: boros.to_crs({"init": "epsg:4326"}).plot(ax=ax, color="white", edgecolor="black");

In [8]: boro_locations.plot(ax=ax, color="red");

图片

snowman2 commented 5 years ago

@pengguanjun, I am curious if the problem persists in pyproj~=2.3.1

I noticed you are using conda D://anaconda3/, so I would recommend using conda to install the package as 2.3.x is not available via pip for windows due to some issues (#403) that will hopefully be addressed soon.

In the meantime, I would recommend using the conda-forge channel to install pyproj and geopandas:

conda config --add channels conda-forge
conda config --set channel_priority strict 
conda create -n geo geopandas pyproj jupyter descartes geopy matplotlib
conda activate geo
(geo) jupyter notebook

Note: If conda activate geo does not work (which might be the case depending on your version of conda), for windows the old command is activate geo.

snowman2 commented 5 years ago

When I ran the above commands on linux:

(geo)$ conda list geopandas
# packages in environment at ~/miniconda3/envs/geo:
#
# Name                    Version                   Build  Channel
geopandas                 0.5.1                      py_0    conda-forge
(geo) $ conda list proj
# packages in environment at ~/miniconda3/envs/geo:
#
# Name                    Version                   Build  Channel
proj4                     6.1.1                hc80f0dc_1    conda-forge
pyproj                    2.3.1            py37h2fd02e8_0    conda-forge
pengguanjun commented 5 years ago

Thank you. Hot-heart man, good luck to you.

snowman2 commented 5 years ago

Not a problem! Does this mean it worked?

pengguanjun commented 5 years ago

pip intall pyproj-2.3.1 ERROR: Could not find a version that satisfies the requirement pyproj-2.3.1 (from versions: none) ERROR: No matching distribution found for pyproj-2.3.1

I can use pyproj-2.2.0 in Windows. If I need to use pyproj in Linux, I will consider your pyproj version.

snowman2 commented 5 years ago

Did you try this on windows:

conda config --add channels conda-forge
conda config --set channel_priority strict 
conda create -n geo geopandas pyproj jupyter descartes geopy matplotlib
conda activate geo
(geo) jupyter notebook

You won't need to pip install pyproj following those steps. It should work on windows.

pengguanjun commented 5 years ago

New envs need install many packages.I have try many times, it is bad http. I give up conda install. I only have a try for intersesing point.If my work need this, I must have done this. After that , I will reply back again. Thank you , handsome snowman.

snowman2 commented 5 years ago

Closing as pyproj==2.2.0 works and 2.4.0 should also work with windows wheels (ref #412).

yxdragon commented 5 years ago

@snowman2 Hello, about two month ago, you help me to solve a question about "alwayse_xy=True", Thanks verymuch, hot-heart snowman. pengguanjun is my friend, We are building a lib geonumpy. I have a doubt "why the geo lib are so hard to install?", did not support pip, also with canda, sometimes there are mismatch. and gdal, numpy, geopandas must be exactly matched. I had also see mapbox/rasterio, it is writen by cython, but also could not be installed by pip. and mapbox/robosat a ml lib for geoimage segment. I look the document, I think it is very heavy and not pythonic (we can use sklearn or pytorch to directly, and there are also some tools such as ilastik, which is popular in bioimage). In my opinion, geoimage is just image with crs and transform mat, but "these heavy and hard to install" cut gis and others in tow world.

So I have a idea, may be it is too difficult:

  1. projection is the core of geo spacial. could we build a ci enviroment for pyproj, and support pip? (many lib in cython like skimage support pip well)
  2. give up gdal, fiona... it is written by C, and is hard to install, need a exactly numpy version. (we can only support tif and hdf with (tiffile, pyhdf) at first, shapely is core, osr could be replaced by pyproj, sample and reproject bould be done easily with pyproj and scipy+skimage)
  3. geopandas 's core value is treate dataframe with a shapely object. pyproj could do the reprojection, and pyshp, geojson could do the io (why it depend on gdal?). sometimes we did not support all format, but prefer to get a clean and easy style.
  4. only write some light method, such as resample, shape to raster mask(draw), rasters merge(match), raster reprojection. (merge is just multi images reprojection to one background)... but keep all in numpy style. I think all these function could be implemented in10-20 lines. (geonumpy want to act this role)
  5. write some seperate lib, such as hydrology, watershed, ridge with numba (I think numba is better than cython, if we need not mix with a C++ lib), esay to read, and esay to modify, upgrade.
  6. the rest, is not a geo question, but a general question. we need not support every function in detail, but to guide people, this question is not a geo question, and could be esaily solved by numpy and others general libs. even you can label and train your images by label tools and mk framework.

I am new in geo processing. I am good at data processing, and bio image. That is my feeling as a freshman. I want to heard your advice.

snowman2 commented 5 years ago

Lots of questions. I won't attempt to answer them all at the moment. But, after a quick read, the first thing that came to mind is pyresample. I would recommend taking a look at that.

snowman2 commented 5 years ago

Here is an update on thoughts on some of your questions:

  1. projection is the core of geo spacial. could we build a ci enviroment for pyproj, and support pip?

Are you talking about wheels? Currently there are wheels for Python 3.5+ on for Linux, OSX, and Windows on pypi for pyproj 2.4.0. But, if you have other ideas for improvement, I would be happy to hear it.

  1. give up gdal, fiona... it is written by C, and is hard to install, need a exactly numpy version. (we can only support tif and hdf with (tiffile, pyhdf) at first, shapely is core, osr could be replaced by pyproj, sample and reproject bould be done easily with pyproj and scipy+skimage

There is a lot of power with using Fiona and GDAL, however it definitely can be difficult to install at times. If you are on Windows, you could look into Windows wheels posted at https://www.lfd.uci.edu/~gohlke/pythonlibs/. Otherwise, there are wheels for most geospatial libraries for osx and linux.

Another option for you could potentially be something similar to geofeather for reading/writing vector data.

  1. geopandas 's core value is treate dataframe with a shapely object. pyproj could do the reprojection, and pyshp, geojson could do the io (why it depend on gdal?). sometimes we did not support all format, but prefer to get a clean and easy style.

Currently GDAL supports a variety of vector formats for file-io (https://gdal.org/drivers/vector/index.html). It also supports reading from Amazon S3 and probably other providers. There is a lot of power when using this.

But, you are correct that geopandas could take a different approach for file io. One such option would be to allow different read/write drivers file io and it could make Fiona optional. An interesting idea that could potentially reduce some overhead for installation if you don't need all of GDAL for a particular use case. Maybe worthwhile to make an issue on geopandas about it.

jorisvandenbossche commented 5 years ago

Here is a related issue on geopandas about having a shapefile reader based on pyshp / making fiona optional https://github.com/geopandas/geopandas/issues/219