pysal / libpysal

Core components of Python Spatial Analysis Library
http://pysal.org/libpysal
Other
264 stars 78 forks source link

How to import weight matrix generated by other software ? #462

Open ZHULOO opened 2 years ago

ZHULOO commented 2 years ago

How to import weight matrix generated by other software or manually ,Such as Stata or Excel (weight_matrix.dta of weight_matrix.csv)? or How to generate distance weight matrix from latitude and longitude data which just has only latitude and longtitude. I couldn't find a manual or anything close to that, Thank's a lot for your help.

ljwolf commented 2 years ago

Hi! So, depending on the format of the csv or dta, you can use pandas to read the graph in, and then use weights.from_adjlist() to interpret the table as a weights object.

I think that our built-in weights reader uses W.from_file(), but I don't think that supports arbitrary types.

If you post an example file, I can show you how to read it!