Troubles with GeoStats/GeoIO coordinates with units

Thank you @juliohm! File reads fine now.

New issue - too small to warrant new thread, perhaps.

bb = boundingbox(gt.geometry)
minx, miny = coordinates(bb.min)[1:2]

coordinates function no longer works.

ERROR: LoadError: UndefVarError: `coordinates` not defined

I tried qualifying it as GeoStats.coordinates or GeoIO.coordinates to no avail.

I’m sure it is obvious but what am I missing?

The function is called c = coords(point) now. It returns a coordinate type with c.x and c.y if your coordinates are projected or Cartesian. You also have to(point) which returns a vector from the origin to the point.

I’m going to have to work through this a bit. The introduction of units seems to be causing my script issues.

I updated the above to:

using Unitful
    bb = boundingbox(gt.geometry)
    crd = coords(bb.min)
    minx = ustrip(Float64, u"m", crd.x)
    miny = ustrip(Float64, u"m", crd.y)

so it no longer fails.
Now I’m having issues on the next step.

I’ll leave this here - with thanks - and work through my issues. I’ll start another thread if/when I need more help.

1 Like

It takes some time to write units-aware code that is idiomatic. Try to rely on the transforms that we provide in the framework as much as possible to avoid manual operations with coordinates and units. Your code will be more general that way.

So, I changed the way I initialised some dataframe columns from

df.minx .= 0.0

to

df.minx .= 0.0u"m"

and after that, by the miracle that is julia, everything just worked!

It takes me a while, but when I finally get there, simple things like this are so satisfying!

1 Like

Yes! It is really nice to see units propagating in the code :slight_smile:

Quick tip to make it more readable:

using Unitful: m

df.minx .= 0.0m
1 Like