segment-geospatial
segment-geospatial copied to clipboard
Error creating Transformer from CRS.
I only run the code from the link: https://samgeo.gishub.org/examples/satellite/ and this code cell did not work:
style = {
"color": "#3388ff",
"weight": 2,
"fillColor": "#7c4185",
"fillOpacity": 0.5,
}
m.add_vector(vector, layer_name="LAL") #, style=style)
m
Do you know why it happened? Thanks.
The above code raised the errors below:
ProjError Traceback (most recent call last)
Cell In[18], line 7
1 style = {
2 "color": "#3388ff",
3 "weight": 2,
4 "fillColor": "#7c4185",
5 "fillOpacity": 0.5,
6 }
----> 7 m.add_vector(vector, layer_name="LAL") #, style=style)
8 m
File [~/miniconda3/envs/geemap/lib/python3.10/site-packages/leafmap/leafmap.py:2622](https://vscode-remote+wsl-002bubuntudev.vscode-resource.vscode-cdn.net/mnt/d/Scripts/sam/code/~/miniconda3/envs/geemap/lib/python3.10/site-packages/leafmap/leafmap.py:2622), in Map.add_vector(self, filename, layer_name, bbox, mask, rows, style, hover_style, style_callback, fill_colors, info_mode, encoding, **kwargs)
2611 self.add_geojson(
2612 filename,
2613 layer_name,
(...)
2619 encoding,
2620 )
2621 else:
-> 2622 geojson = vector_to_geojson(
2623 filename,
2624 bbox=bbox,
2625 mask=mask,
2626 rows=rows,
2627 epsg="4326",
2628 **kwargs,
2629 )
2631 self.add_geojson(
2632 geojson,
2633 layer_name,
(...)
2639 encoding,
2640 )
File [~/miniconda3/envs/geemap/lib/python3.10/site-packages/leafmap/common.py:1555](https://vscode-remote+wsl-002bubuntudev.vscode-resource.vscode-cdn.net/mnt/d/Scripts/sam/code/~/miniconda3/envs/geemap/lib/python3.10/site-packages/leafmap/common.py:1555), in vector_to_geojson(filename, out_geojson, bbox, mask, rows, epsg, encoding, **kwargs)
1551 else:
1552 df = gpd.read_file(
1553 filename, bbox=bbox, mask=mask, rows=rows, encoding=encoding, **kwargs
1554 )
-> 1555 gdf = df.to_crs(epsg=epsg)
1557 if out_geojson is not None:
1558 if not out_geojson.lower().endswith(".geojson"):
File [~/miniconda3/envs/geemap/lib/python3.10/site-packages/geopandas/geodataframe.py:1364](https://vscode-remote+wsl-002bubuntudev.vscode-resource.vscode-cdn.net/mnt/d/Scripts/sam/code/~/miniconda3/envs/geemap/lib/python3.10/site-packages/geopandas/geodataframe.py:1364), in GeoDataFrame.to_crs(self, crs, epsg, inplace)
1362 else:
1363 df = self.copy()
-> 1364 geom = df.geometry.to_crs(crs=crs, epsg=epsg)
1365 df.geometry = geom
1366 if not inplace:
File [~/miniconda3/envs/geemap/lib/python3.10/site-packages/geopandas/geoseries.py:1124](https://vscode-remote+wsl-002bubuntudev.vscode-resource.vscode-cdn.net/mnt/d/Scripts/sam/code/~/miniconda3/envs/geemap/lib/python3.10/site-packages/geopandas/geoseries.py:1124), in GeoSeries.to_crs(self, crs, epsg)
1047 def to_crs(self, crs=None, epsg=None):
1048 """Returns a ``GeoSeries`` with all geometries transformed to a new
1049 coordinate reference system.
1050
(...)
1121
1122 """
1123 return GeoSeries(
-> 1124 self.values.to_crs(crs=crs, epsg=epsg), index=self.index, name=self.name
1125 )
File [~/miniconda3/envs/geemap/lib/python3.10/site-packages/geopandas/array.py:777](https://vscode-remote+wsl-002bubuntudev.vscode-resource.vscode-cdn.net/mnt/d/Scripts/sam/code/~/miniconda3/envs/geemap/lib/python3.10/site-packages/geopandas/array.py:777), in GeometryArray.to_crs(self, crs, epsg)
774 if self.crs.is_exact_same(crs):
775 return self
--> 777 transformer = Transformer.from_crs(self.crs, crs, always_xy=True)
779 new_data = vectorized.transform(self.data, transformer.transform)
780 return GeometryArray(new_data, crs=crs)
File [~/miniconda3/envs/geemap/lib/python3.10/site-packages/pyproj/transformer.py:573](https://vscode-remote+wsl-002bubuntudev.vscode-resource.vscode-cdn.net/mnt/d/Scripts/sam/code/~/miniconda3/envs/geemap/lib/python3.10/site-packages/pyproj/transformer.py:573), in Transformer.from_crs(crs_from, crs_to, skip_equivalent, always_xy, area_of_interest, authority, accuracy, allow_ballpark)
566 if skip_equivalent:
567 warnings.warn(
568 "skip_equivalent is deprecated.",
569 DeprecationWarning,
570 stacklevel=2,
571 )
--> 573 return Transformer(
574 TransformerFromCRS(
575 cstrencode(CRS.from_user_input(crs_from).srs),
576 cstrencode(CRS.from_user_input(crs_to).srs),
577 always_xy=always_xy,
578 area_of_interest=area_of_interest,
579 authority=authority,
580 accuracy=accuracy if accuracy is None else str(accuracy),
581 allow_ballpark=allow_ballpark,
582 )
583 )
File [~/miniconda3/envs/geemap/lib/python3.10/site-packages/pyproj/transformer.py:310](https://vscode-remote+wsl-002bubuntudev.vscode-resource.vscode-cdn.net/mnt/d/Scripts/sam/code/~/miniconda3/envs/geemap/lib/python3.10/site-packages/pyproj/transformer.py:310), in Transformer.__init__(self, transformer_maker)
304 raise ProjError(
305 "Transformer must be initialized using: "
306 "'from_crs', 'from_pipeline', or 'from_proj'."
307 )
309 self._local = TransformerLocal()
...
105 )
File pyproj/_transformer.pyx:1001, in pyproj._transformer._Transformer.from_crs()
ProjError: Error creating Transformer from CRS.