Spatial lookups for RasterField

62 views
Skip to first unread message

Daniel Wiesmann

unread,
Jan 28, 2016, 10:33:54 AM1/28/16
to Django developers (Contributions to Django itself)
Hello Everyone

I have been working on adding spatial lookups for the RasterField in the GIS module.

https://github.com/django/django/pull/5460#issuecomment-152606283

I would like to get feedback regarding API design for the lookups.

The challenge is that one needs to specify two parameters for the lookup: the raster itself and a band index.

I think everything should default to the first band, as many rasters only have one band. For the special cases, an index has to be specified.

On the right hand side (rhs) the proposal is to use a syntax similar to the existing distance lookups, providing a tuple: (raster, band_index). That follows previous art and should be ok.

But on the left hand side (lhs) its less clear to me what to do.

For instance, to compare band 2 from a raster field "elevation" with a geometry, I can see two options

A specify the index with a double underscore:

elevation__2__intersects=geom

B pass the band index on the rhs:

elevation__intersects=(geom, 2)

The current implementation in the PR above uses the second option. But I have doubts because that mixes the lhs with the rhs.

Here are my questions:

- Are there other options for the api that shoudl be considered?
- If not, which of the two approaches would be better?

Thanks,

Daniel

Tim Graham

unread,
Mar 7, 2016, 10:53:15 AM3/7/16
to Django developers (Contributions to Django itself)
The index approach seems consistent with ArrayField's index transforms [0] so that seems okay to me.

[0] https://docs.djangoproject.com/en/1.9/ref/contrib/postgres/fields/#index-transforms
Reply all
Reply to author
Forward
0 new messages