({{, (RefLink[RandomGeoPosition, paclet:ref/RandomGeoPosition])[] 
gives a pseudorandom geo position uniformly distributed on the surface of the Earth.}, {, (RefLink[RandomGeoPosition, paclet:ref/RandomGeoPosition])[{{latmin,lonmin},{latmax,lonmax}}]
gives a pseudorandom geo position uniformly distributed in the given geo bounding box. }, {, (RefLink[RandomGeoPosition, paclet:ref/RandomGeoPosition])[g]
gives a pseudorandom geo position uniformly distributed in the geo region g.}, {, (RefLink[RandomGeoPosition, paclet:ref/RandomGeoPosition])[g,n]
gives a list of n pseudorandom geo positions uniformly distributed in the geo region g.}, {, (RefLink[RandomGeoPosition, paclet:ref/RandomGeoPosition])[g,{(Subscript[n, 1]),(Subscript[n, 2]),…}]
gives an (Subscript[n, 1])× (Subscript[n, 2])×… pseudorandom geo position array.}})

OpenersNotesSection(Spacer1)Details and Options

The geo region g in RandomPosition[g,…] can be given as a geo primitive like (RefLink[GeoDisk, paclet:ref/GeoDisk])[…] or (RefLink[GeoBoundsRegion, paclet:ref/GeoBoundsRegion])[…] or as an extended geo (RefLink[Entity, paclet:ref/Entity]) object.

Possible options for (RefLink[RandomGeoPosition, paclet:ref/RandomGeoPosition]) include:

(RefLink[RandomGeoPosition, paclet:ref/RandomGeoPosition])[] is equivalent to (RefLink[RandomGeoPosition, paclet:ref/RandomGeoPosition])["World"] and (RefLink[RandomGeoPosition, paclet:ref/RandomGeoPosition])[{{-90,-180},{90,180}}].

(RefLink[RandomGeoPosition, paclet:ref/RandomGeoPosition]) gives a different sequence of pseudorandom geo positions whenever you run the Wolfram Language. You can start with a particular seed using (RefLink[SeedRandom, paclet:ref/SeedRandom]).

OpenersPrimaryExamplesSection(Spacer1)Examples  (20)

OpenersExampleSection0(Spacer1)Basic Examples  (4)

Generate a pseudorandom geo position on the Earth:

RandomGeoPosition[]

Restrict the generated geo position to a given bounding box:

RandomGeoPosition[{{0,90},{90,180}}]

Generate a pseudorandom point on Mars:

RandomGeoPosition[GeoModel->(Entity["Mars", Entity["Planet","Mars"], "Entity[\"Planet\", \"Mars\"]", "planet"])]

Generate a list of pseudorandom geo positions in the US:

pts=RandomGeoPosition[(Entity["United States", Entity["Country","UnitedStates"], "Entity[\"Country\", \"UnitedStates\"]", "country"]),1000]

GeoGraphics[Point[pts]]

Generate geo locations uniformly distributed in the Mercator projection:

pts=RandomGeoPosition["World",1000,GeoProjection->"Mercator"]

GeoGraphics[Point[pts],GeoProjection->"Mercator"]

They are not uniformly distributed in an equal-area projection like Mollweide:

GeoGraphics[Point[pts],GeoProjection->"Mollweide"]

OpenersExampleSection1(Spacer1)Scope  (7)

Generate a random geo position on the Earth:

RandomGeoPosition[]

Generate 100 random geo positions uniformly distributed on the Earth:

RandomGeoPosition[100]

Generate a random geo position in a given bounding box:

RandomGeoPosition[{{41,-5},{51,10}}]

Generate random geo positions in France:

p=RandomGeoPosition[(Entity["France", Entity["Country","France"], "Entity[\"Country\", \"France\"]", "country"])]

ps=RandomGeoPosition[(Entity["France", Entity["Country","France"], "Entity[\"Country\", \"France\"]", "country"]),500]

GeoGraphics[{GeoMarker[p],Point[ps]}]

Generate random geo positions in different geo variants of a country:

ps=RandomGeoPosition[GeoVariant[(Entity["United States", Entity["Country","UnitedStates"], "Entity[\"Country\", \"UnitedStates\"]", "country"]),"DefaultMapArea"],1000]

GeoGraphics[Point[ps]]

ps=RandomGeoPosition[GeoVariant[(Entity["United States", Entity["Country","UnitedStates"], "Entity[\"Country\", \"UnitedStates\"]", "country"]),"PrincipalArea"],1000]

GeoGraphics[Point[ps]]

Generate random geo positions in the interior of a geo primitive:

RandomGeoPosition[GeoDisk[Here,Quantity[100,"Miles"]],1000]

GeoGraphics[{Blue,Point[%],Red,GeoCircle[Here,Quantity[100,"Miles"]]}]

Generate a random geo position array:

RandomGeoPosition[(Entity["United States", Entity["Country","UnitedStates"], "Entity[\"Country\", \"UnitedStates\"]", "country"]),{6,10,8}]

OpenersExampleSection2(Spacer1)Options  (2)

OpenersExampleSubsection0(Spacer1)GeoModel  (1)

By default, (RefLink[RandomGeoPosition, paclet:ref/RandomGeoPosition]) generates locations on the Earth using the "ITRF00" datum:

RandomGeoPosition[1000]

Use the (RefLink[GeoModel, paclet:ref/GeoModel]) option to specify other models of the Earth or other celestial globes:

RandomGeoPosition[1000,GeoModel->"Moon"]

GeoGraphics[{Red,Point[%]},GeoProjection->"Orthographic"]

OpenersExampleSubsection1(Spacer1)GeoProjection  (1)

Generate random geo positions uniformly distributed in the Albers projection:

ps=RandomGeoPosition["World",2000,GeoProjection->"Albers"]

Check that they homogeneously distributed in that projection:

GeoGraphics[Point[ps],GeoProjection->"Albers"]

They are not homogeneously distributed in other projections:

GeoGraphics[Point[ps],GeoProjection->"Mercator"]

OpenersExampleSection3(Spacer1)Properties & Relations  (5)

Use (RefLink[SeedRandom, paclet:ref/SeedRandom]) to get repeatable random values:

RandomGeoPosition[]

RandomGeoPosition[]

SeedRandom[1234];
RandomGeoPosition[]

SeedRandom[1234];
RandomGeoPosition[]

Use (RefLink[BlockRandom, paclet:ref/BlockRandom]) to block one use of (RefLink[RandomGeoPosition, paclet:ref/RandomGeoPosition]) from affecting others:

BlockRandom[RandomGeoPosition[]]

RandomGeoPosition[]

Take 200 geo locations uniformly distributed in a geo bounding box:

RandomGeoPosition[{{-40,-60},{40,60}},200]

The central feature and spatial median locations are close to the center of that bounding box:

CentralFeature[%]

SpatialMedian[%%]

Take 2000 geo locations uniformly distributed on the surface of the Earth:

ps=Thread@RandomGeoPosition["World",2000];

Select those geo locations in Africa:

inafrica=Pick[ps,GeoWithinQ[(Entity["Africa", Entity["GeographicRegion","Africa"], "Entity[\"GeographicRegion\", \"Africa\"]", "geographic region"]),ps]];

GeoGraphics[{Point[ps],Red,Point[inafrica]}]

Compute the relative fraction and compare with the relative area of Africa with respect to the world:

Length[inafrica]/Length[ps]//N

GeoArea[(Entity["Africa", Entity["GeographicRegion","Africa"], "Entity[\"GeographicRegion\", \"Africa\"]", "geographic region"])]/GeoArea["World"]

Geo locations uniformly distributed in an area look uniform in equal-area projections:

ps=RandomGeoPosition["World",1000]

equalarea=GeoProjectionData["EqualArea"]

GeoGraphics[Point[ps],GeoProjection->#]&/@RandomSample[equalarea,5]

They do not look uniform in other types of geo projections, like conformal projections:

conformal=GeoProjectionData["Conformal"]

GeoGraphics[Point[ps],GeoProjection->#]&/@RandomSample[conformal,5]

OpenersExampleSection4(Spacer1)Possible Issues  (2)

Take 1000 pseudorandom geo positions uniformly distributed over the world in a given projection:

ps=RandomGeoPosition["World",1000,GeoProjection->"AmericanPolyconic"]

The geo positions look uniform in a (RefLink[GeoGraphics, paclet:ref/GeoGraphics]) map if the same geo range is chosen:

GeoGraphics[Point[ps],GeoProjection->"AmericanPolyconic",GeoRange->"World"]

Options[%,{GeoCenter,GeoRange}]

They may not look uniform in other geo ranges, including the default choice in (RefLink[GeoGraphics, paclet:ref/GeoGraphics]):

GeoGraphics[Point[ps],GeoProjection->"AmericanPolyconic"]

Options[%,{GeoCenter,GeoRange}]

For geo (RefLink[Entity, paclet:ref/Entity]) objects without polygon information, the same location is returned repeatedly:

(Entity["Madrid", Entity["City",{"Madrid","Madrid","Spain"}], "Entity[\"City\", {\"Madrid\", \"Madrid\", \"Spain\"}]", "city"])["Polygon"]

RandomGeoPosition[(Entity["Madrid", Entity["City",{"Madrid","Madrid","Spain"}], "Entity[\"City\", {\"Madrid\", \"Madrid\", \"Spain\"}]", "city"]),5]

GeoPosition[(Entity["Madrid", Entity["City",{"Madrid","Madrid","Spain"}], "Entity[\"City\", {\"Madrid\", \"Madrid\", \"Spain\"}]", "city"])]

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[RandomPoint, paclet:ref/RandomPoint])  ▪  (RefLink[GeoPosition, paclet:ref/GeoPosition])  ▪  (RefLink[GeoGridPosition, paclet:ref/GeoGridPosition])  ▪  (RefLink[SeedRandom, paclet:ref/SeedRandom])  ▪  (RefLink[BlockRandom, paclet:ref/BlockRandom])  ▪  (RefLink[GeoGraphics, paclet:ref/GeoGraphics])  ▪  (RefLink[GeoProjection, paclet:ref/GeoProjection])  ▪  (RefLink[GeoArea, paclet:ref/GeoArea])  ▪  (RefLink[RandomVariate, paclet:ref/RandomVariate])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[Locations, Paths, and Routing, paclet:guide/LocationsPathsAndRouting])}, {▪(RefLinkPlain[Geodesy, paclet:guide/Geodesy])}})}})