You are building ValparaisoPPgis as a regular data.frame, not a spatial data frame. So of course it does not have crs defined.
ValparaisoPPgis <- read.csv(file="kunduz_ST4 - Copy.csv",header=TRUE, stringsAsFactors = FALSE) # a normal data.frame
names(ValparaisoPPgis)[1] <- c("Code") # rename the first column
str(ValparaisoPPgis)
stations <- ValparaisoPPgis # make a copy
( stations <- st_as_sf(stations, coords = c('lon', 'lat'), crs = 32642) ) # convert it to a simple features (sf) spatial data frame with crs 32642
stations.utm <- sf::st_transform(stations, crs=32642) # do nothing I think
st.coords <- st_coordinates(stations.utm) # extract the coordinates
lon <- st.coords[, "X"] # extract the X coordinate
lat <- st.coords[, "Y"] # extract the Y coordinate
ValparaisoPPgis <- data.frame(Id = stations.utm[["Code"]], lon=lon, lat=lat) # put the first column and the coordinate values into a normal data frame
to be honest i did not understand what you wrote here as a reply. if it is possible i would like to send my csv file for you to have a look and see how should i proceed.
Regards
there is no need to send the whole csv-file. Just enclose the first data line of the csv file in the form of a data.frame so that we see what is wrong (if anything) with your code and how the code of @woodward has to be adapted for your special case.
See providing a minimal REPRoducible EXample (reprex) for a full discussion of providing data in such a case but here a good start could be just to define
check out that stations.utm has indeed the required CRS by entering
sf::st_crs(stations.utm)
(I have only loaded the sf package and have no crs function available)
But as @woodward already remarked, the ValparaisoPPgis variable is an ordinary data.frame and has no spatial attributes. You can download this data.frame to a new csv-file and load in ARCGIS or QGIS knowing that the coordinates are now in UTM42N.
Or do you have another purpose for this data.frame ?
Sir,
As you can see, in this csv the points X and Y or lat and lon is already stored. the whole purpose which i have is how to assign a projected utm zone 42 for this data frame. this is all my purpose.
I understand (but I may be wrong) that you started with a csv-file with coordinates in WGS84.
If you save the ValparaisoPPgis.utm data.frame as a csv-file you also have a csv-file with UTM42N coordinates.
You also have the stations simple-feature object that you can use in spatial analysis, plots etc.
I have the feeling that you need something more, but it is not clear to me what that is.
If this is the case please indicate so and otherwise close the issue.
Sir,
I attached a pdf file here, i apology for taking your time. just if you could scan page 5 and page 7. its is all about the problem i have. and that is my purpose to do with my csv.
I now understand that you want to redo the analysis with your own data.
I scanned quickly through these pages and I think that with the adapted code you reproduced these steps.
If you have specific questions, please let them know.
Sir,
i have 4078 chirps rainfall daily data, how i can do a raster brick. when i apply raster brick i lose 1000 data. i use this code.
library(raster)
lista<-list.files(path=getwd(), pattern="tif$")
cdd <- stack(lista)
brc<-brick(cdd)