Random GPS Coordinate Generator
Generate random latitude/longitude inside a bounding box.
Bounding-box coordinate generator and geospatial workflows
This variant of the random coordinate generator lets you pin the output to an arbitrary bounding box β four numbers (latMin, latMax, lngMin, lngMax) that describe a rectangle on the globe. The default covers the metropolitan region of SΓ£o Paulo. Bounding boxes are the cheapest filter in any geospatial pipeline: they are O(1) to test and they pre-filter a large set before more expensive polygon-in-polygon checks.
Geocoding and reverse geocoding
Random coordinates pair naturally with two everyday GIS operations:
- Geocoding β turn an address ("Av. Paulista, 1000") into a lat/lng. Common providers: Nominatim (OpenStreetMap, free), Google Maps Geocoding API, Mapbox, and Brazil-specific stacks like ViaCEP+georeferenciamento.
- Reverse geocoding β turn a lat/lng back into an address or administrative unit. Useful for enriching random points with mock street names during test seeding.
From bounding box to polygon: ray casting
A bounding box always contains more area than the polygon it surrounds β Brazil's bounding box covers parts of Peru, Colombia and the Atlantic. To restrict points to the real outline, use ray casting: generate a candidate point in the bbox, fire a horizontal ray, count polygon edges crossed; an odd count means inside, even means outside. Reject candidates outside the polygon and resample. The polygons themselves come from open datasets:
- Natural Earth β country and admin-1 polygons at 1:10m, 1:50m, 1:110m.
- IBGE Malhas β Brazilian states and municipalities as shapefiles or GeoJSON.
- OpenStreetMap via Overpass API β arbitrary tagged regions (parks, neighbourhoods, water).
Spatial indexes: geohash, H3, S2
For large datasets you want to index points so neighbour queries are fast. Three popular schemes:
- Geohash β encodes lat+lng into a base32 string; longer strings = finer cells. 5 chars β 5 km, 6 chars β 1 km, 7 chars β 150 m, 8 chars β 19 m. Cell sizes shrink toward the poles.
- H3 (Uber) β a hierarchical hexagonal grid. Hexagons have uniform neighbour symmetry (every neighbour is exactly one edge away), which beats geohash for radius queries and routing.
- S2 (Google) β quad-tree on a sphere. Used by Google Maps, Foursquare and InfluxDB geo functions.
Uniform random is not realistic β populations are not uniform
A uniform random point in Brazil's bounding box has equal odds of landing in the Amazon rainforest as in SΓ£o Paulo's downtown β but the city houses millions and the rainforest pixel houses no one. For realistic mock data weight the draw by population density. Free datasets:
- WorldPop β 100 m population rasters by country and year.
- GHSL (Global Human Settlement Layer) β JRC's settlement and built-up rasters.
- Facebook High Resolution Population Density β 30 m grids derived from satellite imagery.
To draw a population-weighted point, treat the raster as a 2D probability distribution: sample a pixel proportionally to its value, then draw a uniform point inside that pixel.
GPS precision in the real world
A smartphone GPS in clear sky delivers Β±3-10 m. Indoors or in dense urban canyons, error climbs to Β±50 m or worse β Wi-Fi positioning and cell-tower triangulation start to beat GPS. Survey-grade RTK GNSS reaches 1-2 cm after carrier-phase correction. The output of this generator uses 4-6 decimals; that resolution is finer than what any consumer GPS can guarantee, so do not interpret the trailing digits as "millimetres of truth".
FAQ
Can I restrict points to a specific country? The bounding box gets you most of the way β use a tight bbox around the territory. For points only inside the polygon (no spillover into neighbouring countries), pair the bbox with ray casting against a country polygon from Natural Earth or IBGE.
Will the points avoid the ocean? Not by default β a bbox over Brazil will produce some Atlantic points. You need a land/water mask raster (e.g. Natural Earth ne_10m_land) and a rejection step to filter sea hits.
Can I generate points that mimic real traffic? Uniform output does not. Mix in population density (WorldPop) for realism, or seed from real OSM Points-of-Interest if you want plausible business locations.
How does this differ from the worldwide generator? The other variant exposes preset regions (world / Brazil / Portugal / US); this one lets you specify any rectangle. Use this when your target is a city, district or arbitrary research area; use the preset variant for cross-country sampling.
Related Tools
Random Time Generator
Generate random times (HH:MM:SS) within a window.
Random Emoji Generator
Generate a sequence of random emojis β pick theme (general, food, animals, sports) and quantity. For design, mockups and messages.
Random Timestamp Generator
Generate random Unix timestamps within a date range. Useful for test data.
Random Words Generator
Generate random words in Portuguese or English. Useful for brainstorming, games, UI tests and identifier generation.
Random Number Generator
Generate random numbers between a defined minimum and maximum. Option for unique numbers (no repetition) and configurable quantity.
Random Coordinate Generator
Generate random geographic coordinates (latitude and longitude) β globally valid or country-restricted. Useful for map fixtures and simulations.