geopandas

How can I set a special colour for `Nan`s in my plot?

一曲冷凌霜 提交于 2020-01-25 20:54:07
问题 Here is a sample of the data I am trying to visualize Prince Edward Island 2.333 Manitoba 2.529 Alberta 2.6444 British Columbia 2.7902 Saskatchewan 2.9205 Ontario 3.465 New Brunswick 3.63175 Newfoundland and Labrador 3.647 Nova Scotia 4.25333333333 Quebec 4.82614285714 Nunavut NaN Yukon NaN Northwest Territories NaN I want to visualize the data by colouring each province according to the number it is associated with. When I do this, the Nan's are coloured like the minimum value of the

How to plot one polygon on top of another polygon with geopandas

蹲街弑〆低调 提交于 2020-01-25 07:32:19
问题 I was trying to compare the size of two polygons by plotting them in one figure. For example, I want to put Kansas on top of Texas. however, because the two polygons share the same CRS, so when I was trying to plot them in one figure, they are separated with each one stay at their positions based on the CRS. I was wondering how to change my code (see below) to let Kansas (polygon) stay in Texas (polygon). Thanks. kansas = gpd.read_file("kansas.shp") texas = gpd.read_file("texas.shp") ax =

Convert the coordinates of a shapefile in Geopandas

江枫思渺然 提交于 2020-01-23 17:40:26
问题 I am new at spatial analysis, but I cant find this answer anywhere. I have a list of post codes in CRS coordinates, latitude and longitude, and London's Boroughs shape file in OSN coordinates, and I would like to map them together, but this is what happens. This is the head of the postcodes london_post_codes.head() Out[81]: postcode latitude longitude 0 WD6 1GS 51.658021 -0.255663 1 WD17 1LA 51.660366 -0.397525 2 WC2N 6LE 51.509413 -0.121676 3 WC2N 6NA 51.508363 -0.124454 4 WC2N 6ND 51.508216

Convert the coordinates of a shapefile in Geopandas

你。 提交于 2020-01-23 17:40:06
问题 I am new at spatial analysis, but I cant find this answer anywhere. I have a list of post codes in CRS coordinates, latitude and longitude, and London's Boroughs shape file in OSN coordinates, and I would like to map them together, but this is what happens. This is the head of the postcodes london_post_codes.head() Out[81]: postcode latitude longitude 0 WD6 1GS 51.658021 -0.255663 1 WD17 1LA 51.660366 -0.397525 2 WC2N 6LE 51.509413 -0.121676 3 WC2N 6NA 51.508363 -0.124454 4 WC2N 6ND 51.508216

Generating Legend for geopandas plot

此生再无相见时 提交于 2020-01-16 19:06:50
问题 I am plotting a shape file with Geopandas. Additionally im Adding Points of a dataframe (see picture). Now im trying to add a legend (at the right of the original plot) for the point. I dont really know how to do that! Plot import pandas as pd import numpy as np import matplotlib.pyplot as plt import geopandas as gpd import test variable = 'RTD_rtd' df = test.getdataframe() gdf = gpd.GeoDataFrame( df, geometry=gpd.points_from_xy(df.NP_LongDegree, df.NP_LatDegree)) fp = "xxx" map_df = gpd.read

Generating Legend for geopandas plot

天大地大妈咪最大 提交于 2020-01-16 19:06:46
问题 I am plotting a shape file with Geopandas. Additionally im Adding Points of a dataframe (see picture). Now im trying to add a legend (at the right of the original plot) for the point. I dont really know how to do that! Plot import pandas as pd import numpy as np import matplotlib.pyplot as plt import geopandas as gpd import test variable = 'RTD_rtd' df = test.getdataframe() gdf = gpd.GeoDataFrame( df, geometry=gpd.points_from_xy(df.NP_LongDegree, df.NP_LatDegree)) fp = "xxx" map_df = gpd.read

How to create an accurate buffer of 5 miles around a coordinate in python?

萝らか妹 提交于 2020-01-15 03:21:10
问题 I would like to create an accurate buffer of 5 miles around a coordinate, my current code is: cpr_gdf['p_buffer']=cpr_gdf['coordinates'].buffer(5*(1/60)) The coordinates column was created with this code: cpr_df['coordinates']=list(zip(cpr_df.sample_longitude_decimal,cpr_df.sample_latitude_decimal)) cpr_df['coordinates']=cpr_df['coordinates'].apply(Point) cpr_gdf=gpd.GeoDataFrame(cpr_df,geometry='coordinates',crs={'init' :'epsg:4326'}) Thanks for any help! 回答1: You need to convert to an equal

Change single patch color in geopandas

邮差的信 提交于 2020-01-02 11:02:18
问题 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

Change single patch color in geopandas

北城以北 提交于 2020-01-02 11:01:22
问题 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

Change single patch color in geopandas

流过昼夜 提交于 2020-01-02 11:01:06
问题 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