danioxoli / HotSpotAnalysis_Plugin

A QGIS plugin for hotspot analysis
GNU General Public License v3.0
55 stars 12 forks source link

Point G_Local with Fixed Distance Band parameter #9

Closed Ariel505 closed 5 years ago

Ariel505 commented 5 years ago

Hello Daniele,

I have a specific question regarding to Local Getis-Ord Gi test. I used my point based shapefile as input data, applied G_Local test and given fixed distance band: e.g: 5000 meter. And the result gave me several -inf (Z-score) and 0 (p-value). It would produce normal result perform the same analysis with ArcMap. So I was wondering was this is a bug in pysal or it is something to do with data value input itself? My test dataset can be found here: (please simply download the ZIP file) https://goo.gl/Vbb4m5 I used SUMME as input field, no optimized distance band was selected. Please let me know if this is something worth looking into, thanks.

Ariel

Ariel505 commented 5 years ago

Hi Daniele, Oh I just project my dataset into EPSG3587 coordinate system and tried again then it works. So it is input projection system WGS84 not working with degree minutes seconds unit. Cheers, Ariel

Ariel505 commented 5 years ago

Hi Daniele, I tried 5k and 3.5k two parameters and tried to compare result. It however shows contradict hotspot map compare to ArcMap.

First, the cold spot region in your plugin display hotspot in ArcMap. (with higher value). The hot spot region in your plugin display coldspot in ArcMap. (with negetive value).

Regarding to distance band, when I gave 5000 meters, it produce smaller hot/cold spot compared with 3500m. (95; 99%) In Arcmap it shows larger area with 5000 meters.

Would you please have a deeper look into these? Thank you very much. My e-mail: juiwen.chang@hcu-hamburg.de (In case you need further discussion)

Ariel

danioxoli commented 5 years ago

Dear Ariel,

You were right about the projection. Using points, the distance band is expressed in the same unit of measure of the input shapefile. Therefore you need to use a metric reference system to properly compute the statistics.

Actually, I was partially aware of the issue with the Gi. This is mainly due to the PySAL version of the statistics which is the original version of 1992 that was not supporting negative values. ArcGIS instead implements the 1996's version of the Gi that introduces normalization for including negative values in the computation. When using the PySAL version on negative values the result is what you saw.

I introduced some month ago a workaround that corrects the sign of the z-scores (p-values are ok). Probably, I mess up with some check in the code that makes the workaround not generally valid.

I made a correction. Please, try the plugin now by installing it from the zip file, if you are using QGIS3 (zip file QGIS3 here) instruction QGIS3 If you are using QGIS2, just unpack the repo master zip ( zip file QGIS2 here) in the system QGIS2 plugin folder. instruction QGIS2.

By using this latest code, I got the same results of ArcGIS as you can see in the picture

qgis arcgis

About the effect of the distance band, the results from the two software were the same. The 5k QGIS map and the 5k ArcGIS map were completely overlapped. The same using the 3.5k. Can you check if you were looking at the correct outputs?

Please, let me know if the fix I did works for you too.

Best,

Daniele

Ariel505 commented 5 years ago

Hi Daniele, Thank you very much to looking into this issue. Yes the problem is solved. I think you can upload the script into QGIS repository. Cheers, Ariel