-
Notifications
You must be signed in to change notification settings - Fork 0
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
Errors related to using pygeos #10
Comments
I created a new conda virtual environment (with python=3.9) and only installed the following packages from github:
Then I got the staging error Robyn recorded above, so I ran Restarted kernel, cleared all outputs in notebook, and got the same error during staging. Closed remote connection to datateam server, quit VS code, and reopened connection and got the same error during staging. Used |
… fix error documented in issue #10 that may be related to pygeos
Update:After meeting with Robyn to discuss potential sources of error for the staging step, she identified the latest version of geopandas (0.12) which is imported with the pdgstaging as the source of the error. One of their bug fixes for this version is: Combining GeoSeries/GeoDataFrames with While the CRS's of both GeoDataFrames that we combine are the same, perhaps the CRS metadata or something else minor about the CRS is different, because they are flagged by geopandas 0.12 as being inconsistent. Uninstalling pygeos, then also uninstalling geopandas 0.12 and installing version 0.11.1 fixes the CRS error reported above! The files are staged successfully in parallel. But a different staging error occurs with the same approach with Ingmar's data sample: Both data samples are geopackages. This is something to investigate moving forward. |
Reproducing staging error versus reproducing successful staging with different data inputsRobyn found a way to fix to the CRS mismatch error mentioned in the first comment of this issue. See her solution (also linked in first comment) includes changing the TMS to However, I was able to run the staging step on a very small data subset (2 files that overlap spatially, provided by Robyn) without changing the TMS. Additionally, I reproduced the unique error reported above (
The config and list of installed packages for these workflows is included within these notebooks just below the import chunk, as well as the following:
|
@julietcohen Although you also found an IndexError, it looks like this one is being caused by something other than the pygeos library. I was able to reproduce the error thanks for your very helpful notebook! Since it occurred whether or not |
@robyngit Thank you for making a new issue for this. I've been troubleshooting with no resolution so far, but I'll document what I've tried in that new issue. Based on your suggestion, I created a new environment to install my locally cloned repo |
Rasterization
|
Update on the 3D Tiles error reproducing the error:
pip install git+https://github.com/PermafrostDiscoveryGateway/py3dtiles geopandas==0.12.1 pygeos==0.13 shapely==1.8.5.post1
# test.py
from shapely.geometry import box, Polygon, MultiPolygon
from py3dtiles import TriangleSoup
import geopandas as gpd
# print(gpd.show_versions())
polygon = box(0, 0, 1, 1)
g = gpd.GeoDataFrame(geometry = [polygon], crs=4326)
g['geometry'] = g['geometry'].apply(lambda p: Polygon([(x, y, 10) for x, y in p.exterior.coords]))
g = g.to_crs(epsg=4978)
print(g) # <- ⛔️ POLYGON Z without pygeos; POLYGON with pygeos
polygon=Polygon(g["geometry"][0])
multipolygon = MultiPolygon([polygon])
multipolygon_wkb = multipolygon.wkb
ts = TriangleSoup.from_wkb_multipolygon(multipolygon_wkb)
print('🎉 SUCCESS!')
pip uninstall pygeos
python test.py
Notes
|
From the docs:
The issue geopandas/geopandas#1345 confirms that this problem persists with Shapely >= 2.0, but it seems the developers are working on a fix: geopandas/geopandas#2641 |
Remove requirement for pygeos Relates to PermafrostDiscoveryGateway/viz-workflow#10
Remove requirement for pygeos Relates to PermafrostDiscoveryGateway/viz-workflow#10
For viz_3dtiles, found a work around that transforms the geometries themselves using shapely, rather than converting the CRS with geopandas, where we are somehow losing the z-coordinate. I've tested this method with a small sample and everything looks good. In the other PDG packages, I removed the requirement for pygeos, and upgraded version requirements to geopandas >= 0.12 and shapely shapely >= 2.0b2. Changes in all packages are in branches named Left TODO:
|
Updates to viz_3dtiles and Shapely 2+ & GeoPandas 0.12+ requirements are merged into the main branches now. The official shapely 2.0 release is expected to come in 1-2 weeks, so the timing is good to have our packages ready for those changes. |
- Revert some changes from commit eb92102, which was a workaround for the fix released in geopandas 0.12.2 - Change requirements to officialy shapely 2 release, and geopandas 0.12.2 Relates to PermafrostDiscoveryGateway/viz-workflow#10
- For compatibility with PermafrostDiscoveryGateway/viz-3dtiles#23 - Relates to PermafrostDiscoveryGateway/viz-workflow#10
Although this issue is closed, I wanted to note that geopandas just released a fix for the workaround I described above, and shapely officially released version 2. There are PRs in all three viz-* packages to reflect these changes, including reverting the workaround to make use of the geopandas fix. |
Those 3 PRs have now been merged. Nice job keeping up with geopandas and shapely. |
Pygeos was added as a requirement to help resolve #3. However, it appears that when GeoPandas uses pygeos under-the-hood, it causes all sorts of unexpected behaviour in other parts of the workflow that were not initially detected!
During rasterization, I'm getting the error:
GEOSException: IllegalArgumentException: Argument must be Polygonal or LinearRing
. This originates from the overlay operation (when we "slice" the GDF with the grid lines). (I checked, and all inputs havegeom_type
Polygon
)During 3D tile creation, we are seeing the error:
IndexError: index 2 is out of bounds for axis 0 with size 2
from py3dtiles. This may be because the output fromMultiPolygon([polygon]).wkb
is different when we are using pygeos than when we are not. This output is passed toTriangleSoup.from_wkb_multipolygon
, where the error is originating.Both of the above errors are resolved by uninstalling pygeos.
Additionally, I'm seeing a new error during staging that I did not see before changes made in #3, but I'm not sure yet if it's related to pygeos, or perhaps the newer version of Shapely that we're now using. Kastan was able to get through staging without these errors, so it might be unrelated.During staging, I'm getting an error concatenating two GDFs (withpd.concat
, happens when we merge new polygons into an existing tile). The error implies that the two GDFs differ in CRS, but this is not the case:Cannot determine common CRS for concatenation inputs, got ['WGS 84 (CRS84)', 'WGS 84 (CRS84)']. Use to_crs() to transform geometries to the same CRS before merging.
(See PermafrostDiscoveryGateway/viz-staging#11 for the "Cannot determine common CRS for concatenation inputs" error during staging, which is not related to pygeos)
The text was updated successfully, but these errors were encountered: