danioxoli / HotSpotAnalysis_Plugin

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

Error message: "TypeError: float() argument must be a string or a number, not 'Chain'" #18

Closed LuchinoB closed 5 years ago

LuchinoB commented 5 years ago

Hi there,

I've successfully downloaded and installed HotspotAnalysis plugin on my QGIS 3.2.3, but as soon as I launch the plugin I get this python message:

TypeError: float() argument must be a string or a number, not 'Chain'

As I was saying, during the installation process I didn't get any error messages in both OSGeo4W Shell and QGIS... can you help me? Thanks,

Luca

danioxoli commented 5 years ago

Dear Luca,

Could you please provide me with the full text of the error message (you can look for it inside the QGIS Python console).

I will try to check in deep which is the problem. Now, it looks like an error on the input layer or parameter used.

Best,

Daniele

LuchinoB commented 5 years ago

Hi Daniele, you can find the entire string below (thanks in advance!):

018-11-09T12:40:27 WARNING Traceback (most recent call last): File "C:/Users/Luca-B/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\HotspotAnalysis\hotspot_analysis.py", line 551, in run self.load_comboBox() File "C:/Users/Luca-B/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\HotspotAnalysis\hotspot_analysis.py", line 472, in load_comboBox thresh = pysal.min_threshold_dist_from_shapefile(path) File "C:\PROGRA~1\QGIS3~1.2\apps\Python36\lib\site-packages\pysal\weights\user.py", line 1085, in min_threshold_dist_from_shapefile return min_threshold_distance(points, p) File "C:\PROGRA~1\QGIS3~1.2\apps\Python36\lib\site-packages\pysal\weights\util.py", line 1142, in min_threshold_distance kd = KDTree(data) File "C:\PROGRA~1\QGIS3~1.2\apps\Python36\lib\site-packages\pysal\cg\kdtree.py", line 54, in KDTree return scipy.spatial.cKDTree(data, leafsize) File "scipy\spatial\ckdtree.pyx", line 531, in scipy.spatial.ckdtree.cKDTree.init (scipy\spatial\ckdtree.cxx:5496) File "C:\PROGRA~1\QGIS3~1.2\apps\Python36\lib\site-packages\numpy\core\numeric.py", line 620, in ascontiguousarray return array(a, dtype, copy=False, order='C', ndmin=1) TypeError: float() argument must be a string or a number, not 'Chain'

danioxoli commented 5 years ago

This is definitely due to the input file you are using. Please, remind that to run the analysis you need:

1) a shapefile (no text layers can be used) 2) shapefile must be of points or polygons (no lines layer can be used) 3) the shapefile needs to have at least a numeric attribute assigned to each geometry (no attribute coming from e.g. a join operation are valid, no holes in data are handled)

Is the above describing exactly the input data you are using?

Let me know!

Daniele

LuchinoB commented 5 years ago

Ok, I guess I've fixed the error removing all the line-shapes uploaded in QGIS and leaving there only the point-shape: seems definetely to work now! Thx a lot,

Luca

LuchinoB commented 5 years ago

One last thing: to avoid crashes I had to convert my shape SR (it was EPSG:3003) in a EPSG:4326.

danioxoli commented 5 years ago

Yes, actually if you have a line shapefile as the first layer in the layer list this might produce the error. I am aware of, it's in the (long) to-do list!

About the SR: This is really strange! Actually, it should be the contary. If you use point layers you need to have a projected coordinate system to get distances in meters (3003 should work!). If you use geographic one (as 4326) distances need to be considered in arc and the plugin has not conversions capabilites to perform them.

I suggest to set always a projected coordinate system like WGS84-UTM in order to avoid any problem.

Daniele

LuchinoB commented 5 years ago

Yeah, I was wrong with coordinates, now also EPSG3003 works well!