geopandas

RTree: Count points in the neighbourhoods within each point of another set of points

梦想的初衷 提交于 2019-12-05 04:23:18
Why is this not returning a count of number of points in each neighbourhoods (bounding box)? import geopandas as gpd def radius(points_neighbour, points_center, new_field_name, r): """ :param points_neighbour: :param points_center: :param new_field_name: new field_name attached to points_center :param r: radius around points_center :return: """ sindex = points_neighbour.sindex pts_in_neighbour = [] for i, pt_center in points_center.iterrows(): nearest_index = list(sindex.intersection((pt_center.LATITUDE-r, pt_center.LONGITUDE-r, pt_center.LATITUDE+r, pt_center.LONGITUDE+r))) pts_in_this

GeoPandas Set CRS on Points

大兔子大兔子 提交于 2019-12-05 02:32:26
Given the following GeoDataFrame: h=pd.DataFrame({'zip':[19152,19047], 'Lat':[40.058841,40.202162], 'Lon':[-75.042164,-74.924594]}) crs='none' geometry = [Point(xy) for xy in zip(h.Lon, h.Lat)] hg = GeoDataFrame(h, crs=crs, geometry=geometry) hg Lat Lon zip geometry 0 40.058841 -75.042164 19152 POINT (-75.042164 40.058841) 1 40.202162 -74.924594 19047 POINT (-74.924594 40.202162) I need to set the CRS as I did with another GeoDataFrame (like this): c=c.to_crs("+init=epsg:3857 +ellps=GRS80 +datum=GGRS87 +units=mi +no_defs") I've tried this: crs={'init': 'epsg:3857'} and this: hg=hg.to_crs("

Plotting a map using geopandas and matplotlib

吃可爱长大的小学妹 提交于 2019-12-05 01:53:25
问题 I have small csv that has 6 coordinates from Birmingham England. I read the csv with pandas then transformed it into GeoPandas DataFrame changing my latitude and longitude columns with Shapely Points. I am now trying to plot my GeoDataframe and all I can see are the points. How do I get the Birmingham map represented as well? A good documentation source on GeoPandas would be strongly appreciated too. from shapely.geometry import Point import geopandas as gpd import pandas as pd df = pd.read

centos libgeos repository missing

百般思念 提交于 2019-12-04 03:31:24
问题 On centos 7.3 minimal trying to install shapely or geopandas requires access to https://github.com/libgeos/libgeos libgeos. Trying to install this via sudo yum install libgeos-dev tells me that this package is not available. It seems that I am lacking a repository. So far I have been unable to find a working one as http://trac.osgeo.org/geos is pointing to https://yum.postgresql.org/repopackages.php#pg96 for the RPM but still after rpm -Uvh https://download.postgresql.org/pub/repos/yum/9.6

Cannot import Geopandas with PyInstaller executable - despite running fine in the virtual env

穿精又带淫゛_ 提交于 2019-12-04 02:38:41
问题 When my Python application frozen with PyInstaller attempts to import Geopandas, it stops working. Windows 10 PyInstaller 3.3.1 Geopandas 0.4 Here is the source code: print("Hello, StackOverflow") import geopandas as gpd Here is the resulting console output of the compiled EXE: Hello, StackOverflow Traceback (most recent call last): File "application.py", line 3, in <module> File "<frozen importlib._bootstrap>", line 971, in _find_and_load File "<frozen importlib._bootstrap>", line 955, in

Plotting a map using geopandas and matplotlib

时光总嘲笑我的痴心妄想 提交于 2019-12-03 17:24:05
I have small csv that has 6 coordinates from Birmingham England. I read the csv with pandas then transformed it into GeoPandas DataFrame changing my latitude and longitude columns with Shapely Points. I am now trying to plot my GeoDataframe and all I can see are the points. How do I get the Birmingham map represented as well? A good documentation source on GeoPandas would be strongly appreciated too. from shapely.geometry import Point import geopandas as gpd import pandas as pd df = pd.read_csv('SiteLocation.csv') df['Coordinates'] = list(zip(df.LONG, df.LAT)) df['Coordinates'] = df[

Calculate Distance to Nearest Feature with Geopandas

偶尔善良 提交于 2019-12-03 13:29:01
问题 I'm looking to do the equivalent of the ArcPy Generate Near Table using Geopandas / Shapely. I'm very new to Geopandas and Shapely and have developed a methodology that works, but I'm wondering if there is a more efficient way of doing it. I have two point file datasets - Census Block Centroids and restaurants. I'm looking to find, for each Census Block centroid, the distance to it's closest restaurant. There are no restrictions in terms of same restaurant being the closest restaurant for

GeoPandas, MatPlotLib Plot Custom Colors

[亡魂溺海] 提交于 2019-12-03 08:23:42
Given the shape file available here : I'd like to plot the specified set of counties below with custom colors; 'blue' for Wayne and Washtenaw counties and 'grey' for the others. import geopandas as gpd import matplotlib.pyplot as plt %matplotlib inline shpfile=<Path to unzipped .shp file referenced and linked above> c=gpd.read_file(shpfile) c=c.loc[c['GEOID'].isin(['26161','26093','26049','26091','26075','26125','26163','26099','26115','26065'])] c.plot() I'd prefer to assign the colors as a column in the data frame first, then invoke them when plotting somehow. Is this possible? UPDATE I've

geopandas point in polygon

你说的曾经没有我的故事 提交于 2019-12-03 07:34:30
问题 I have a GeoDataFrame of polygons (~30) and a GeoDataFrame of Points (~10k) I'm looking to create 30 new columns (with appropriate polygon names) in my GeoDataFrame of Points with a simple boolean True/False if the point is present in the polygon. As an example, the GeoDataFrame of Polygons is this: id geometry foo POLYGON ((-0.18353,51.51022, -0.18421,51.50767, -0.18253,51.50744, -0.1794,51.50914)) bar POLYGON ((-0.17003,51.50739, -0.16904,51.50604, -0.16488,51.50615, -0.1613,51.5091)) The

Calculate Distance to Nearest Feature with Geopandas

纵饮孤独 提交于 2019-12-03 06:33:16
I'm looking to do the equivalent of the ArcPy Generate Near Table using Geopandas / Shapely. I'm very new to Geopandas and Shapely and have developed a methodology that works, but I'm wondering if there is a more efficient way of doing it. I have two point file datasets - Census Block Centroids and restaurants. I'm looking to find, for each Census Block centroid, the distance to it's closest restaurant. There are no restrictions in terms of same restaurant being the closest restaurant for multiple blocks. The reason this becomes a bit more complicated for me is because the Geopandas Distance