Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: st: Randomize points to map polygons using -spmap- ?
From
Sergiy Radyakin <[email protected]>
To
"[email protected]" <[email protected]>
Subject
Re: st: Randomize points to map polygons using -spmap- ?
Date
Mon, 15 Jul 2013 14:58:51 -0400
Andrew, spmap does not (afaik) have an pip-algortihm built-in, so you
will have to implement it yourself. Note that the center of a polygon
does not necessarily _belong_ to the polygon. You will have to deal
with cases like shown here:
http://geometrylibrary.geodan.nl/within_polygon.png
I would go with something like this:
http://i.stack.imgur.com/sa9tY.png
throw a grid of points(cells) on top of the polygon, number them
1....10000, then manually remove those ones that do not belong to the
polygon (red ones), then randomize within the remaining subset (green
ones).
Perhaps this is not too difficult, since spmap as far as I remember
does not support the donut-shaped polygons anyway, (which are legal in
ArcView shapefiles). Double-check this to be sure.
Also, you don't specify whether you want to, say, randomize regions
(e.g. assign 100 points to 25 regions, but place, say the first 4 that
have fallen into the first region into ONE point?) or randomize
location completely? (so that the points occupy random positions also
within regions?). First is obviously easier to implement.
Finally consider what is it that you are randomizing. If this is
locations where you want to take an air-quality sample, it's fine, but
if you are sampling households, you want to make sure you don't send
your enumerators into the center of a desert (so take population
density into account).
Best, Sergiy
On Mon, Jul 15, 2013 at 11:13 AM, <[email protected]> wrote:
> Dear Statalist,
>
> Any thoughts on the possibility of randomizing in space a given number
> of points to polygons (say, states, districts, etc) using Maurizio
> Pisati's -spmap- (from SSC)?
>
> ******** Example starts here ********
>
> * cd "User/Data/"
>
> ssc install spmap
> ssc install shp2dta
>
> * open-source shapefile for Andorra(AND)
>
> copy "http://gadm.org/data/shp/AND_adm.zip" AND_adm.zip, replace
> unzipfile AND_adm.zip, replace
>
> shp2dta using "AND_adm1", database(ADMdb) coordinates(ADMcoord)
> genid(id) replace
>
> use ADMdb, clear
>
> gen cases = ceil(uniform() * 25)
> desc
>
> * use ADMcoord, clear
> * desc
>
> ******** Example ends here ********
>
>
> How to randomize 'cases' within 'NAME_1' and export the coordinates?
>
> Thanks for taking a look-
>
> cheers-
> Andrew Lover
> ___________________________________________________________
> Epidemiologist
> Centre for Infectious Disease Epidemiology Research (CIDER)
> Saw Swee Hock School of Public Health
> National University of Singapore
> *
> * For searches and help try:
> * http://www.stata.com/help.cgi?search
> * http://www.stata.com/support/faqs/resources/statalist-faq/
> * http://www.ats.ucla.edu/stat/stata/
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/faqs/resources/statalist-faq/
* http://www.ats.ucla.edu/stat/stata/