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

Add lenunit option to GeoIO.load #100

Closed
kramsretlow opened this issue Jul 24, 2024 · 12 comments
Closed

Add lenunit option to GeoIO.load #100

kramsretlow opened this issue Jul 24, 2024 · 12 comments
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed

Comments

@kramsretlow
Copy link

I have an .obj file that was exported from a CAD program. The CAD software was using mm as the unit. If I import it as a SimpleMesh using GeoIO.load(filename).geometry, it comes out with units of meters. Is it (or could it be) possible to specify the units in the call to load? And/or, is there an easy way to change the units of a mesh after creation? Right now I am using the inelegant way of loading the mesh, then creating a new mesh with a fix_part_units function defined like this:

fix_unit(p) = Meshes.Point((ustrip.([coords(p).x, coords(p).y, coords(p).z]) .* u"mm")...)
fix_part_units(msh) = SimpleMesh([fix_unit(v) for v in vertices(msh)], msh.topology)

I've tried searching the docs and source, but I can't find the functionalities I'm after. Sorry if I've missed something.

I'm not familiar with all of the file formats, but I guess this point could apply to some other "unitless" formats as well.

@juliohm
Copy link
Member

juliohm commented Jul 24, 2024

Hi @kramsretlow, it is good to see you.

We should probably add a lengthunit option to load as suggested given that .obj files don't store units.

Would you like to try adding the option yourself? You can forward it to any affected format, and we can review it.

@juliohm juliohm added enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed labels Jul 24, 2024
@kramsretlow
Copy link
Author

Hi @juliohm , thanks for remembering me 😄

I will try to make some time in the next while to work on it, though I can't promise it'll get done. So far I was still unable to find the point in the source where the meters unit magically joined my mesh coordinates--will need to check it more deeply.

I'm really enjoying using Meshes.jl for some computation job I'm doing on 3D parts. If one comes to Meshes.jl from a direction not related to geographical data, it feels slightly odd to need to go to GeoIO.jl (which is clearly geostats related) to load a mesh. Not a problem, but just a comment from user's perspective. In any case, thanks for your work on these packages!

@juliohm
Copy link
Member

juliohm commented Jul 25, 2024

I was still unable to find the point in the source where the meters unit magically joined my mesh coordinates--will need to check it more deeply.

The units are added in the Point constructor. You can write Point(x, y) with x and y unitful quantities:

Point(1mm, 2mm)

m is the default unit when x and y are not unitful.

You can add a unit to a pre-existing tuple with:

u = mm

Point(x * u, y * u)

I'm really enjoying using Meshes.jl for some computation job I'm doing on 3D parts.

Glad you are enjoying it :)

If one comes to Meshes.jl from a direction not related to geographical data, it feels slightly odd to need to go to GeoIO.jl (which is clearly geostats related) to load a mesh. Not a problem, but just a comment from user's perspective. In any case, thanks for your work on these packages!

GeoIO.jl is not tied to GeoStats.jl (the package), but is certainly related to GeoStats.jl (the framework). It doesn't depend on the "stats" part of "geostats". Think of it as a simple tool to load geospatial data as geotables, which can be used for any purpose beyond geospatial data science and geostatistical modeling.

@juliohm juliohm changed the title specify units when loading an .obj file? Add lenunit option to GeoIO.load Jul 31, 2024
@juliohm
Copy link
Member

juliohm commented Aug 9, 2024

@kramsretlow the option should be available now. Please update the environment.

I will leave the issue open because there some other formats also support the option, but we didn't have time to implement yet:

  • vtk
  • img
  • csv

@juliohm
Copy link
Member

juliohm commented Sep 9, 2024

/bounty $20

Copy link

algora-pbc bot commented Sep 9, 2024

💎 $20 bounty • JuliaEarth

Steps to solve:

  1. Start working: Comment /attempt #100 with your implementation plan
  2. Submit work: Create a pull request including /claim #100 in the PR body to claim the bounty
  3. Receive payment: 100% of the bounty is received 2-5 days post-reward. Make sure you are eligible for payouts

Thank you for contributing to JuliaEarth/GeoIO.jl!

Add a bountyShare on socials

Attempt Started (GMT+0) Solution
🔴 @mobley-trent Sep 10, 2024, 6:11:33 AM WIP

@mobley-trent
Copy link

mobley-trent commented Sep 10, 2024

/attempt #100

Algora profile Completed bounties Tech Active attempts Options
@mobley-trent 10 bounties from 5 projects
Python, Rust,
Jupyter Notebook
Cancel attempt

@mobley-trent
Copy link

Hello @juliohm correct me if I'm wrong but this issue seems to have been fixed in #110

@juliohm
Copy link
Member

juliohm commented Sep 10, 2024

@mobley-trent it is partially fixed. The option is not available in the formats listed above in a check list.

@mobley-trent
Copy link

mobley-trent commented Sep 10, 2024

I see that vtkread, imgread and csvread are referenced in the load function. Perhaps I am missing something @juliohm ?

@juliohm
Copy link
Member

juliohm commented Sep 10, 2024

The option is passed to the inner functions, but it is being currently ignored. See the csvread for example:

function csvread(fname; lenunit, coords, kwargs...)

The option is not used inside the function.

@juliohm
Copy link
Member

juliohm commented Sep 24, 2024

Fixed for all backends.

@juliohm juliohm closed this as completed Sep 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants