Questions tagged [pysal]

Pysal is a spatial analysis library written in Python. It provides a variety of functions for interpreting common spatial data file formats and performing common analyses on them, with the goal of being easy to providing core functionality that is easier to integrate into higher level projects.

Pysal is an open-source library of spatial data analysis tools written in Python. It is able to read a variety of common data file formats such as shapefiles, DBF, CSV, WKT, GeoDa, GAL, GWT, and files from popular programs such as ArcGIS, MATLAB, and Stata. It provides functions for assessing autocorrelation, spatial econometrics, analyzing spatial data over time and more.

68 questions
6
votes
2 answers

format/round numerical legend label in GeoPandas

I'm looking for a way to format/round the numerical legend labels in those maps produced by .plot() function in GeoPandas. For example: gdf.plot(column='pop2010', scheme='QUANTILES', k=4) This gives me a legend with many decimal places: I want the…
steven
  • 2,130
  • 19
  • 38
6
votes
1 answer

Optimize scipy nearest neighbor search

I am trying to find all the nearest neighbors which are within 1 KM radius. Here is my script to construct tree and search the nearest points, from pysal.cg.kdtree import KDTree def construct_tree(s): data_geopoints = [tuple(x) for x in…
ds_user
  • 2,139
  • 4
  • 36
  • 71
5
votes
1 answer

Pysal: how to do cross validation with pysal regression models?

I am using pysal to to spatial regression. This what I am doing. I first divided training and validation sets import pysal as ps m_train = ps.model.spreg.GM_Lag(ytrain, xtrain, w=w_train, spat_diag=True) How can I use the coefficients of m_train to…
emax
  • 6,965
  • 19
  • 74
  • 141
5
votes
2 answers

Finding 1st order neighbors using shapefile polygons

I am looking a efficient way to find the 1st order neighbors of a given polygon. My data are in shapefile format. My first idea was to calculate the x and y coordinates of the polygons' centroids in order to find the neighbor's centroids. import…
Gianni Spear
  • 7,033
  • 22
  • 82
  • 131
4
votes
0 answers

How to fix "TypeError: must be real number, not str" error?

I keep on getting this error. My data is formatted correctly, but I just can't get it to create a KDTree. I have one data set, let's call it A, and another data set, let's call it B. Both sets have many latitude and longitude coordinates. I want to…
Naiem
  • 71
  • 1
  • 5
4
votes
1 answer

Geoplot won't plot geopandas object

I imported a shapefile with Wisconsin counties using geopandas and each county's vote margin for a previous election. I am now trying to partition the state of Wisconsin into neighborhoods using a Voronoi tessellation of the vote share of each…
rytse
  • 133
  • 1
  • 10
4
votes
3 answers

How to plot two maps side by side using pysal or geopandas?

I want to plot two tematic maps side by side to compare then. I am using geopandas to plot the maps and pysal to generate the maps from spatial analysis.
Oalvinegro
  • 458
  • 5
  • 21
4
votes
1 answer

python: pysal explanation of weight function

I have a 2D array of values and I'm trying to analyze spatial correlations. To calculate a 2D autocorrelation like Moran's I in python, pysal provides an implementation. 1) How do I transform my 2D data into a 1D array expected by pysal? 2) How do…
user3450049
  • 825
  • 1
  • 10
  • 20
4
votes
0 answers

pysal AssertionError terminator == '\r'

I am trying to convert a .dbf file to a pandas.DataFrame. However, I am getting an error from the following line of code: dbf = ps.open(dbf_link) File "/Users/UserName/anaconda/lib/python2.7/site-packages/pysal/core/IOHandlers/pyDbfIO.py", line…
Mantis
  • 1,357
  • 3
  • 27
  • 49
4
votes
2 answers

OLS Breusch Pagan test in Python

I used the statsmodels package to estimate my OLS regression. Now I want Breusch Pagan test. I used the pysal package for this test but this function returns an error: import statsmodels.api as sm import pysal model = sm.OLS(Y,X,missing =…
Eghbal
  • 3,892
  • 13
  • 51
  • 112
3
votes
0 answers

How to obtain a correlogram using Moran's I values at different lag distances

I am new to calculating these values and am having a hard time figuring out how to calculate a (global?) Moran's I value for an increasing neighbour distance between points. Specifically, I'm not really sure how to set this lag/neighbour distance so…
3
votes
1 answer

Calculating Moran's I with PySal?

For an assignment at Uni we have to use PySal to calculate Moran's I. I have found an examplar code and am going from that but I am getting the error message "'file' object has no attribute 'by_col'" Any Ideas would be much appreciated. The dataset…
3
votes
1 answer

Can't set units of distance in pysal

New to Pysal and just getting to grips with loading, reading etc. I have some test point data, in Decimal Degrees (WGS84) and want to use the get_point_dist function. After running it, I get the correct response but would like the distance in…
user965586
  • 563
  • 5
  • 22
2
votes
1 answer

install `pysal` but get error report: `ERROR: No .egg-info directory found in C:\users\xxxx\AppData\Local\Temp\pip-pip-egg-info-ygsexy4a`

Trying to install pysal, (Python Spatial Analysis Library), but get the error report. I have searched and read lots of answers, most of the solutions are upgrade setuptools. But I have tried and nothing changed. I tried to reinstall pandas with pip,…
2
votes
1 answer

Pysal does not have attribute open

Hi I am using Anaconda with Python 3.7 and I have imported Pysal to my environment. Now I am trying to import a dataset and open it with pysal, to my surprise it appears that pysal does not have attribute open... import pysal as ps import libpysal…
ryszard eggink
  • 315
  • 3
  • 14
1
2 3 4 5