Say you want to learn about the average number of potholes per kilometer of street in a city. Or estimate a similar such quantity. To estimate the quantity, you need to sample locations on the streets. This package helps you sample those locations. In particular, the package implements the following sampling strategy:
Get all the streets in the region of interest from OpenStreetMap. To accomplish that, the package first downloads administrative boundary data for the country in which the region is located in ESRI format from http://www.gadm.org/country. The administrative data is in multiple levels, for instance, cities are nested in states, which are nested in countries. The user can choose a city or state, but not a portion of a city. And then the package uses the pyshp package to build a URL for the site http://extract.bbbike.org from which we can download the OSM data.
-
For each street (or road), starting from one end of the street, we split the street into .5 km segments till we 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.)
-
Get the lat/long of starting and ending points of each of the segments. And assume that the street is a straight line between the .5 km segment.
-
Next, create a database of all the segments
-
Sample rows from the database and produce a CSV of the sampled segments
-
Plot the lat/long --- filling all the area within the segment. These shaded regions are regions for which data needs to be collected.
Collect data on the highlighted segments.
The package requires Python 3.10 or higher. Install the package from PyPI:
pip install geo-sampling
For development installation:
git clone https://github.com/geosensing/geo_sampling.git
cd geo_sampling
pip install -e .
The package provides two main CLI commands:
Process geographic regions to extract road segments:
geo_roads -c Singapore -n North -l 1
Sample from processed road segments:
sample_roads input_roads.csv output_sample.csv --sample-size 100
For complete documentation, visit the project documentation page.
- geosensing/latlong-to-zip — Reverse Geocode Lat/Long to Zip Codes using GeoNames, AskGeo, or Google. Compare Geocoding Services.
- geosensing/autosense — AutoSense: Automated Street Condition Assessment
- geosensing/streetsense — Street Sense: Learning from Google Street View
- geosensing/missing_women — Missing Women On the Streets: Evidence from Mumbai
- geosensing/women-count — Missing Women on the streets of Delhi
Suriyan Laohaprapanon and Gaurav Sood
Scripts are released under the MIT License.