geopandas

How to change the text of the legend of a choropleth map in Python?

跟風遠走 提交于 2019-12-07 07:55:15
问题 I get one choropleth map using the following code: %matplotlib inline import seaborn as sns import pandas as pd import pysal as ps import geopandas as gpd import numpy as np import matplotlib.pyplot as pet imd_shp = 'desktop/sgfwu/E07000222_IMD/shapefiles/E07000222.shp' imd = gpd.read_file(imd_shp) imd = imd.set_index('LSOA11CD') imd.plot(column='imd_score', scheme='fisher_jenks', alpha=0.8, k=7, colormap=plt.cm.Blues, legend=True, axes=ax1) The result is: But how can I change the text of the

RuntimeError: b'no arguments in initialization list'

雨燕双飞 提交于 2019-12-07 07:32:54
问题 I'm trying to solve my issue in my own but I couldn't, I'm trying to run this code in every format you can imagine and in ArcGIS pro software it's the same I can't find this error message in any other issue. From similar issues, it seems some data files could be missing? import geopandas as gpd import json import numpy as np from shapely.geometry import LineString, Point, box import ast from pyproj import Proj paths = road_features.SHAPE.map(lambda x: np.array(ast.literal_eval(x)["paths"][0])

Shapely Split LineStrings at Intersections with other LineStrings

本秂侑毒 提交于 2019-12-07 06:41:37
问题 I have a set of LineStrings which are intersected by other LineStrings and I want to split the LineString into separate segments at these intersection points. I have a solution but I don't think it's the best approach. Let's say we are dealing with one LineString: >>> import shapely >>> from shapely.geometry import * >>> import geopandas as gpd >>> >>> MyLine=LineString([(0,0),(5,0),(10,3)]) >>> MyLine <shapely.geometry.linestring.LineString object at 0x1277EEB0> >>> And 2 lines that

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

☆樱花仙子☆ 提交于 2019-12-07 00:40:54
问题 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

b'Recode from ANSI 1252 to UTF-8 failed with the error: “Invalid argument”.' geopandas python

為{幸葍}努か 提交于 2019-12-07 00:23:01
问题 I am trying to read in a shapefile into a GeoDataFrame. Normally I just do this and it works: import pandas as pd import geopandas as gpd from shapely.geometry import Point df = gpd.read_file("wild_fires/nbac_2016_r2_20170707_1114.shp") But this time it gives me the error: b'Recode from ANSI 1252 to UTF-8 failed with the error: "Invalid argument".' Full error: --------------------------------------------------------------------------- CPLE_AppDefinedError Traceback (most recent call last)

Converting a column of Polygons from string to GeoPandas geometry

左心房为你撑大大i 提交于 2019-12-06 12:14:52
问题 I have a dataframe stored as csv file, one column of which is Polygon object. However, this column is stored as strings instead of GeoPandas geometry object. How can I convert this column to Geopandas geometry object so that I can perform geo analysis? This is how my data looks like my_df['geometry'].head() 0 POLYGON ((-122.419942 37.809021, -122.419938 3... 1 POLYGON ((-122.419942 37.809021, -122.419938 3... 2 POLYGON ((-122.419942 37.809021, -122.419938 3... 3 POLYGON ((-122.419942 37

Change single patch color in geopandas

风流意气都作罢 提交于 2019-12-06 08:42:01
Using this map of NYC I'd like to change Manhattan to be bright blue. But when I change the individual patch color of Manhattan all the other patch colors change too. This was unexpected to me. How do you change the color of one individual patch? from matplotlib import pyplot as plt import geopandas as gpd nybb = gpd.GeoDataFrame.from_file('nybb.shp') nybb_plot = nybb.plot() for p_ny in nybb_plot.patches: p_ny.set_color("#111111") p_ny.set_alpha(0.6) for line in nybb_plot.lines: line.set_linewidth(0.25) line.set_alpha(0.9) line.set_color("#d3d3d3") manhattan = nybb.loc[nybb.BoroName ==

RuntimeError: b'no arguments in initialization list'

可紊 提交于 2019-12-05 11:48:36
I'm trying to solve my issue in my own but I couldn't, I'm trying to run this code in every format you can imagine and in ArcGIS pro software it's the same I can't find this error message in any other issue. From similar issues, it seems some data files could be missing? import geopandas as gpd import json import numpy as np from shapely.geometry import LineString, Point, box import ast from pyproj import Proj paths = road_features.SHAPE.map(lambda x: np.array(ast.literal_eval(x)["paths"][0])) pathLineStrings = paths.map(LineString) gdf = gpd.GeoDataFrame(road_features,geometry=pathLineStrings

Shapely Split LineStrings at Intersections with other LineStrings

和自甴很熟 提交于 2019-12-05 09:52:31
I have a set of LineStrings which are intersected by other LineStrings and I want to split the LineString into separate segments at these intersection points. I have a solution but I don't think it's the best approach. Let's say we are dealing with one LineString: >>> import shapely >>> from shapely.geometry import * >>> import geopandas as gpd >>> >>> MyLine=LineString([(0,0),(5,0),(10,3)]) >>> MyLine <shapely.geometry.linestring.LineString object at 0x1277EEB0> >>> And 2 lines that intersect this LineString: >>> IntersectionLines=gpd.GeoSeries([LineString([(2,1.5),(3,-.5)]), LineString([(5,

b'Recode from ANSI 1252 to UTF-8 failed with the error: “Invalid argument”.' geopandas python

喜夏-厌秋 提交于 2019-12-05 06:40:18
I am trying to read in a shapefile into a GeoDataFrame. Normally I just do this and it works: import pandas as pd import geopandas as gpd from shapely.geometry import Point df = gpd.read_file("wild_fires/nbac_2016_r2_20170707_1114.shp") But this time it gives me the error: b'Recode from ANSI 1252 to UTF-8 failed with the error: "Invalid argument".' Full error: --------------------------------------------------------------------------- CPLE_AppDefinedError Traceback (most recent call last) <ipython-input-14-adcad0275d30> in <module>() ----> 1 df_wildfires_2016 = gpd.read_file("wild_fires/nbac