Geographic Information Systems Asked by Feyzi Bagirov on January 17, 2021
I have a data of a centroid and a count:
centroid population id
0 POINT(38.9081 77.0349) 9004.0 0
1 POINT(38.8521,77.0377) 517.0 1
2 POINT(38.9081 77.0377) 10369.0 2
...
The count is a count of the population within a 15km radius from the centroid.
I need to:
Here is my code:
import geopandas as gpd
import geopy
import geopy.distance
from shapely import wkt
from shapely.geometry import Point, LineString, Polygon
import pyproj
df['centroid'] = df['centroid'].apply(wkt.loads)
for i, r in df.iterrows():
a = gpd.GeoSeries(r.centroid, crs = 4326).to_crs(crs = 3857).buffer(15000)
df_dropped = df.drop(i, axis = 0)
l1 = [] # an empty list to collect intersections
for j, s in df_dropped.iterrows():
b = gpd.GeoSeries(s.centroid, crs = 4326).to_crs(crs = 3857).buffer(15000)
tf = a.intersects(b)
l1.append(tf)
print(l1)
My idea is to get the list populated with intersections with the other circles (True) and then use their indexes to subtract those buffered centroids from the initial buffered centroid to get the semi-moon for the original buffered centroid. If there are more than 1 intersect, then I would subtract it from the previous result, etc., until there are no more intersects. I would then calculate the population for that shape.
What would be the code to achieve that?
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP