First time working with shape files and new to mapping so please forgive my potential ignorance here. Also, I am unable to create MWE due to access to shape file in question.
I am creating a leaflet map within Shiny and using the SF package for reading shape files. I am trying to import a shape file to display as a map overlay.
Shape file:
Simple feature collection with 13 features and 20 fields
Geometry type: MULTIPOLYGON
Dimension: XYZ
Bounding box: xmin: 389792.7 ymin: 2295313 xmax: 431035.9 ymax: 2376519
z_range: zmin: 0 zmax: 0
Projected CRS: WGS 84 / UTM zone 46N
Structure:
Classes ‘sf’ and 'data.frame': 13 obs. of 21 variables:
$ Join_Count: num 0 0 0 0 0 0 0 0 0 0 ...
$ TARGET_FID: num 0 0 0 0 0 0 0 0 0 0 ...
$ JOIN_FID : num 0 0 0 0 0 0 0 0 0 0 ...
$ Id : num 0 0 0 0 0 0 0 0 0 0 ...
$ OBJECTID : num 0 0 0 0 0 0 0 0 0 0 ...
$ Name : chr "Teknaf Beach Deposits" "Tipam" "Girujan Clay" "Upper Bokabil sst-shl alteration" ...
$ FolderPath: chr NA "Geology_Interpretation.kmz/Geology_Interpretation" "Geology_Interpretation.kmz/Geology_Interpretation" "Geology_Interpretation.kmz/Geology_Interpretation" ...
$ SymbolID : num 0 0 1 2 4 5 6 5 5 6 ...
$ AltMode : num 0 0 0 0 0 0 0 0 0 0 ...
$ Base : num 0 0 0 0 0 0 0 0 0 0 ...
$ Clamped : num 0 -1 -1 -1 -1 -1 -1 -1 -1 -1 ...
$ Extruded : num 0 0 0 0 0 0 0 0 0 0 ...
$ Snippet : chr NA NA NA NA ...
$ PopupInfo : chr NA NA NA NA ...
$ Shape_Leng: num 0 2.485 1.368 0.163 0.157 ...
$ Shape_Le_1: num 0 2.493 1.426 0.892 0.812 ...
$ Shape_Area: num 0 0.04115 0.00439 0.00418 0.00205 ...
$ OBJECTID_1: num 0 1 2 3 5 9 11 12 14 15 ...
$ layer : chr NA "Clip_all" "Clip_all" "Clip_all" ...
$ path : chr NA "MultiPolygonZ?crs=EPSG:3857&field=OBJECTID_1:long(10,0)&field=Name:string(254,0)&field=FolderPath:string(254,0)"| __truncated__ "MultiPolygonZ?crs=EPSG:3857&field=OBJECTID_1:long(10,0)&field=Name:string(254,0)&field=FolderPath:string(254,0)"| __truncated__ "MultiPolygonZ?crs=EPSG:3857&field=OBJECTID_1:long(10,0)&field=Name:string(254,0)&field=FolderPath:string(254,0)"| __truncated__ ...
$ geometry :sfc_MULTIPOLYGON of length 13; first list element: List of 1
..$ :List of 1
.. ..$ : num [1:832, 1:3] 424728 424746 424763 424781 424799 ...
..- attr(*, "class")= chr [1:3] "XYZ" "MULTIPOLYGON" "sfg"
- attr(*, "sf_column")= chr "geometry"
- attr(*, "agr")= Factor w/ 3 levels "constant","aggregate",..: NA NA NA NA NA NA NA NA NA NA ...
..- attr(*, "names")= chr [1:20] "Join_Count" "TARGET_FID" "JOIN_FID" "Id" ...
Previous shapes have been simply added using addPolygons
and function perfectly. However, I am unable to map this particular file which I assume stems from two things. 1) There are no lng or lat data stored as far as I can see. 2) The file uses WGS 84 CRS whereas leaflet needs ESRI 3857?
I've attempted to transform the shapefile using shape <- shape %>% st_transform(3857)
but receive the following: addPolygons must be called with both lng and lat, or with neither.
So I guess this confirms that the missing lng and lat data are the issue here?
My question is, is there anything I can do to resolve this or is there a more fundamental issue with the creation of the shape file itself?
Advice appreciated!