oturns / geosnap

The Geospatial Neighborhood Analysis Package
https://oturns.github.io/geosnap-guide
BSD 3-Clause "New" or "Revised" License
247 stars 32 forks source link

check for multiple crs in from_geodataframes constructor #279

Closed AnGWar26 closed 3 years ago

AnGWar26 commented 4 years ago

Addresses #276. This is my first shot at this. Let me know if you want any implementation changes on it, like telling the user which frames have mismatches, or raising an error/warning instead of using an assert statement @knaaptime.

Tested using the Chicago GeoDataFrames from 02_creating_community_datasets image

codecov[bot] commented 4 years ago

Codecov Report

Merging #279 (1924f37) into master (158315c) will decrease coverage by 10.5%. The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff            @@
##           master    #279      +/-   ##
=========================================
- Coverage    81.6%   71.1%   -10.5%     
=========================================
  Files          12      14       +2     
  Lines        1184    1184              
=========================================
- Hits          966     842     -124     
- Misses        218     342     +124     
Impacted Files Coverage Δ
geosnap/_community.py 71.9% <ø> (-2.7%) :arrow_down:
geosnap/_data.py 72.9% <ø> (-0.3%) :arrow_down:
geosnap/analyze/__init__.py 100.0% <ø> (ø)
geosnap/analyze/analytics.py 85.9% <ø> (+1.9%) :arrow_up:
geosnap/analyze/cluster.py 92.7% <ø> (+0.2%) :arrow_up:
geosnap/analyze/regionalize.py 90.9% <ø> (ø)
geosnap/io/storage.py 22.6% <ø> (-72.7%) :arrow_down:
geosnap/analyze/dynamics.py 61.3% <0.0%> (-38.7%) :arrow_down:
... and 6 more
knaaptime commented 4 years ago

smart, i like it. thanks!

knaaptime commented 4 years ago

wanna take a shot at writing a test?

AnGWar26 commented 4 years ago

Sure. I've never written one of these tests before, so I'll just give it a shot right here before I put it in a PR.

From looking at the tests already in geosnap, I was thinking it would look something like this: Placed under test_Community_from_gdfs() in test_community.py.

def test_Community_from_gdfs_crs():
    t90 = datasets.tracts_1990()
    t00 = datasets.tracts_2000()
    t90 = t90.to_crs(4236)
    t00 = t00.to_crs(3857)
    try:
        Community.from_geodataframes([t90, t00])
    except AssertionError:
        print("From_gdfs constructor successfully detects inconsistent crs.")
        pass

Thanks for taking a look at this!

knaaptime commented 3 years ago

test looks good too! add it to the pr :)