Skip to content

Commit

Permalink
[Enhancement] automatically re-project GeoDataFrame to EPSG:4326 (#1350)
Browse files Browse the repository at this point in the history
* automatically reproject to 4326

Signed-off-by: Martin Fleischmann <martin@martinfleischmann.net>

* readme

Signed-off-by: Martin Fleischmann <martin@martinfleischmann.net>
  • Loading branch information
martinfleis committed Dec 8, 2020
1 parent 2aad97f commit be61b70
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 3 additions & 0 deletions bindings/kepler.gl-jupyter/keplergl/keplergl.py
Expand Up @@ -29,6 +29,9 @@ def _gdf_to_dict(gdf):
Returns:
- dictionary: a dictionary variable that can be used in Kepler.gl
'''
# reproject to 4326 if needed
if gdf.crs and not gdf.crs == 4326:
gdf = gdf.to_crs(4326)

# get name of the geometry column
# will cause error if data frame has no geometry column
Expand Down
2 changes: 1 addition & 1 deletion docs/keplergl-jupyter/README.md
Expand Up @@ -212,7 +212,7 @@ w1.add_data(data=df, name='cities')
```

### `GeoDataFrame`
kepler.gl accepts [geopandas.GeoDataFrame][geo_data_frame], it automatically converts the current `geometry` column from shapely to wkt string.
kepler.gl accepts [geopandas.GeoDataFrame][geo_data_frame], it automatically converts the current `geometry` column from shapely to wkt string and re-projects geometries to latitude and longitude (EPSG:4326) if the active `geometry` column is in a different projection.
```python
url = 'http://eric.clst.org/assets/wiki/uploads/Stuff/gz_2010_us_040_00_500k.json'
country_gdf = geopandas.read_file(url)
Expand Down

0 comments on commit be61b70

Please sign in to comment.