pylusat.density module
- pylusat.density.of_point(input_gdf, point_gdf, pop_clm=None, search_radius=None, area_unit='square meters')
Calculate density of points in each input geometry.
- Parameters:
input_gdf (geopandas.GeoDataFrame) – Input GeoDataFrame in which points are counted.
point_gdf (geopandas.GeoDataFrame) – Point GeoDataFrame.
pop_clm (str) – Population column which contains values to represent each occurrence of the point feature.
search_radius (str, optional) – A string of buffering distance and unit, separated by space. e.g., “1 mile”.
area_unit (str, optional) – A string of the area unit used for density calculation. e.g., “square meters”.
- Returns:
output_sr – A pandas Series that contains the density of point in each input geometry of the input GeoDataFrame.
- Return type:
Examples
Calculate density of points (schools) in polygon layer (Alachua County census tracts) per square miles.
>>> pylusat.density.of_point(acs2016_gdf, schools_gdf, area_unit='square mile') 0 2.389447 1 0.000000 2 1.714565 3 4.974934 4 2.494981 ... 150 0.6607739 151 3.332871 152 0.967817 153 0.116269 154 1.140540
Calculate density of points (schools) in polygon layer (Alachua County census tracts) in square miles. Each occurrence of schools is represented by the enrollment column.
>>> pylusat.density.of_point(acs2016_gdf, schools_gdf, "ENROLLMENT", '1 mile', 'square mile') 0 0.000159 1 0.000252 2 0.000132 3 0.000117 4 0.000099 ... 150 0.000084 151 0.000114 152 0.000085 153 0.000031 154 0.000024
- pylusat.density.of_line(input_gdf, line_gdf, cellsize=30, search_radius=None, area_unit='square meters', geomtoarray=None)
Calculate density of line length in each input geometry.
- Parameters:
input_gdf (geopandas.GeoDataFrame) – Input GeoDataFrame in which length of lines are summed.
line_gdf (geopandas.GeoDataFrame) – Line GeoDataFrame whose lengths are summed.
cellsize (float, optional) – The cell size used to rasterize the line_gdf.
search_radius (str, optional) – A string of buffering distance and unit, separated by space. e.g., “1 mile”.
area_unit (str, optional) – A string of the area unit used for density calculation. e.g., “square meters”.
geomtoarray ({tuple of (numpy.ndarray, Affine, numpy.ndarray, float), None}) – The output of
rasterize_geometryfunction. If a desired output has already been created for the line_gdf has already been created, set it to be this argument to use it.
- Returns:
output_sr – A pandas Series that contains the density of line in each input geometry of the input GeoDataFrame.
- Return type:
Examples
Calculate density of lines (highway) per square mile in Alachua County census tract polygons.
>>> pylusat.density.of_line(acs2016_gdf, highway_gdf, search_radius='1 mile', area_unit='square mile') 0 0.000425 1 0.000705 2 0.000273 3 0.000753 4 0.000358 ... 150 0.000266 151 NaN 152 0.000277 153 NaN 154 0.000620