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

Delete convertcentroid!, converttounits!, dropcols! #90

Closed
cpaniaguam opened this issue Nov 27, 2023 · 0 comments · Fixed by #91
Closed

Delete convertcentroid!, converttounits!, dropcols! #90

cpaniaguam opened this issue Nov 27, 2023 · 0 comments · Fixed by #91
Assignees
Labels
enhancement New feature or request

Comments

@cpaniaguam
Copy link
Member

Remove convertcentroid!, converttounits!, dropcols! which are now in IFT.

"""
convertcentroid!(propdf, latlondata, colstodrop)
Convert the centroid coordinates from row and column to latitude and longitude. Also drop the columns specified in `colstodrop`.
"""
function convertcentroid!(propdf, latlondata, colstodrop)
latitude, longitude = [
[latlondata[c][x, y] for
(x, y) in zip(propdf.row_centroid, propdf.col_centroid)] for
c in ["latitude", "longitude"]
]
x, y = [
[latlondata[c][z] for z in V] for
(c, V) in zip(["Y", "X"], [propdf.row_centroid, propdf.col_centroid])
]
propdf.latitude = latitude
propdf.longitude = longitude
propdf.x = x
propdf.y = y
dropcols!(propdf, colstodrop)
return nothing
end
function dropcols!(df, colstodrop)
select!(df, Not(colstodrop))
return nothing
end
function converttounits!(propdf, latlondata, colstodrop)
if nrow(propdf) == 0
dropcols!(propdf, colstodrop)
return nothing
end
convertcentroid!(propdf, latlondata, colstodrop)
x = latlondata["X"]
dx = abs(x[2] - x[1])
convertarea(area) = area * dx^2 / 1e6
convertlength(length) = length * dx / 1e3
propdf.area .= convertarea(propdf.area)
propdf.convex_area .= convertarea(propdf.convex_area)
propdf.minor_axis_length .= convertlength(propdf.minor_axis_length)
propdf.major_axis_length .= convertlength(propdf.major_axis_length)
propdf.perimeter .= convertlength(propdf.perimeter)
return nothing
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant