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

ENH: Define datatype for make_geocube #72

Closed
snowman2 opened this issue Aug 13, 2021 Discussed in #61 · 1 comment · Fixed by #82
Closed

ENH: Define datatype for make_geocube #72

snowman2 opened this issue Aug 13, 2021 Discussed in #61 · 1 comment · Fixed by #82

Comments

@snowman2
Copy link
Member

Discussed in #61

Originally posted by mjyshin March 19, 2021
Hello, I have a lot of Shapely polygons as shapes that I want to rasterize into an output image, but the output will be huge. Is there a way to use make_geocube so that when I run something like

gdf = gpd.GeoDataFrame({'mask': shape_types}, geometry=shapes)
cube = make_geocube(gdf, resolution=(-1, 1), fill=0)
mask = cube.mask.values

the mask will be an int8 array instead of float64 (shape_types will naturally only be small integers)? Thanks in advance!

@snowman2
Copy link
Member Author

It is currently defaulted to float64 ref. If you would like to specify a different dtype, you could open up a PR to add the dtype kwarg to rasterize_image and then use functools.partial to change the dtype similar to what is done in this example ref.

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.

1 participant