GeospatialPython.com
Points, Polylines, Polygons, Pixels, Python!
Thursday, October 10, 2019
Learning Geospatial Analysis with Python, 3rd Ed.
Third Edition is on the shelves! Geospatial concepts, Geo-python universe, and pound-for-pound still the most pure-python and minimal-dependency examples you’ll find anywhere so somebody somewhere out there will still be able to do the math. I'm giving away a few eBook versions if you're willing to write a review on Amazon. DM me @SpatialPython with your name and email! https://bit.ly/35gm0xl
Saturday, January 12, 2019
PotreeConverter Mac Binary
Potree is the amazing javascript WebGL library that can effortlessly display multi-million-point lidar
point clouds in a browser using a static web page. In order to do that, you have to use PotreeConverter which creates an efficient octree of your LAS file. But the MacOS built-in compilers with XCode are usually several generations behind and don't like the PotreeConverter source. I was finally able to get it to compile so I created a GitHub repository with the binary and the compile steps. You still need to download the "resources" directory from the original PotreeConverter repository which contains the viewer webpage template. You may also have to deal with issue https://github.com/potree/PotreeConverter/issues/281 but it's an easy fix. I have no idea how portable the binary is, but hopefully the compile steps will save time for others.
Thursday, November 16, 2017
Creating MultiPoint Shapefiles with PyShp
Pyshp let's you create any type of shapefile. Normally a point shapefile has one point per record. But
you can also have a group of points tied to a single record in a Multipoint shapefile. To create a Multipoint shapefile, you just use the "poly" method in the Writer. The poly method isn't just for polygons. It can also create polylines and polypoints (i.e. MultiPoints)!
Here's a simple Multipoint shapefile:
![]() |
Photo credit: VancouverMom.ca |
Here's a simple Multipoint shapefile:
import shapefile # Create our writer as a multipoint shapefile w = shapefile.Writer(shapefile.MULTIPOINT) # We'll create a single dbf field w.field("NAME","C",40) # Create a single-part, multi-point shape # by declaring the shape # type after the parts/points list w.poly([[[3,4],[5,6],[7,8],[9,8]]], shapeType=shapefile.MULTIPOINT) # Create a record for this feature w.record("Group1") # Save the multipoint shapefile w.save("mpoint")Repeat the poly and record steps to add additional shapes. Add another nested list of points in the first poly method argument to add more parts to the same record
Tuesday, March 14, 2017
QGIS Python Programming Cookbook - SECOND EDITION

As with all of my books, I've tried to walk a very tricky line. I created a QGIS Python book reference book that will stand on its own if it's the only book you have. But I also try to create content that is very different from the official documentation and book, as well as complement other third-party books out there. QGIS is rich enough,
and updated and released with such frequency, that I don't think one book can do it justice. While many operations in QGIS are straight-forward and easy to understand, some things can be quite complex. For example, the Map Composer, raster operations, tinkering with various types of settings, and working with plug-ins through Python can be more difficult to understand. And having more than one example from different sources can be invaluable in software development. So I carefully picked examples and explanations that I felt were not easily found on the Internet for the most part, lacked documentation, or were complex enough that the over 170 examples should enrich your knowledge of QGIS regardless of you're starting from. At the very least, I hope it encourages more people to use my favorite GIS package.
Sunday, October 16, 2016
Cutting a Line Shapefile with a Point Shapefile using Shapely
Shapely works with geometric classes. Sometimes you want those geometries to come from
shapefiles. That's where PyShp comes in. In this example on GIS Stack Exchange, we take a line shapefile and a point shapefile with points on or near the line segments, and split those lines at the location of the nearest point. At a minimum, the point must be inside the envelope of the line segment:
http://gis.stackexchange.com/questions/214344/split-polyline-shapefile-using-python-with-point-shapefile/214432#214432
shapefiles. That's where PyShp comes in. In this example on GIS Stack Exchange, we take a line shapefile and a point shapefile with points on or near the line segments, and split those lines at the location of the nearest point. At a minimum, the point must be inside the envelope of the line segment:
http://gis.stackexchange.com/questions/214344/split-polyline-shapefile-using-python-with-point-shapefile/214432#214432
Subscribe to:
Posts (Atom)