-
Notifications
You must be signed in to change notification settings - Fork 302
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
Weights for rasters or arrays with missing data #895
Comments
The following code changes the dictionary of weight by dropping all
|
Ok...looking at the code I figured out what was causing the error. I also needed to change the weights. There was also a mistake in the previous code for dropping missing data
Now it produces the data. Still trying to figure out if the output is correct. |
Here's a function to implement this. May create a pull request once I figure out where it could go, and if there's interest in this.
|
Does this get to what you are interested in:
|
@sjsrey Thanks for getting back to me. Indeed, it generates the same result as in my function above. The main difference is the inputs and the order of some of the neighbors (although that should affect any of the results). Any reason there is no material on rasters in PySal (or for that matter there seems to be an emphasis in the literature /software packages on spatial correlation on geometries, but nothing on rasters)? |
I've included part of your in my function
which seems to be much faster than your implementation (at least on the
|
@ozak thanks for pushing forward on this. On the ordering of the weights, it is important to ensure that the order matches that in the corresponding attribute vector, otherwise the calculation of things like spatial autocorrelation coefficients and the spatial lag will be incorrect. On the raster question, PySAL's origins were in vector based spatial analysis so rasters were not a key focus of the original developers. That said, if interested developers want to include support for rasters, we are open to it :-> On that score, for raster weights it may be more memory-efficient to calculate them on the fly rather than storing all the neighbors. Otherwise as the raster size grows, so too will the memory requirements of the weights structure. Of course there will be a trade-off in loss of speed for doing the weights on the fly rather than in-memory, but something to consider. |
@sjsrey I am still trying to figure out if there is way of doing it cleanly. I was trying to implement some spatial correlation methods of PySal for my GeoRasters package, where I can ensure this done correctly using the a function One option could be to do all this under the hood in PySal, i.e. that PySal constructs and performs all the computations using the flattened raster. But I imagine this may require a lot of reqriting, unless one can adapt the basic classes to take care of this. I am not knowledgable enough about PySal at the moment, so I am not sure. |
@sjsrey I have added the global spatial autocorrelation measures to my package (ozak/georasters@d6b1169). Since
and similarly for the other global measures. I will continue with the local ones, which require a bit of more thought. |
@ozak very nice to see the work on georasters 👍 I would be happy to help out over on georasters on the pysal interface if that would be of interest. If so, I think one place that would be a good target would be to add some tests on the missing/mask properties for the raster and the W objects to ensure the alignment is correct. I think it is best to iron that out before moving on to the local autocorrelation stats. Let me know if this makes sense. If it does, we can close the ticket here and move the discussion over to |
@sjsrey that sounds perfect! |
Closing this here and working on downstream issue ozak/georasters#13 |
Hi,
I was wondering if there is a way to assign weights to an array or raster using one of the weight functions? Or to change weights to take into account that there are missing data (e.g., GIS rasters). Here's a simple example of what I have in mind...
missn
shows which cells should not be included. Is there a way to edit thew
object to take this into account? Or is there a function that will create the weights based on the actual raster?Thanks for the help.
The text was updated successfully, but these errors were encountered: