Skip to content
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

[Bug]Loading base maps #2450

Open
LorenzEh opened this issue Aug 16, 2023 · 7 comments
Open

[Bug]Loading base maps #2450

LorenzEh opened this issue Aug 16, 2023 · 7 comments
Assignees
Labels

Comments

@LorenzEh
Copy link

LorenzEh commented Aug 16, 2023

Hello,

I´m struggeling with using a base map on a geojson dataframe of contiguous USA (polygons of the counties). None of the base maps seem to load. Also, the map window gets zoomed out if I try to load a base map and I can´t zoom in again. I tried adjusting my Firewall, as suggested in a previous post. All other operations with the data frame work perfectly fine (eg. creating weights). Im using Windows 10 Pro, version 22H2.

@LorenzEh LorenzEh added the bug label Aug 16, 2023
@LorenzEh LorenzEh changed the title [Bug]Loading base maps [Bug]Loading base maps Aug 16, 2023
@lixun910
Copy link
Member

Hi @LorenzEh, I doubt it could be a projection issue. Is it possible to share your data with me, so I can replicate it on my side? (xunli at uchicago dot edu)Thanks!

@LorenzEh
Copy link
Author

Thanks for your answer. I also think, that it´s an projection issue. I tried various settings, but none seem to work. I sent you the data frame per mail. Many thanks!

@lixun910
Copy link
Member

Thanks for sharing the data, @LorenzEh! I took a quick look and noticed the coordinates in the geojson file are not latitudes and longitudes:

"geometry": { "type": "Polygon", "coordinates": [ [ [ 807455.392761853989214, 2546708.977930807042867 ], [ 807455.393001545453444, 2546708.977977536153048 ], [ 807455.39078853931278, 2546709.066942900419235 ], [ 807455.389023010386154, 2546709.155353326816112 ], [ 807455.38658063125331, 2546709.237100647762418 ], [ 807455.682548265205696, 2546709.240207165945321 ], [ 807455.778317327611148, 2546709.241212370339781 ], [ 807455.776965847820975, 2546709.168454395607114 ], [ 807455.761028536478989, 2546709.107905836775899 ], [ 807455.748624625732191, 2546709.046384064946324 ], [ 807455.750068846391514, 2546709.042590104509145 ], [ 807455.784047283232212, 2546708.953328959643841 ], [ 807455.784649488981813, 2546708.951746970880777 ], [ 807455.825810951879248, 2546708.895810604095459 ], [ 807455.642366748303175, 2546708.892880711704493 ], [ 807455.585099698742852, 2546708.892189278267324 ], [ 807455.566164272488095, 2546708.891893259249628 ], [ 807455.393514780327678, 2546708.888892692048103 ], [ 807455.392761853989214, 2546708.977930807042867 ] ] ] } }

From the crs code in your geojson file: "crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:EPSG::32614" } }, it shows the projection is UTM Zone 14, which should not be used for the entire US. (See https://epsg.io/32614).

To fix this projection issue, I think you can try to reproject the original raw geometires (if you have) to WGS84 EPSG::4326 (https://epsg.io/4326). E.g. you can use ogr2ogr to do reprojection:
https://gdal.org/programs/ogr2ogr.html#cmdoption-ogr2ogr-t_srs

@LorenzEh
Copy link
Author

Thanks for you answer and checking my data. I tried reprojection using geopandas and got the following output in python:

Out[79]: 
<Geographic 2D CRS: EPSG:4326>
Name: WGS 84
Axis Info [ellipsoidal]:
- Lat[north]: Geodetic latitude (degree)
- Lon[east]: Geodetic longitude (degree)
Area of Use:
- name: World.
- bounds: (-180.0, -90.0, 180.0, 90.0)
Datum: World Geodetic System 1984 ensemble
- Ellipsoid: WGS 84
- Prime Meridian: Greenwich

Unforutnatly I´m still not able to use a basemap in Geoda:
geoda2
What Am I doing wrong here? Is it necessary to create latidues and longituded in order to use a base map?
Many thanks!

@lixun910
Copy link
Member

@LorenzEh The projection looks right, but I doubt the coordinates are not correctly projected. You can check the latitudes and longitudes in the geojson file, and e.g. compare them to a valid US geojson file like https://geodacenter.github.io/data-and-lab/data/natregimes.geojson

For example, the first geometry in your geojson is "origin_fips_code": "17097", "origin_state": "IL", "County": "il_lake", and check if the coordinates are similar (or at least the similar value range) of the one below:

{ "type": "Feature", "properties": { "REGIONS": 1.000000, "NOSOUTH": 1.000000, "POLY_ID": 3031, "NAME": "Lake", "STATE_NAME": "Illinois", "STATE_FIPS": "17", "CNTY_FIPS": "097", "FIPS": "17097" }, "geometry": { "type": "MultiPolygon", "coordinates": [ [ [ [ -87.797309875488281, 42.489131927490234 ], [ -87.836944580078125, 42.314212799072266 ], [ -87.760238647460938, 42.156455993652344 ], [ -88.204025268554688, 42.157115936279297 ], [ -88.1947021484375, 42.489612579345703 ], [ -87.797309875488281, 42.489131927490234 ] ] ] ] } },

If the coordinates in your geojson are very different, then you need to find a good source of the geometries and replace the ones in your geojson file. You can use geopandas to replace the geom column with another geom column based on e.g FIPS id

@lixun910
Copy link
Member

@LorenzEh Just noticed the map boundary in your screenshots looks not correct:

Screenshot 2023-08-18 at 11 19 23 AM

It should be close to the range:
Lower left: -124.731422, 24.955967 Upper right: -66.969849, 49.371735

@LorenzEh
Copy link
Author

LorenzEh commented Aug 22, 2023

Many thanks for your answers. I thought that GeoPandas could adjust the geo column correctly with to_crs (see https://geopandas.org/en/stable/docs/reference/api/geopandas.GeoDataFrame.to_crs.html). Its good to know for future projects, that it doesnt seem to be 100% reliable. Sorry for reporting this as GeoDa bug.

Best wishes,
Lorenz

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants