Now I have a shapefile describing the sergeant area of Texas. I opened it in R using read_sf() and get very weird results:
sgt_area <- read_sf("shapefiles/THP_SGTArea_outlines_20200422.shp")
sgt_area$geometry
Geometry set for 213 features
Geometry type: MULTIPOLYGON
Dimension: XY
Bounding box: xmin: -11871800 ymin: 2978934 xmax: -10409240 ymax: 4369693
CRS: NA
First 5 geometries:
MULTIPOLYGON (((-11103211 3540951, -11102945 35...
MULTIPOLYGON (((-10981244 3470857, -10981233 34...
MULTIPOLYGON (((-10944063 3451077, -10944060 34...
MULTIPOLYGON (((-10999089 3463854, -10996024 34...
MULTIPOLYGON (((-11066709 3387272, -11066686 33...
I want to simply convert the coordinates into a normal form (i.e. with crs = ESPG:4326 or long/lat).
I tried many ways but failed all the time.
sgt_area <- st_transform(sgt_area, crs = 4326)
Error in st_transform.sfc(st_geometry(x), crs, ...) :
cannot transform sfc object with missing crs
sgt_area <- st_transform(sgt_area, st_crs(county_sf)) # county_sf is the correct shapefile of counties Texasand did nothing.
Error in st_transform.sfc(st_geometry(x), crs, ...) :
cannot transform sfc object with missing crs
- I opened it in QGIS and did
reproject layersetting crs to NAD83. But the reprojected layer didn't move as expected. I exported the data set and opened it in R.
sgt
Simple feature collection with 213 features and 8 fields
Geometry type: MULTIPOLYGON
Dimension: XY
Bounding box: xmin: -11871800 ymin: 2978934 xmax: -10409240 ymax: 4369693
Geodetic CRS: NAD83
# A tibble: 213 × 9
REGION DISTRICT SGT_AREA SGT_AREA_N COUNTY DISTR…¹ Shape…² Shape…³ geometry
<chr> <chr> <chr> <chr> <chr> <chr> <dbl> <dbl> <MULTIPOLYGON [°]>
1 6 6C 6C07 6C07 Bander… San An… 1.03e10 518477. (((-11103211 3540951, -1…
2 6 6C 6C09 6C09 Comal San An… 1.99e 9 230062. (((-10981244 3470857, -1…
3 6 6C 6C03 6C03 Guadal… San An… 2.46e 9 282335. (((-10944063 3451077, -1…
4 6 6C 6C01 6C01 Bexar,… San An… 6.60e 9 471434. (((-10999089 3463854, -1…
5 6 6C 6C05 6C05 Medina San An… 4.57e 9 299504. (((-11066709 3387272, -1…
6 6 6C 6C02 6C02 Karnes… San An… 5.30e 9 325761. (((-10861961 3351903, -1…
7 6 6C 6C04 6C04 Atasco… San An… 8.03e 9 409839. (((-10998912 3387155, -1…
8 6 6C 6C06 6C06 Frio San An… 3.84e 9 249471. (((-11066709 3387272, -1…
9 1 1D 1D01 1D01 Red Ri… Mt. Pl… 5.54e 9 530189. (((-10592824 4020348, -1…
10 1 1D 1D05 1D05 Delta,… Mt. Pl… 7.90e 9 541725. (((-10641676 4020961, -1…
# … with 203 more rows, and abbreviated variable names ¹DISTRICT_N, ²Shape_STAr, ³Shape_STLe
# ℹ Use `print(n = ...)` to see more rows
still didn't work.
- using the method from here
sgt <- readOGR("shapefiles/THP_SGTArea_outlines_20200422.shp") #from rdgal
> proj4string(sgt)
[1] NA
> proj4string(sgt) <- CRS("+init=epsg:4269") # I wanted to specify the crs epsg:4269
Error in `proj4string<-`(`*tmp*`, value = new("CRS", projargs = "+proj=longlat +datum=NAD83 +no_defs")) :
Geographical CRS given to non-conformant data: -11871802.3935 4369693.2565
Have you encountered this kind of problem?