geopandas

How to plot a shapefile in matplotlib

How to plot a shapefile in matplotlib Question: I have a question regarding plotting a polygon shapefile in matplotlib. The data I am working with is available here (the zip file called Delmarva_PL_House_Final.zip). The polygons coordinates are UTM 18N. After importing it into geopandas and changing the crs as such: df = df.to_crs(epsg=4326) I went …

Total answers: 1

Load / Plot geopandas dataframe with GeometryCollection column

Load / Plot geopandas dataframe with GeometryCollection column Question: I have a dataset like this: You can reproduce this dataframe loading the following dict: {‘entity_ts’: {0: ‘2022-11-01T00:00:56.000Z’, 1: ‘2022-11-01T00:00:56.000Z’}, ‘entity_id’: {0: ‘WAZE.jams.1172133072’, 1: ‘WAZE.jams.1284082818’}, ‘street’: {0: ‘Ac. Monsanto, Benfica’, 1: nan}, ‘position’: {0: {‘type’: ‘GeometryCollection’, ‘geometries’: [{‘coordinates’: [[[-9.168816, 38.741779], [-9.169618, 38.741353], [-9.16976, 38.741289]]], ‘type’: ‘MultiLineString’}]}, …

Total answers: 1

Change the shape of legend markers with geopandas.geodataframe.plot

Change the shape of legend markers with geopandas.geodataframe.plot Question: I like the convenience of the following syntax to make maps: import geopandas world = geopandas.read_file(geopandas.datasets.get_path(‘naturalearth_lowres’)) world.plot(column=’continent’,legend=True,legend_kwds = {‘loc’:’lower left’}) However, I am looking for a way to change the shape of markers that this produces. By default (with a non-continuous variable), geopandas (or matplotlib) produces …

Total answers: 1

How to extract individual points from the shapely Multipoint data type?

How to extract individual points from the shapely Multipoint data type? Question: I am using shapely2.0; somehow, I can’t iterate through individual points in the MULTIPOINT data type in this version. I wanted to extract and plot individual points from the MULTIPOINT. The MULTIPOINT is obtained from line.intersection(circle_boundary), where I tried to get the intersection …

Total answers: 1

How would you use Dask to recursively find neighbouring polygons in a Dask.Geodataframe?

How would you use Dask to recursively find neighbouring polygons in a Dask.Geodataframe? Question: I am new to Dask. I’ve been trying to get it to do the following task: I have two geodataframes and a set: # Main chunk and combined chunk are a list of polygons of tessellated cells main_chunk = gpd.read_parquet(f"./out/singapore/tess_chunk_{int(n1)}.pq") combined_chunks …

Total answers: 1

How to fix the scale of several choropleth maps?

How to fix the scale of several choropleth maps? Question: I am creating multiple choropleth maps for different time frames (because I want to do a gif) and wondering if there is any way to fix the scale for each map to do easy visual comparison ? My current code is as follows years = …

Total answers: 1

Highlight polygons that share a side/edge

Highlight polygons that share a side/edge Question: How do I create a… —I don’t know; list, dict of all the polygons, in a GeoDataFrame, that share a side/edge. The polygons will intersect but never cross. import geopandas as gpd from shapely.geometry import Polygon import matplotlib.pyplot as plt polys = gpd.GeoSeries([Polygon([(0,0), (2,0), (2, 1.5), (2,2), (0,2)]), …

Total answers: 3

Plotting points on Australia Map in Python

Plotting points on Australia Map in Python Question: I have the following pandas df import geopandas as gpd import pandas as pd import numpy as np import matplotlib.pyplot as plt import seaborn as sns # Define the list of cities and their latitudes/longitudes cities = [‘Sydney’, ‘Melbourne’, ‘Brisbane’, ‘Perth’, ‘Adelaide’, ‘Gold Coast’, ‘Newcastle’, ‘Canberra’, ‘Wollongong’, …

Total answers: 1

How can I solve this "IndexError: index 774 is out of bounds for axis 0 with size 724"?

How can I solve this "IndexError: index 774 is out of bounds for axis 0 with size 724"? Question: Code: import geopandas as gpd import rasterio as rio capital_cities = gpd.read_file(r’C:UsersuserDesktopSHPBangladesh_shapefile_Feature.shp’) capital_cities[‘Temp’]=0 for index, row in capital_cities.iterrows() : city= row[‘DISTNAME’] longitude=row[‘geometry’].x latitude=row[‘geometry’].y temp_raster = rio.open(r’C:UsersuserDesktopOutput rasterc2019GDP_Clip.tif’) temp_data = temp_raster.read(1) rowIndex, colIndex = temp_raster.index(longitude, latitude) print(city …

Total answers: 1

Sort station names after countries and save them as csv

Sort station names after countries and save them as csv Question: How can I sort a list of geographical coordinates into different lists based on the country and save each list as a separate CSV file? Koforidua_ANUC,6.109N,0.302W Kuching,1.491N,110.349E Kuopio,62.892N,27.634E Kuwait_University,29.325N,47.971E Edit: The comments from tripleee were helpful Is it possible to add regional mountain ranges …

Total answers: 1