7

A generator is not subscriptable and iterRecords() returns a generator. Instead, use shapeRecords() (or records()). It gives you a list. rows = shapefile.Reader(shapefile_path).shapeRecords()[0:100] for row_num, row in enumerate(rows): print(row_num, row)


5

As I mentioned in the comments, your post here is bit difficult to work through; and to me, it's doing what I'm expecting: namely, buffering a point (-120, 40) by 10 results in the appropriately sized Polygon form (-130 to -110, 30 to 50). However, I think I understand what your confusion is. You're setting the coordinate system here: elines = elines.set_crs(...


5

You can store each GeoDataFrame in a list or a generator to avoid any memory issue. import glob import geopandas as gpd files = glob.iglob('E:/folder/*.shp') gdfs = (gpd.read_file(file) for file in files) # generator # A list is an option for small files # gdfs = [gpd.read_file(file) for file in files] for gdf in gdfs: # clip stuffs Or import glob ...


4

How about using zip: import geopandas as gpd import os frames = [gpd.read_file(r'C:\GIS\data\testdata\ak_riks.shp'), gpd.read_file(r"C:\GIS\data\testdata\ak_riks_2.shp")] names = ['r1.shp','r2.shp'] outfolder = r'C:\GIS\data\testdata' for frame, name in zip(frames, names): frame.to_file(os.path.join(outfolder, name))


4

for gdf in gdfs: gdf.crs = "EPSG:6668" Or for i in range(len(gdfs)): gdfs[i].crs = "EPSG:6668"


3

Geopandas is included with Python for ArcGIS Pro. See the image below. Maybe you have cloned your environment but your Python environment defaulted back to the walled garden version for some reason?


2

You already have the geometry as a shapely multipolygon/list of polygons. Add it directly to the geodataframe. gdf3 = gpd.GeoDataFrame(geometry=[finalpol]) # Note GeoDataFrame geometry requires a list gdf3.to_file(filename='dPolygons.shp', driver='ESRI Shapefile') # Or gdf3 = gpd.GeoDataFrame(geometry=outmulti) # outmulti is already a list gdf3.to_file(...


2

A list comprehension is very Python. clipped = [gpd.clip(s, boundary) for s in shapefiles] But often it's easier and more flexible to loop, especially if there are clip polygons for each shapefile. Let's say clip_bounds contains a list of clip bounds in the same order as the shapefile list: shapefiles = glob.iglob('E:/folder/shapefiles/*.shp') for file, ...


2

Create points, buffer, dissolve: import geopandas as gpd import pandas as pd from shapely import wkt df = pd.read_csv(r'/home/bera/Downloads/gdf.csv') df['geom'] = df['geometry'].apply(lambda x: wkt.loads(x)) gdf = gpd.GeoDataFrame(df, geometry=df['geom']) gdf.crs = "EPSG:3857" gdf.geometry = gdf.buffer(distance=0.008) gdf = gdf.dissolve(by='ur') ...


2

Geopandas 0.7 added a new rows parameter to read_file. You can use it to read the first n rows, or a specific slice or rows. import geopandas as gpd # Read the first 100 rows gdf = gpd.read_file("/path/to/my/shapefile.shp", rows=100) # Read the 5 rows from the 100000th gdf = gpd.read_file("/path/to/my/shapefile.shp", rows=slice(100000, ...


2

In the next-to-last line of your code you use "set_crs" which tells the dataset it is in some crs; it doesn't actually transform the data. To do that, you need to use "to_crs". I have no idea if the rest of your code is right as you don't provide the context.


1

I have solved it with the movingpandas package, as Kadir suggested: import pandas as pd import geopandas as gpd import movingpandas as mpd import matplotlib.pyplot as plt import contextily as ctx import geoplot fig, ax = plt.subplots(figsize = (25, 25), dpi = 200) df = pd.read_csv("/path/to/csv").set_index('snapshot_timestamp') gdf = gpd....


1

Not sure if it's possible via GeoPandas but at least quite easy with ogr Python bindings (you have them if you have Geopandas). The dirty way e.g parsing is not required. import ogr # PostgreSQL recipe databaseServer,databaseName,databaseUser,databasePW = 'your_host', 'your_dbname', 'your_user', 'your_password' connString = f"PG: host={databaseServer} ...


1

Following code you can use to get what you want: for shapefiles in gdfs: clipped = gpd.clip(shapefiles, boundary) clipped.to_file("your local system path") Here I assume that your all shapefiles and boundary polygon are having same projections. If not then you can change the projection of your boundary polygon (if it's also in a ...


1

An easy approach is to use seaborn to plot a 2D Kernel Density Estimate. That may do what you want. import seaborn as sns sns.kdeplot(data=df x='longitude', y='latitude', fill=True, cmap='coolwarm', alpha=0.3, gridsize=200, levels=20, ax=ax) If you want a ...


1

Your polygon is indeed invalid. You can check it for example with ogrinfo ogrinfo -sql "select isvalidreason(geometry) from christina_proj_4269" jsonpoly.json -dialect sqlite ... OGRFeature(SELECT):0 isvalidreason(geometry) (String) = Self-intersection[-75.5297803164871 39.7081441293768] The viewer in Gist actually shows the error Fix the data ...


1

I wasn't able to download buildings data from OSM with a polygon (shapefile) as the bounding box however I was able to using distance from a point with the following code: import osmnx as ox import ast point = 'point coordinates' dist = 'distance in m' buildings = ox.geometries.geometries_from_point(point, {'building': True}, dist=dist) And convert to a ...


1

I solved pip-installing the last rtree version downloaded from https://www.lfd.uci.edu/~gohlke/pythonlibs/#rtree,


Only top voted, non community-wiki answers of a minimum length are eligible