shapefile

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

Exporting a Geopandas dataframe to a zipped shapefile directly

Exporting a Geopandas dataframe to a zipped shapefile directly Question: I’m trying to save Geopandas data frame into a shapefile that is written to a zipped folder directly. As any shapefile user knows, a shapefile is not a single file but rather a collection of files that are meant to be read together. So calling …

Total answers: 4

UnicodeDecodeError 'utf-8' codec can't decode – using python shapefile reader

UnicodeDecodeError 'utf-8' codec can't decode – using python shapefile reader Question: I’m trying to read a shapefile r = shapefile.Reader(filepath, encoding = “utf-8”) but when I try to get a value from the .records() object like: r.records()[0] it returns to me the following error: UnicodeDecodeError: ‘utf-8’ codec can’t decode byte 0xe9 in position 4: invalid …

Total answers: 2

Plotting a masked Antarctica with a shapefile or geopandas

Plotting a masked Antarctica with a shapefile or geopandas Question: I’m trying to plot data around the Antarctica while masking the continent. While I’m using basemap and it has an option to easily mask continents using map.fillcontinents(), the continent considered by basemap includes the ice shelves, which I do not want to mask. I tried …

Total answers: 2

How to copy the spatial reference from a shapefile to a geotiff raster?

How to copy the spatial reference from a shapefile to a geotiff raster? Question: I have constructed a python script that constructs a geotiff raster from a shapefile. At present the geotiff produced does not contain the spatial reference of the shapefile. How do I copy the spatial reference from the shapefile to the geotiff? …

Total answers: 1

Need the path for particular files using os.walk()

Need the path for particular files using os.walk() Question: I’m trying to perform some geoprocessing. My task is to locate all shapefiles within a directory, and then find the full path name for that shapefile within the directory. I can get the name of the shapefile, but I don’t know how to get the full …

Total answers: 3

Check if a geopoint with latitude and longitude is within a shapefile

Check if a geopoint with latitude and longitude is within a shapefile Question: How can I check if a geopoint is within the area of a given shapefile? I managed to load a shapefile in python, but can’t get any further. Asked By: Gerald Bäck || Source Answers: One way to do this is to …

Total answers: 7

Shapefile reader in Python?

Shapefile reader in Python? Question: Are there any libraries that I can use to read a shp/shx/dbf/sbx set of files? I mainly need to extract some polygons but something that lets me extract any data that I want would be awesome. Asked By: Zameer Manji || Source Answers: The pyshp library should be good. Answered …

Total answers: 6