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

rasterize is not covering the full extent of the input polygon #749

Closed
asinghvi17 opened this issue Sep 19, 2024 · 8 comments · Fixed by #751
Closed

rasterize is not covering the full extent of the input polygon #749

asinghvi17 opened this issue Sep 19, 2024 · 8 comments · Fixed by #751

Comments

@asinghvi17
Copy link
Contributor

MWE:
california_borders.geojson.txt

using GeoJSON, Rasters, CairoMakie
california_borders = GeoJSON.read(read("california_borders.geojson.txt"))
raster = rasterize(california_borders; fill = 1, res = 0.5, shape = :line)

fig, ax, plt = plot(raster; colormap = cgrad(:Set3; categorical = true))
lines!(ax, california_borders; color = :darkgrey, linewidth = 1)
scatter!(ax, vec(DimPoints(raster)); markersize = 3, color = :black)
fig

Note here that the top seems uncovered by the raster?! Also it's not closed.

@rafaqz
Copy link
Owner

rafaqz commented Sep 19, 2024

Ahh right it needs to use Touches for the extent somewhere.

And the plotting looks a bit weird too, like there is a half offset missing somewhere.

@rafaqz
Copy link
Owner

rafaqz commented Sep 19, 2024

Uggh this is an open/closed intervals problem. Probably I should actually use Interval internally to fix it cleanly.

Like the extent of a polygon is closed,closed but a raster is closed,open. So we are missing the points at the edges

@rafaqz
Copy link
Owner

rafaqz commented Sep 19, 2024

fixed

Adding eps to upper bounds fixes it. I think I consolodated a bunch of separate code at some point in the past and broke it by treating all extents as the same. Maybe extents should hold intervals...

@asinghvi17
Copy link
Contributor Author

Gotcha, looks like a doable fix then..

@rafaqz
Copy link
Owner

rafaqz commented Sep 19, 2024

Yeah the qustion is if we fix it here or in Extents.jl.

Maybe Intervals in extents is a longer term problem, and I'll hack it here for now.

@rafaqz
Copy link
Owner

rafaqz commented Sep 19, 2024

Ok this looks accurate to me now, as this DimPoints is the starts of the intervals

fixed

@asinghvi17
Copy link
Contributor Author

Sweet!

Should DimPoints be defined as always being the center of the interval? Is there a way one can specify that?

@rafaqz
Copy link
Owner

rafaqz commented Sep 19, 2024

Yeah, hard to say. Despite the name it knows that its still Intervals{Start} and that will e.g. propagate through similar, broadcasts etc. Its just giving you the values in the lookups as points so changing them might be confusing.

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 a pull request may close this issue.

2 participants