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

Create a high-level RasterUpdater.write function #95

Closed
mwtoews opened this issue Jun 19, 2014 · 4 comments
Closed

Create a high-level RasterUpdater.write function #95

mwtoews opened this issue Jun 19, 2014 · 4 comments
Milestone

Comments

@mwtoews
Copy link
Contributor

mwtoews commented Jun 19, 2014

This function should be best friends with read(), so data from numpy arrays could be symmetrically read/written for multidimensional arrays/bands. See #71 and #83 for background to the high-level read() implementation. This function will make use of write_band, which will remain the same.

The proposed prototype for the RasterUpdater class is:

def write(self, src, bidx=None, window=None)

where

  • src: source Numpy array (masked or regular)
    • A 3D array (nbands, nrow, ncol) with optional list of indexes e.g. bidx=[1, 3] for two bands: the first and third
    • A 2D array (nrow, ncol) with band index integer e.g. bidx=1 for the first
  • bidx: band index as list (for 3D) or integer (for 2D). Default of None assumes all indexes of the raster, and a length check is done with the 0th dimension of src
  • window: same as in write_band

When a mask array is used for src, the band array should be written using the MaskedArray.filled(fill_value=None) function, where fill_value is from nodatavals if not None for the band index, otherwise should this be set from the masked array fill_value. Only in this case, the nodatavals list for the raster could be modified by this function to update it from None to fill_value from the masked array.

Feedback and suggestions are welcome!

@sgillies
Copy link
Member

👍

@mwtoews I'd like to point out that we're now releasing the GIL when calling GDALRasterioIO (see https://github.com/mapbox/rasterio/blob/master/rasterio/_io.pyx#L42). If, instead of having write() call write_band() multiple times, we pushed the writes into almost-pure C functions (multi-band versions of the io_*() functions) we could release the GIL once for many reads/writes. Does that make sense to you? Then write_band() could just call write().

@sgillies
Copy link
Member

Hey, so we're not duplicating effort: I'm making good progress on io_multi_*() functions that read or write multiple bands in a branch I've dedicated to #96. Along the way I'm learning some new stuff about Cython typed memoryviews and the GIL (all good).

@sgillies
Copy link
Member

I closed #96. The io_multi* functions are good to go.

@sgillies sgillies added this to the 0.10 milestone Jul 16, 2014
@sgillies sgillies modified the milestones: 0.10, 0.11 Aug 4, 2014
@sgillies
Copy link
Member

sgillies commented Aug 5, 2014

@mwtoews in the end, I didn't implement mask filling, but we can do that as another issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants