{smcl} {* *! version 2.0 11oct2025}{...} {vieweralsosee "[D] import" "mansection D import"}{...} {viewerjumpto "Syntax" "crsconvert##syntax"}{...} {viewerjumpto "Description" "crsconvert##description"}{...} {viewerjumpto "Options" "crsconvert##options"}{...} {viewerjumpto "Examples" "crsconvert##examples"}{...} {title:Title} {phang} {bf:crsconvert} {hline 2} Convert coordinates between different coordinate reference systems {marker syntax}{...} {title:Syntax} {p 8 17 2} {cmdab:crsconvert} {it:varlist}, {cmd:gen({it:string})} {cmd:from({it:string})} {cmd:to({it:string})} {p 8 17 2} varlist must contain exactly two numeric variables representing x and y coordinates in the source coordinate reference system. {marker description}{...} {title:Description} {pstd} The {cmd:crsconvert} command converts coordinates from one coordinate reference system to another. It creates two new variables containing the transformed coordinates. {marker Dependencies}{...} {title:Dependencies} {pstd} The {cmd:crsconvert} command requires Java libraries from GeoTools and netCDF-Java. {phang} Run {cmd:geotools_init} to configure the GeoTools library path. {phang} Run {cmd:netcdf_init} to configure the netCDF-Java library path (pointing to netcdfAll-5.9.1.jar). {marker options}{...} {title:Options} {phang} {opt gen(prefix_)} specifies the prefix for the two new variables that will contain the transformed coordinates. The new variables will be named {it:prefix_}x and {it:prefix_}y. {phang} {opt from(string)} specifies the source coordinate reference system. It can be provided in EPSG format (e.g., "EPSG:4326") or as a WKT string. Alternatively, users can specify a GeoTIFF (.tif/.tiff), Shapefile (.shp), or NetCDF (.nc) file to automatically extract the coordinate reference system from the file. {phang} {opt to(string)} specifies the target coordinate reference system. It can be provided in EPSG format (e.g., "EPSG:4326") or as a WKT string. Alternatively, users can specify a GeoTIFF (.tif/.tiff), Shapefile (.shp), or NetCDF (.nc) file to automatically extract the coordinate reference system from the file. {marker examples}{...} {title:Examples} {pstd}convert the coordinate system of the hunan.shp to the coordinate system of the DMSP-like2020.tif:{p_end} {phang2}{cmd:. spshape2dta hunan.shp, replace}{p_end} {phang2}{cmd:. use "hunan.dta",clear}{p_end} {phang2}{cmd:. crsconvert _CX _CY, gen(alber) from(hunan.shp) to(DMSP-like2020.tif)}{p_end} {title:Author} {pstd}Kerry Du{p_end} {pstd}School of Managemnet, Xiamen University, China{p_end} {pstd}Email: kerrydu@xmu.edu.cn{p_end} {pstd}Chunxia Chen{p_end} {pstd}School of Managemnet, Xiamen University, China{p_end} {pstd}Email: 35720241151353@stu.xmu.edu.cn {pstd}Yang Song{p_end} {pstd}School of Economics, Hefei University of Technology, China{p_end} {pstd}Email: ss0706082021@163.com {pstd}Ruipeng Tan{p_end} {pstd}School of Economics, Hefei University of Technology, China{p_end} {pstd}Email: tanruipeng@hfut.edu.cn {title:Also see} {psee} Online: {help geotools_init}, {help netcdf_init}, {help gtiffread}, {help ncread} {p_end}