Skip to content

Replace hardcoded Alaska Albers with dynamic UTM lookup#84

Open
arpitjain099 wants to merge 2 commits into
dbetchkal:mainfrom
arpitjain099:fix/dynamic-equal-area-projection
Open

Replace hardcoded Alaska Albers with dynamic UTM lookup#84
arpitjain099 wants to merge 2 commits into
dbetchkal:mainfrom
arpitjain099:fix/dynamic-equal-area-projection

Conversation

@arpitjain099

Copy link
Copy Markdown
Contributor

Fixes #51.

The mask-buffering step in query_tracks(), query_adsb(), and query_ais_mxak() hardcodes
EPSG:3338 (Alaska Albers) as the equal-area projection. That gives wrong buffer distances for
parks outside Alaska. The same issue affects the area calculation in
study_duration_stability.fit_varying_n_tracks().

This patch replaces every epsg:3338 reference with a dynamic UTM zone derived from the
geometry's centroid, using coords_to_utm() which already exists in the codebase. For the
stability module the fix is even simpler: NMSIM_bbox_utm() already computes the correct
UTM zone earlier in the function, so we reuse that variable.

With this change the toolkit works correctly for any park in the US (for example Great Smoky
Mountains, which is already in active use per Gurung et al. 2026).

Files changed

  • nps_active_space/utils/helpers.py - query_tracks() and query_adsb() buffer projections
  • nps_active_space/utils/ais/query.py - query_ais_mxak() buffer projection
  • nps_active_space/validation/study_duration_stability.py - area calculation projection

The query_tracks(), query_adsb(), and query_ais_mxak() helpers all
project the spatial mask into EPSG:3338 (Alaska Albers) for buffering.
This only gives correct results for parks in Alaska.

Use coords_to_utm() (already in the codebase) to derive the
appropriate UTM zone from the mask centroid so the buffer works
for any location in the US.  In study_duration_stability, reuse the
utm_zone variable that NMSIM_bbox_utm() already computed for the
study area.

Fixes dbetchkal#51

Signed-off-by: Arpit Jain <arpitjain099@gmail.com>

@elliott-ruebush elliott-ruebush left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice idea for a change to improve general applicability of this software!

Could we potentially add some unit tests around the dynamic UTM lookup?

@arpitjain099

Copy link
Copy Markdown
Contributor Author

Sure thing. I'll add tests covering different regions (Alaska, somewhere in CONUS, southern hemisphere) to verify the zone detection handles various coordinate inputs correctly. Will push a follow-up commit.

Cover Alaska, CONUS, southern hemisphere, zone boundaries,
prime meridian, and far-east/west edge cases. All tests are
self-contained with no external data dependencies.

Signed-off-by: arpitjain099 <arpitjain099@gmail.com>
@arpitjain099 arpitjain099 mentioned this pull request Jul 7, 2026
6 tasks

@elliott-ruebush elliott-ruebush left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! Thanks for adding the tests

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Use general equal area projection, not always Alaska Albers

2 participants