-
Notifications
You must be signed in to change notification settings - Fork 9
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
unexpected behavior for running Proj4.trans on multiple points vs. a single point #60
Comments
Hi! It looks like the broadcasting behavior is a bit different than you are expecting here. Without broadcasting, So if you look at the output here, it is a list of points:
Judging from the assigned variables you were expecting an x and a y vector instead, but that is not what is returned. If your lat and lon coordinate come as separate vectors, and you'd like separate vectors as output as well, you could use such an approach: # allocate vectors for the output
y = zero(lat)
x = zero(lon)
# fill them one by one
for (i, point) in enumerate(zip(lat, lon))
x[i], y[i] = trans(point)
end Now the output looks correct:
It's probably useful to document this pattern. |
Ahhh... got it thanks a ton. I'm still dreaming in Matlab so this is really helpful. I also found this discussion on immutable arrays (https://m3g.github.io/JuliaNotes.jl/stable/immutable/) very helpful to grow my understanding of what's going on. In the end I settled on: specify lat and lon valueslat = [69.1, 70.1, 90] trans = Proj4.Transformation("EPSG:4326", "EPSG:3413") parse x and y valuesxPt = first.(pt) |
You can also broadcast xs = getindex.(pt, 1)
ys = getindex.(pt, 2)
zs = getindex.(pt, 3) |
Hello all... Working with Proj4 and getting some unexpected behavior for running Proj4.trans on multiple points vs. a single point... in my code I've had to put an if, else to switch between single lat lon and multiple lat lon which seems like a bad option. Wondering if anyone has a better way of handling this?
The text was updated successfully, but these errors were encountered: