-
Notifications
You must be signed in to change notification settings - Fork 36
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
Some comments/suggestions concerning plotting and other funtionality (paletted geotiffs) #52
Comments
Can't share the input file I used in the gist, sadly, for copyright reasons.. |
Thanks for trying it out and the suggestions. I agree there is much more that could be improved. Obviously the package at this point reflects mostly my own needs, but hopefully more people can collaborate and we can improve this to make it more useful to more users. Do you have any data that is similar and not under copyright? Or just deidentified a subset of your data? |
I am not sure I understand your point 2. If you extract a subset fo the data, say between (x0, y0) and (x1,y1) the geot needs to be updated. Otherwise it will put the extracted raster in the wrong place (see here). |
Exactly my point, it seems |
OK, here's a downloadable example geotiff with qualitative data and an embedded paletted colormap (and not too crazy file size): https://www.eea.europa.eu/data-and-maps/data/global-land-cover-250m color codes land use class Here's the gist to plot it: https://gist.github.com/9b7f31f617a1a4c077e83d013d27d1f9 Default georasters plot (after extracting a tiny subpatch) How it should look like |
So here's the plot for 6. Multiband RGB image Only needs some axis juggling on the array, but cropping operations Link to the data file is in the gist. |
I added a short summary in first post. |
You are right about |
Multiband is not yet supported, but it's on the to-do list. |
I will check out your examples once I have some time. |
didn't try reduce yet, only tried |
Yeah, sure, I just wanted to share my thoughts since I was looking into it anyway. No use letting all these findings go to waste by not sharing them here. |
Sure that is perfect! I actually meant |
I made #53 since I'm playing around in a dev environment anyway and so that you can see what I think could improve things and you can try it out as well. |
I was trying out georasters today, specifically for plotting paletted geotiff files.
Here's a few comments, in no particular order.. i might not be able to help with PRs at this point, due to time restrictions and although because I'm not fully sure georasters will work for me (main blocker for me right now is lack of reprojection and deficiencies in downsampling, esp. with paletted data).
But I wanted to at least leave these comments to help with thoughts for improvements (compare gist linked at bottom).
1. Correct map extents
Most geotiffs I work with are in some metric coordinates and pixels are aligned rectangular in X and Y. Those plots should take into account map extent, which is trivial, extracted from
data.geot
. It's possible to manually do it and pass it in todata.plot(..., extent=..)
but it could be done automatically. See gist.2. Track transformation changes
Methods like
.resize
and.extract
change the map extents (compare above). Derived georaster should have it's.geot
attribute updated, otherwise it's not correct anymore (e.g. adjust thedx
anddy
on resize and adjust x/y boundaries when doing an extract)3. Use paletted color map defined by geotiff
Some geotiffs use paletted colormaps and these won't plot correct with just a default divergent colormap. With gdal it's easy to extract paletted colors and create a matplotlib linear segmented colormap for the array plot (see gist).
4. Resize with paletted data
Calculating new pixel values from an array of old pixels might need some other measure to compute new pixel, like a
mode
measure for example.5.
self.shape
should be a propertyWhen modifying
data.raster
(e.g. in a multiband geotif getting rid of 3rd dimension in array by reducing to one band),self.shape
breaks as it is not reflecting current state of the raster anymore. I think it should just return whatself.raster.shape
is currently saying.6. Multiband files problems
Multiband files, like most interestingly 3-band RGB geotiffs, are not handled correctly right now. It only needs one line of numpy to plot them correctly, moving the band-axis to the rear. Above problems with cropping/resampling the data will apply as well, though and code might need some love to take third axis into account, I bet.
Gist for the Natural Earth RGB plot: https://gist.github.com/b1d03ec98cb54656644d95a8f7abffb8
Summary
gdal.Open(filename).GetRasterBand(1).GetRasterColorTable()
) and plot with a linear segmented custom colormapdata.geot
self.shape
should be read-only property linking toself.raster.shape
I think, so that it doesn't get out of syncFor reference, here's my scripts I was playing around with..
The text was updated successfully, but these errors were encountered: