[BUG]: "epsg:4326" not parsed correctly as a CRS
See original GitHub issueThank you for helping us improve solaris
!
Summary of the bug
I cannot get a polygon created with ‘sol.vector.polygon.georegister_px_df’ to write out to a geojson formatted file.
Steps to reproduce the bug
I am running a notebook that identifies vineyards, based on another called “How to Segment Buildings on Drone Imagery with Fast.ai & Cloud-Native GeoData Tools”
I believe the issue is very closely related to this question on GSE.
The polygon is created as expected:
But, when I go to write out with result_polys.to_file (‘result_polys.geojson’) I get a CRS failure.
I think this is very similar to the issues raised in #317
# convert polys from pixel coords to geo coords: https://solaris.readthedocs.io/en/latest/api/vector.html?highlight=georegister_px_df#solaris.vector.polygon.georegister_px_df
result_polys = sol.vector.polygon.georegister_px_df(mask2poly,
affine_obj=tile_tfm,
crs=4326
)
---
# show tile image to raw prediction to georegistered polygons
fig, (ax1, ax2, ax3) = plt.subplots(1,3, figsize=(15,5))
ax1.imshow(test_tile)
ax2.imshow(result)
result_polys.plot(ax=ax3)
[produces the correct plot above]
---
result_polys.to_file ('result_polys.geojson', driver='GeoJSON')
[fails]
Buggy behavior and/or error message
Please describe the buggy behavior and/or paste output here.
---------------------------------------------------------------------------
CRSError Traceback (most recent call last)
<ipython-input-18-94b01e24e989> in <module>
----> 1 result_polys.to_file ('result_polys.geojson')
/opt/anaconda3/lib/python3.7/site-packages/geopandas/geodataframe.py in to_file(self, filename, driver, schema, **kwargs)
513 from geopandas.io.file import to_file
514
--> 515 to_file(self, filename, driver, schema, **kwargs)
516
517 def to_crs(self, crs=None, epsg=None, inplace=False):
/opt/anaconda3/lib/python3.7/site-packages/geopandas/io/file.py in to_file(df, filename, driver, schema, **kwargs)
126 with fiona_env():
127 with fiona.open(
--> 128 filename, "w", driver=driver, crs=df.crs, schema=schema, **kwargs
129 ) as colxn:
130 colxn.writerecords(df.iterfeatures())
/opt/anaconda3/lib/python3.7/site-packages/fiona/env.py in wrapper(*args, **kwargs)
396 def wrapper(*args, **kwargs):
397 if local._env:
--> 398 return f(*args, **kwargs)
399 else:
400 if isinstance(args[0], str):
/opt/anaconda3/lib/python3.7/site-packages/fiona/__init__.py in open(fp, mode, driver, schema, crs, encoding, layer, vfs, enabled_drivers, crs_wkt, **kwargs)
262 c = Collection(path, mode, crs=crs, driver=driver, schema=this_schema,
263 encoding=encoding, layer=layer, enabled_drivers=enabled_drivers, crs_wkt=crs_wkt,
--> 264 **kwargs)
265 else:
266 raise ValueError(
/opt/anaconda3/lib/python3.7/site-packages/fiona/collection.py in __init__(self, path, mode, driver, schema, crs, encoding, layer, vsi, archive, enabled_drivers, crs_wkt, ignore_fields, ignore_geometry, **kwargs)
143 self._check_schema_driver_support()
144 if crs_wkt or crs:
--> 145 self._crs_wkt = crs_to_wkt(crs_wkt or crs)
146
147 self._driver = driver
fiona/_crs.pyx in fiona._crs.crs_to_wkt()
CRSError: Invalid input to create CRS: epsg:4326
Expected behavior
Expected to write out ‘result_polys.geojson’
Screenshots
If applicable, add screenshots to help explain your problem.
Environment information
-
OS: ====================================== Welcome to the Google Deep Learning VM ====================================== Version: pytorch-gpu.1-3.m40 Based on: Debian GNU/Linux 9.11 (stretch) (GNU/Linux 4.9.0-11-amd64 x86_64\n)
-
solaris
version: 0.2.1 -
python version: 3.7.4
-
version of any relevant dependencies (optional - we may ask for this information later if not provided) pyproj 2.4.1 fiona 1.8.13 geopandas 0.6.2
Additional context
Hoping this is a simple fix that I’ve overlooked reading through the previous questions and responses. Thank you for a really impressive project.
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (3 by maintainers)
Top GitHub Comments
Also, that export restriction issue is… incredible.
NIck,
Thank you for taking the time to look into this. I was just logging into gcloud console to try and remember what fixed the issue. I think it may have been going up to pyproj 2.4.2 and using this syntax:
result_polys = sol.vector.polygon.georegister_px_df(mask2poly, affine_obj=tile_tfm, crs=4326
<poof!> and the issue was gone.
My library versions now match yours.: solaris: 0.2.1 geopandas: 0.6.3 fiona: 1.8.13 pyproj: 2.4.2