pysal / mgwr

Multiscale Geographically Weighted Regression (MGWR)
https://mgwr.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
368 stars 126 forks source link

allow results.summary() to return a string or redirect #108

Closed chrisg-ngis closed 3 years ago

chrisg-ngis commented 3 years ago

results.summary() always prints to stdout. It would be good to provide it as a string that could be piped, logged or stored anywhere.

Ziqi-Li commented 3 years ago

Yes! That's something that is on the to-do list, and hopefully it can be done in a week or so.

chrisg-ngis commented 3 years ago

Hi Zigi Li,

I have been using the python GWR library for a few weeks. I am not very good at the stats side. My main feedback is that I would have loved to see some examples examining Raster data. We have data in GeoTIF which we read and perform GWR on. But there is missing data (clipped) where we have NaN so there are several issues.

  1. How to read a GeoTIFF to a 2D raster (rasterio)
  2. Convert to a 1D raster as input for GWR
  3. Get the lat lon of each point (or the xy offsets if UTM)
  4. Remove NaN
  5. Do GWR on cleaned array
  6. Apply the results back to the dirty array
  7. Reformat to a 2-D image or add as new bands and save.

I know most of this is not core to the library, but it would be of great value for people taking it up who are unfamiliar with these techniques.

Regards, Chris

From: Ziqi Li @.> Sent: Thursday, 11 November 2021 8:14 PM To: pysal/mgwr @.> Cc: Chris Goodman @.>; Author @.> Subject: Re: [pysal/mgwr] allow results.summary() to return a string or redirect (Issue #108)

This message was sent from outside the company by someone with a display name matching a user in your organisation. Please do not click links or open attachments unless you recognise the source of this email and know the content is safe.

Yes! That's something that is on the to-do list, and hopefully it can be done in a week or so.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/pysal/mgwr/issues/108#issuecomment-966123739, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AVULAN27RKO3KICXRINNWUTULOCNZANCNFSM5HZREYEQ. Triage notifications on the go with GitHub Mobile for iOShttps://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Androidhttps://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

Ziqi-Li commented 3 years ago

Hi @chrisg-ngis,

Thanks for the suggestion. However, data cleaning and preprocessing may be outside the scope of this package. I believe there should be methods available to convert a raster in rasterio to GeoDataFrame. If you have any standardised solution for demonstrating the process of feeding raster data to MGWR, please submit it as a pull request.

Cheers

mtralka commented 3 years ago

109 implements an as_str return option to summary methods. @chrisg-ngis does this meet your usage requirements?

chrisg-ngis commented 3 years ago

Hi Matthew,

That’s perfect!

Regards, Chris

From: Matthew Tralka @.> Sent: Friday, 12 November 2021 3:56 AM To: pysal/mgwr @.> Cc: Chris Goodman @.>; Mention @.> Subject: Re: [pysal/mgwr] allow results.summary() to return a string or redirect (Issue #108)

This message was sent from outside the company by someone with a display name matching a user in your organisation. Please do not click links or open attachments unless you recognise the source of this email and know the content is safe.

109https://github.com/pysal/mgwr/pull/109 implements an as_str return option to summary methods. @chrisg-ngishttps://github.com/chrisg-ngis does this meet your usage requirements?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/pysal/mgwr/issues/108#issuecomment-966461839, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AVULAN3FN3IVWJTJMOJJTUTULPYRDANCNFSM5HZREYEQ. Triage notifications on the go with GitHub Mobile for iOShttps://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Androidhttps://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

chrisg-ngis commented 3 years ago

Hi Ziqi,

You are right it is not a core delivery for your library. I think of it more as a tutorial on how to use it for image processes. Perhaps an article on medium.

I will have a think about how to ingest a raster.

Perhaps providing an option to ignore rows with values outside certain limits would make it easier to use by simplifying data cleaning. So if X or y contains a NaN or out of range result, then the output result is also Nan, but its doesn’t impact the other results? I am not sure if that is even possible.

Regards, Chris

From: Ziqi Li @.> Sent: Friday, 12 November 2021 1:49 AM To: pysal/mgwr @.> Cc: Chris Goodman @.>; Mention @.> Subject: Re: [pysal/mgwr] allow results.summary() to return a string or redirect (Issue #108)

This message was sent from outside the company by someone with a display name matching a user in your organisation. Please do not click links or open attachments unless you recognise the source of this email and know the content is safe.

Hi @chrisg-ngishttps://github.com/chrisg-ngis,

Thanks for the suggestion. However, data cleaning and preprocessing may be outside the scope of this package. I believe there should be methods available to convert a raster in rasterio to GeoDataFrame. If you have any standardised solution for demonstrating the process of feeding raster data to MGWR, please submit it as a pull request.

Cheers

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/pysal/mgwr/issues/108#issuecomment-966362844, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AVULAN7RE25IGEGXXSBX3WTULPJWXANCNFSM5HZREYEQ. Triage notifications on the go with GitHub Mobile for iOShttps://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Androidhttps://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.