Skip to main content

Scripts for sampling Geo data sets by the specific region name

Project description

Geo sampling

Say you want to learn about the average number of potholes per kilometer of street in a city. Or estimate a similar quantity. The package allows you to sample locations randomly to allow for collecting such data. In particular, the package facilitates the following workflow:

  1. Get all the streets in a specific region from OpenStreetMap data.

  2. Starting from one end of the street, split each street into .5 km segments till you reach the end of the street. The last segment, or if the street is shorter than .5km, the only segment, can be shorter than .5 km.

  3. Get the lat/long of starting point and ending point of each of the segments. Assume that the street is a straight line between the .5 km segment.

  4. Create a database of all the segments

    segment_id, street_name, start_lat, start_long, end_lat, end_long
  5. Sample rows from the database

  6. Produce a CSV of the sampled segments

  7. Plot the lat/long — filling all the area within the segment.

  8. Collect data on the highlighted segments.


There are a couple dependencies that need to be built from the source on Windows so you may need to install Microsoft Visual C++ Compiler for Python 2.7.


Prepare the working directory. We recommend that you install in the Python virtual environment.

mkdir geo_sampling
cd geo_sampling
virtualenv -p python2.7 venv
. venv/bin/activate

Upgrade Python packages pip and setuptools to the latest version.

pip install --upgrade pip setuptools

Install geo-sampling package from test PyPI.

pip install --extra-index-url geo-sampling

For more information please visit the project documentation page.


Suriyan Laohaprapanon and Gaurav Sood


Scripts are released under the MIT License.

Project details

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page