Skip to content

Reprojection#681

Merged
TheJeran merged 15 commits into
mainfrom
jp/projection
Jul 16, 2026
Merged

Reprojection#681
TheJeran merged 15 commits into
mainfrom
jp/projection

Conversation

@TheJeran

@TheJeran TheJeran commented Jul 16, 2026

Copy link
Copy Markdown
Collaborator

This update brings reprojection to Browzarr using the https://github.com/proj4js/proj4js package.

reprojection

Workflow

Reprojection is handled in the adjustments menu like all other tweaks. At the moment there is no parsing or searching for CRS on datasets so you have to set the CRS manually (The UI could use some love)

image image

Proj4js is not as flexible as rioxarray so there aren't a lot of prenamed CRS you can use:

‘EPSG:4326’, which has the following alias
‘WGS84’
‘EPSG:4269’
‘EPSG:3857’, which has the following aliases
‘EPSG:3785’
‘GOOGLE’
‘EPSG:900913’
‘EPSG:102113’
EPSG:32601 to EPSG:32660 (WGS84 / UTM zones 1 to 60 North)
EPSG:32701 to EPSG:32760 (WGS84 / UTM zones 1 to 60 South)
EPSG:5041 (WGS 84 / UPS North (E,N))
EPSG:5042 (WGS 84 / UPS South (E,N))

After entering a CRS (I like Mollweide)

+proj=moll +lon_0=0

Resolution represents the vertical resolution of the new grid. It affects the jaggedness along valid and invalid coordinates. It also is the number of little cubes that will show up in the FlatBlocks displacement. So in the animation that is not a surface, that is a high resolution number of blocks.

image

After reprojecting, the shape of the plot and the Axis ticks will update to reflect the new CRS.

WGS84 EASE Grid
browzarr-plot (3) browzarr-plot (4)

Limitations/Conflicts

I dunno how this will behave with Analysis and the Country lines haven't been updated to work with this.
Sphere and point-cloud are unaffected

At the moment I'm assuming all variables in a dataset have the same CRS and only wipe the CRS when changing datasets. Can remove annoyance with having to re-enter CRS each time you change variable.

The reset icon is always visible

Misc

I went with 12 textures for the main texture arrays since I need 3 extra textures and 13 is random. It makes sense 2x2x3

added mutable axisDim# states to update the axis values. This will also be used when transformations is added.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request introduces coordinate reprojection capabilities using the proj4 library, adding a new Reprojection UI component, a ProjectionTexture utility, and updating global stores, plot components, and shaders to support remapping textures. The review feedback highlights several critical issues, including multiple GPU memory leaks from missing .dispose() calls on textures, potential runtime crashes from unhandled exceptions in proj4 operations, a TypeError when reversing undefined arrays, and a RangeError from unhandled NaN resolution inputs. Additionally, improvements are suggested to handle division-by-zero during array normalization, replace strict floating-point equality checks with tolerance thresholds, and clean up a duplicated CSS class name.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread src/components/LandingHome.tsx Outdated
Comment thread src/components/textures/ProjectionTexture.ts
Comment thread src/components/textures/ProjectionTexture.ts
Comment thread src/components/plots/AxisLines.tsx
Comment thread src/components/ui/Elements/Reprojection.tsx Outdated
Comment on lines +71 to +75
for (let i = 2; i < len; i++) {
if (array[i] - array[i - 1] !== step) {
return false;
}
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

Strict equality check (!==) on floating-point differences can fail due to precision inaccuracies in JavaScript (e.g., 0.3 - 0.2 !== 0.1). Use an epsilon/tolerance threshold to check for uniform steps reliably.

Suggested change
for (let i = 2; i < len; i++) {
if (array[i] - array[i - 1] !== step) {
return false;
}
}
for (let i = 2; i < len; i++) {
if (Math.abs((array[i] - array[i - 1]) - step) > 1e-9) {
return false;
}
}

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I may come back to this

Comment thread src/components/textures/ProjectionTexture.ts Outdated
Comment thread src/components/ui/Elements/Reprojection.tsx Outdated
Comment thread src/components/textures/ProjectionTexture.ts
@TheJeran
TheJeran merged commit 6c8045b into main Jul 16, 2026
6 checks passed
This was referenced Jul 16, 2026
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.

1 participant