Hello,
I have created an SP dataset from shapefiles ( with extensions .sph and .dbf) using the STATA command spshape2dta. Now I have two STATA datasets: one is an SP dataset called Example 14_1.dta, and the other is a translated shapefile called Example 14_2_shp.dta. Both datasets are located in the same directory.
My question is regarding the SP dataset. When I examine it, I find that it contains the following variables:
_CX: x-coordinate of the area centroid
_CY: y-coordinate of the area centroid
I would like to convert these y-coordinates of the area centroid and x-coordinates of the area centroid to latitude and longitude degrees. I attempted to use the command "spset, modify coordsys(latlong)" to achieve this. However, when I browse the dataset and check the values of _CX and _CY coordinates of the area centroid, I notice that they remain unchanged and have not been converted to latitude and longitude degrees.
Indeed, the "spset, modify coordsys" command in STATA converts the coordinates to latitude and longitude in kilometers or miles, not to degrees. I specifically require latitude and longitude in degrees. Specifically, latitude values ranging from -90 to 90 and longitude values ranging from -180 to 180.
Could you please advise me on how to generate latitude and longitude values in degreesfrom the x-coordinate of the area centroid (_CX) and y-coordinate of the area centroid (_CY) of the SP dataset? For additional context, I have provided a data example below showing the first 20 observations (regions) and four variables (ID, _CX, _CY, and regions_code) of my SP dataset.
Looking forward to your assistance, and thank you in advance !!
----------------------- copy starting from the next line -----------------------
------------------ copy up to and including the previous line ------------------
Listed 20 out of 363 observations
I have created an SP dataset from shapefiles ( with extensions .sph and .dbf) using the STATA command spshape2dta. Now I have two STATA datasets: one is an SP dataset called Example 14_1.dta, and the other is a translated shapefile called Example 14_2_shp.dta. Both datasets are located in the same directory.
My question is regarding the SP dataset. When I examine it, I find that it contains the following variables:
_CX: x-coordinate of the area centroid
_CY: y-coordinate of the area centroid
I would like to convert these y-coordinates of the area centroid and x-coordinates of the area centroid to latitude and longitude degrees. I attempted to use the command "spset, modify coordsys(latlong)" to achieve this. However, when I browse the dataset and check the values of _CX and _CY coordinates of the area centroid, I notice that they remain unchanged and have not been converted to latitude and longitude degrees.
Indeed, the "spset, modify coordsys" command in STATA converts the coordinates to latitude and longitude in kilometers or miles, not to degrees. I specifically require latitude and longitude in degrees. Specifically, latitude values ranging from -90 to 90 and longitude values ranging from -180 to 180.
Could you please advise me on how to generate latitude and longitude values in degreesfrom the x-coordinate of the area centroid (_CX) and y-coordinate of the area centroid (_CY) of the SP dataset? For additional context, I have provided a data example below showing the first 20 observations (regions) and four variables (ID, _CX, _CY, and regions_code) of my SP dataset.
Looking forward to your assistance, and thank you in advance !!
----------------------- copy starting from the next line -----------------------
Code:
* Example generated by -dataex-. For more info, type help dataex clear input int _ID double(_CX _CY) str4 Regions_code 1 292980.6302968765 7030896.843935639 "5031" 2 -63869.11095563841 6815936.127018477 "4636" 3 258595.46388926185 6610985.7930324 "3019" 4 278249.87143412017 6667101.162352326 "3032" 5 139557.65901253297 6748864.792262625 "3043" 6 88473.66376966685 6498985.249885225 "4218" 7 135072.977436099 6620844.239222783 "3820" 8 242743.12614329145 6594030.4484248245 "3801" 9 180123.56628837058 6852569.976749381 "3435" 10 336160.993047937 6654637.561141844 "3416" 11 143023.9396955031 6529669.265775605 "4212" 12 153248.29062826297 6543291.5931665255 "4211" 13 340404.43807261565 6875831.214050882 "3425" 14 269394.8269284572 6667953.285738191 "3031" 15 149917.56660270633 6804540.514651674 "3454" 16 320207.2367520043 6680741.092113004 "3415" 17 169120.241682819 6911789.354071034 "3432" 18 30070.6838231142 6553867.230620015 "4228" 19 146185.20300780854 6634900.5292685665 "3819" 20 288891.2981200035 6674267.909753888 "3033" end
Listed 20 out of 363 observations