GIS4DEV / GIS4DEV.github.io

Open Source GIScience & GIS for Development
1 stars 12 forks source link

Distance matrix not working with actual data #24

Closed jackson-mumper closed 3 years ago

jackson-mumper commented 3 years ago

Hi all!

I'm currently trying to run the gravity model on New England towns with my prepared hospitals layer, and I'm running into an error with the distance matrix. It keeps telling me:

featList = index.nearestNeighbor(inGeom.asPoint(), nPoints) ValueError: Null geometry cannot be converted to a point. Error encountered while running Distance matrix

Has anyone encountered this issue? The models works fine with the VT data and the centroids on their own seem to be working properly so I'm not sure where it's going wrong.

Thanks!

mtango99 commented 3 years ago

Is there any way you can filter out the rows with null geometries? Maybe null geometries correspond to some null values in the attribute table?


From: Jackson M notifications@github.com Sent: Saturday, March 6, 2021 9:37:59 PM To: GIS4DEV/GIS4DEV.github.io GIS4DEV.github.io@noreply.github.com Cc: Subscribed subscribed@noreply.github.com Subject: [GIS4DEV/GIS4DEV.github.io] Distance matrix not working with actual data (#24)

Hi all!

I'm currently trying to run the gravity model on New England towns with my prepared hospitals layer, and I'm running into an error with the distance matrix. It keeps telling me:

featList = index.nearestNeighbor(inGeom.asPoint(), nPoints) ValueError: Null geometry cannot be converted to a point. Error encountered while running Distance matrix

Has anyone encountered this issue? The models works fine with the VT data and the centroids on their own seem to be working properly so I'm not sure where it's going wrong.

Thanks!

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://github.com/GIS4DEV/GIS4DEV.github.io/issues/24, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AOZTNMLFUKZ7QCTLI52DZVDTCLRIPANCNFSM4YXLSHNA.

sanjana-roy commented 3 years ago

I had the same issue. The null geometries match some places in the middle of the ocean that don't seem to exist i.e. there actually aren't any geometries there. You would have to allow for only weights greater than 0 to be selected from the very beginning.

josephholler commented 3 years ago

Yes, Sanjana is correct. I didn't notice this problem because I had filtered for weights greater than 0 at the beginning of my model. The null geometries also all have 0 population. The field calculator function num_geometries($geometry) can tell you how many geometry parts each town has, and there is a small batch with 0 parts and 0 people. Also, there is a remove null geometries tool which could be handy in a situation such as this.