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: Two questions on Pisati's -spmap- for plotting shapefile geographic data
From
Jen Zhen <[email protected]>
To
[email protected]
Subject
Re: st: Two questions on Pisati's -spmap- for plotting shapefile geographic data
Date
Thu, 19 May 2011 12:06:11 +0200
Maurizio,
thanks a lot for your reply!
I realized that my original shapefile dataset contained not only
polygons for the district boundaries, but also polygons for the state
boundaries, marked as such. I have now saved the latter in a separate
dataset and then used the --option polygon(data(stateboundaries)
osize(*1.5))--.
But instead of the desired thicker lines around my states in the
original map, I get some weird lines outside my original map. The
weird thing is that the range of _X and _Y values of the state dataset
lies within those of the main coordinates dataset, so I do not
understand why the geographical matching does not work out.
I realize this may be hard to understand. But if, by any chance, you
should still see what might be going wrong here, then any hint would
be much appreciated.
Thanks and best regards,
JZ
On Wed, May 18, 2011 at 10:16 PM, Maurizio Pisati
<[email protected]> wrote:
>> (1) First, I would like to plot a categorical variable with 2 values,
>> so I'm using the -clmethod(unique)- option. So there is a total number
>> of 3 different colors in my map "treated", controls" and "no values".
>> But I haven't been able to figure out a way to get a legend that will
>> display the labels ("treated","control","no values") instead of the
>> values (1,0,.)?
>
> This result can be easily achieved by attaching the desired labels to the values of the variable of interest. Here's an example based on the datasets distributed with -spmap-:
>
> . use "Italy-RegionsData.dta", clear
> . generate y = fortell<17
> . replace y = . if inlist(id,1,10)
> . label define y 0 "control" 1 "treated", modify
> . label values y y
> . spmap y using "Italy-RegionsCoordinates.dta", id(id) clmethod(unique) ndlabel("no values")
>
>
>
>> (2) A bit more complicated: My base map delineates the areas of
>> different districts, which in turn belong to a number of different
>> states. Now I would like to plot the districts and color them
>> according to the values of different non-geograpphic variables, but I
>> would also like to clearly show the borders of the different states.
>> My polygons describe only the districts within the states, I only have
>> a database variable that tells me for each district which state it's
>> in. So I'm wondering:
>> (a) Is there any way to add a border around the states with my current
>> data. Or is there any way to construct an additional data layer with
>> the state polygons based on the district polygons within them?
>> (b) If not, can I at least use different color schemes within each state?
>> (c) Or is my goal only achievable if I already have the polygons as a
>> shape file also for the states?
>
> The easiest way to achieve this goal is following approach (c). For example:
>
> . spmap fortell using "Italy-RegionsCoordinates.dta", id(id) ///
> ocolor(white ..) osize(*1.5 ..) fcolor(Reds) ///
> polygon(data("Italy-OutlineCoordinates.dta") osize(*1.5))
>
> After some data manipulation, in principle JZ might also follow approach (b), but I'm not sure that would be a good idea (I guess the resulting map would be quite difficult to read).
>
> Best,
> Maurizio
>
>
>
>
> *
> * For searches and help try:
> * http://www.stata.com/help.cgi?search
> * http://www.stata.com/support/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/statalist/faq
* http://www.ats.ucla.edu/stat/stata/