1 year ago

#380131

test-img

Wei Chong

How can I obtain the Latitude and Longitude of polygons created in QGIS

I have been using QGIS to create geographical boundaries to perform spatial clipping in R. I have done so without issues previously by using the st and sf packages. My usual procedure is as follows:

library(st)
library(sf)

#import the shapefile
pie_boundary <- st_read("pie.shp")

#convert my gps data points into an sf object
gps_data <- gps_data %>%
  mutate(long = as.numeric(long),
         lat = as.numeric(lat)) %>%
  filter(!is.na(long), !is.na(lat))

coords.tmp <- cbind(gps_data$long, gps_data$lat)
data.sp <- SpatialPointsDataFrame(coords.tmp, data = data.frame(gps_data), proj4string = CRS("+proj=longlat "))
data_sf <- st_as_sf(data.sp)

#perform the spatial join operation
data_join <- st_join(data_sf, pie_boundary)

Here are the first 6 observations of pie_boundary:

dput(head(pie_boundary), n=6)

structure(list(ID = c("PIE_E_1", "PIE_E_2", "PIE_E_3", "PIE_E_4", 
"PIE_E_5", "PIE_E_6"), geometry = structure(list(structure(list(
    structure(c(103.973397042321, 103.973359037017, 103.973431624961, 
    103.975686599317, 103.976210224709, 103.976871092709, 103.977546740698, 
    103.977895119644, 103.978255771782, 103.978842740188, 103.97925129533, 
    103.979442376911, 103.979520498721, 103.979593078217, 103.979562985663, 
    103.979185309348, 103.978495674358, 103.978433124271, 103.978387597316, 
    103.978321352232, 103.978226603316, 103.97814280715, 103.978097676032, 
    103.977987091688, 103.977848927168, 103.977711158615, 103.977625910996, 
    103.977542246962, 103.977410284867, 103.976949208492, 103.976625108797, 
    103.975996967124, 103.975232640727, 103.974512653019, 103.973868676074, 
    103.973471733025, 103.973397042321, 1.33974614533139, 1.33976102317517, 
    1.33987995785224, 1.33888953335063, 1.33863661654637, 1.33835606534424, 
    1.3380755131043, 1.33789698460984, 1.33772595957809, 1.33747410104351, 
    1.33729663133032, 1.33721799143468, 1.33718690726273, 1.3371599407893, 
    1.3370856971413, 1.33724297666658, 1.33753893707783, 1.33756669983444, 
    1.33758702374973, 1.33761551722442, 1.33765682936172, 1.33769136710955, 
    1.33771076126798, 1.33775991061938, 1.33782021834235, 1.33788185421825, 
    1.33791957967624, 1.33795730503785, 1.33801867491819, 1.33822005474811, 
    1.33835873618525, 1.33861962829086, 1.33895118755307, 1.33925511780663, 
    1.33953566744684, 1.33971207312106, 1.33974614533139), .Dim = c(37L, 
    2L))), class = c("XY", "POLYGON", "sfg")), structure(list(
    structure(c(103.967860624528, 103.96806436086, 103.968976430599, 
    103.969062997984, 103.969252483847, 103.969355935461, 103.969473111468, 
    103.969693738793, 103.970000402561, 103.970115995861, 103.970235284755, 
    103.970366713998, 103.970578902851, 103.970733030457, 103.971003282401, 
    103.971308373284, 103.971549067974, 103.971831991344, 103.972218372778, 
    103.972266934773, 103.972296494403, 103.972169797138, 103.972110678596, 
    103.971494158731, 103.970981099186, 103.970508158164, 103.970066891629, 
    103.969775533435, 103.969332165067, 103.969069311648, 103.967705427266, 
    103.967860624528, 1.3459602335715, 1.34560639404654, 1.344153841248, 
    1.34411133452234, 1.34379680996615, 1.34362042134778, 1.34344296940968, 
    1.34308487865018, 1.34263115379771, 1.34247123395307, 1.34232140809357, 
    1.34216254989471, 1.34194046557975, 1.34178638754536, 1.34153136095838, 
    1.34127633237039, 1.34107868495108, 1.34087465982564, 1.34061537632306, 
    1.34058987242207, 1.34057712016979, 1.34039861950051, 1.34043687456577, 
    1.34087467903522, 1.34129972695117, 1.34174389836028, 1.34223907017301, 
    1.34264710464331, 1.34332184693485, 1.34373625502827, 1.34586780057617, 
    1.3459602335715), .Dim = c(32L, 2L))), class = c("XY", "POLYGON", 
"sfg")), structure(list(structure(c(103.957765964142, 103.958369850427, 
103.958760474943, 103.959146875895, 103.959634627211, 103.9602532885, 
103.961104208988, 103.961615181759, 103.961997355033, 103.961950888097, 
103.961686958017, 103.961277337195, 103.960895164038, 103.960523547298, 
103.960137149314, 103.959377018609, 103.958963168764, 103.958238928638, 
103.957844078224, 103.957765964142, 1.35039053375392, 1.3505435094169, 
1.35061786749024, 1.3506794751481, 1.35074320253888, 1.35079204728756, 
1.35080687807996, 1.35078134985286, 1.35075157819466, 1.35047106815909, 
1.35052420956823, 1.35058160886127, 1.35061350549872, 1.35062840076156, 
1.35062417088939, 1.35054770725853, 1.35048822615883, 1.35032675649186, 
1.3501928958825, 1.35039053375392), .Dim = c(20L, 2L))), class = c("XY", 
"POLYGON", "sfg")), structure(list(structure(c(103.955347950808, 
103.955340446623, 103.955118095837, 103.954719011978, 103.954463514948, 
103.953979969901, 103.953538656105, 103.952805948377, 103.952132364672, 
103.951628760565, 103.951267685992, 103.950734520441, 103.95046952136, 
103.950114110858, 103.949999511588, 103.950060909403, 103.950174154235, 
103.950678981877, 103.951095122941, 103.952910479278, 103.953826892056, 
103.955216979549, 103.955347950808, 1.3487078893196, 1.34870205379444, 
1.34851420949914, 1.34815933862527, 1.34795321717244, 1.34753884770973, 
1.34716272775754, 1.34652948553649, 1.34595361774187, 1.34551906030582, 
1.34520668882533, 1.34474450636559, 1.34451394628195, 1.34420694853785, 
1.34432229899726, 1.34437310274734, 1.34446612848879, 1.34490551343631, 
1.34525152809348, 1.3468089304476, 1.34760154565107, 1.34882461399809, 
1.3487078893196), .Dim = c(23L, 2L))), class = c("XY", "POLYGON", 
"sfg")), structure(list(structure(c(103.945498919251, 103.94568220744, 
103.945560904067, 103.945194296516, 103.944862734056, 103.944390999926, 
103.943870744423, 103.942981188803, 103.942371977179, 103.941214207492, 
103.941099652993, 103.945043351222, 103.945498245463, 103.945498919251, 
1.34070263250518, 1.34053984781151, 1.34043404885439, 1.34007324506738, 
1.33978297598195, 1.33939097808683, 1.33895150588249, 1.33820006237125, 
1.33766021510611, 1.33666258373397, 1.33677924512028, 1.34016142246325, 
1.34070466723922, 1.34070263250518), .Dim = c(14L, 2L))), class = c("XY", 
"POLYGON", "sfg")), structure(list(structure(c(103.936106134053, 
103.93612366467, 103.936933663707, 103.937870354423, 103.938220771579, 
103.938692488901, 103.939037517795, 103.939584719319, 103.940072621879, 
103.940765396042, 103.941103695681, 103.941205447024, 103.9408833208, 
103.940302415305, 103.940012636609, 103.939848204656, 103.939778119248, 
103.939500474846, 103.939301002478, 103.93910692203, 103.938778065857, 
103.938546249332, 103.938307694537, 103.93809474803, 103.937827891848, 
103.937570470548, 103.936954546223, 103.936104112386, 103.936106134053, 
1.33513948936948, 1.33537415779139, 1.33527103192174, 1.33522487207148, 
1.33521943117599, 1.33525739201081, 1.33531706174246, 1.33558019298512, 
1.33589758544604, 1.33649168844986, 1.33676568025279, 1.33666190588677, 
1.33639469572946, 1.33590774890731, 1.33566631011072, 1.33554287861203, 
1.33549811819148, 1.33535841397024, 1.33526482627102, 1.33519158535581, 
1.33512241965159, 1.33507630969839, 1.33504240823333, 1.33502885268234, 
1.33503157704738, 1.33504786567154, 1.33508587300465, 1.33513881121995, 
1.33513948936948), .Dim = c(29L, 2L))), class = c("XY", "POLYGON", 
"sfg"))), class = c("sfc_POLYGON", "sfc"), precision = 0, bbox = structure(c(xmin = 103.936104112386, 
ymin = 1.33502885268234, xmax = 103.979593078217, ymax = 1.35080687807996
), class = "bbox"), crs = structure(list(input = "WGS 84", wkt = "GEOGCRS[\"WGS 84\",\n    DATUM[\"World Geodetic System 1984\",\n        ELLIPSOID[\"WGS 84\",6378137,298.257223563,\n            LENGTHUNIT[\"metre\",1]]],\n    PRIMEM[\"Greenwich\",0,\n        ANGLEUNIT[\"degree\",0.0174532925199433]],\n    CS[ellipsoidal,2],\n        AXIS[\"latitude\",north,\n            ORDER[1],\n            ANGLEUNIT[\"degree\",0.0174532925199433]],\n        AXIS[\"longitude\",east,\n            ORDER[2],\n            ANGLEUNIT[\"degree\",0.0174532925199433]],\n    ID[\"EPSG\",4326]]"), class = "crs"), n_empty = 0L)), sf_column = "geometry", agr = structure(c(ID = NA_integer_), .Label = c("constant", 
"aggregate", "identity"), class = "factor"), row.names = c(NA, 
6L), class = c("sf", "data.frame"))

However, using the same procedure as above (st_read to import the shapefile), I have encountered an issue where the geometry imported is not in longitude and latitude, but seems to be the XY coordinates, and hence I am unable to perform clipping.

Here are the first 6 observations of the taxi_boundary

dput(head(taxistand, n=6))

structure(list(TYPE_CD = c(NA_character_, NA_character_, NA_character_, 
NA_character_, NA_character_, NA_character_), TYPE_CD_DE = c("TAXI STOP", 
"TAXI STOP", "TAXI STOP", "TAXI STAND", "TAXI STAND", "TAXI STAND"
), taxicode = c("C09", "C15", "C05", "D04", "D01", "F34"), Popular = c(25, 
25, 25, 25, 25, 25), geometry = structure(list(structure(list(
    structure(c(29926.8253137292, 29926.8253137292, 29926.7301811815, 
    29926.4455075545, 29925.9734593865, 29925.3176292489, 29924.4830084052, 
    29923.4759488238, 29922.3041148365, 29920.9764248072, 29919.5029832589, 
    29917.8950039714, 29916.164724638, 29914.3253137292, 29912.3907702728, 
    29910.3758173124, 29908.2957898568, 29906.1665181709, 29904.0042072979, 
    29901.8253137292, 29899.6464201605, 29897.4841092876, 29895.3548376017, 
    29893.2748101461, 29891.2598571857, 29889.3253137292, 29887.4859028205, 
    29885.7556234871, 29884.1476441996, 29882.6742026513, 29881.346512622, 
    29880.1746786346, 29879.1676190533, 29878.3329982096, 29877.677168072, 
    29877.2051199039, 29876.9204462769, 29876.8253137292, 29876.9204462769, 
    29877.2051199039, 29877.677168072, 29878.3329982096, 29879.1676190533, 
    29880.1746786346, 29881.346512622, 29882.6742026513, 29884.1476441996, 
    29885.7556234871, 29887.4859028205, 29889.3253137292, 29891.2598571857, 
    29893.2748101461, 29895.3548376017, 29897.4841092876, 29899.6464201605, 
    29901.8253137292, 29904.0042072979, 29906.1665181709, 29908.2957898568, 
    29910.3758173124, 29912.3907702728, 29914.3253137292, 29916.164724638, 
    29917.8950039714, 29919.5029832589, 29920.9764248072, 29922.3041148365, 
    29923.4759488238, 29924.4830084052, 29925.3176292489, 29925.9734593865, 
    29926.4455075545, 29926.7301811815, 29926.8253137292, 30391.6178182997, 
    30391.6178182997, 30389.438924731, 30387.276613858, 30385.1473421721, 
    30383.0673147165, 30381.0523617562, 30379.1178182997, 30377.2784073909, 
    30375.5481280575, 30373.94014877, 30372.4667072217, 30371.1390171925, 
    30369.9671832051, 30368.9601236238, 30368.12550278, 30367.4696726425, 
    30366.9976244744, 30366.7129508474, 30366.6178182997, 30366.7129508474, 
    30366.9976244744, 30367.4696726425, 30368.12550278, 30368.9601236238, 
    30369.9671832051, 30371.1390171925, 30372.4667072217, 30373.94014877, 
    30375.5481280575, 30377.2784073909, 30379.1178182997, 30381.0523617562, 
    30383.0673147165, 30385.1473421721, 30387.276613858, 30389.438924731, 
    30391.6178182997, 30393.7967118684, 30395.9590227414, 30398.0882944272, 
    30400.1683218828, 30402.1832748432, 30404.1178182997, 30405.9572292085, 
    30407.6875085418, 30409.2954878293, 30410.7689293777, 30412.0966194069, 
    30413.2684533943, 30414.2755129756, 30415.1101338193, 30415.7659639569, 
    30416.238012125, 30416.522685752, 30416.6178182997, 30416.522685752, 
    30416.238012125, 30415.7659639569, 30415.1101338193, 30414.2755129756, 
    30413.2684533943, 30412.0966194069, 30410.7689293777, 30409.2954878293, 
    30407.6875085418, 30405.9572292085, 30404.1178182997, 30402.1832748432, 
    30400.1683218828, 30398.0882944272, 30395.9590227414, 30393.7967118684, 
    30391.6178182997), .Dim = c(74L, 2L))), class = c("XY", "POLYGON", 
"sfg")), structure(list(structure(c(30204.9785137298, 30204.9785137298, 
30204.8833811821, 30204.5987075551, 30204.126659387, 30203.4708292494, 
30202.6362084057, 30201.6291488244, 30200.457314837, 30199.1296248077, 
30197.6561832594, 30196.0482039719, 30194.3179246385, 30192.4785137298, 
30190.5439702733, 30188.5290173129, 30186.4489898573, 30184.3197181714, 
30182.1574072985, 30179.9785137298, 30177.7996201611, 30175.6373092881, 
30173.5080376022, 30171.4280101466, 30169.4130571862, 30167.4785137298, 
30165.639102821, 30163.9088234876, 30162.3008442001, 30160.8274026518, 
30159.4997126225, 30158.3278786351, 30157.3208190538, 30156.4861982101, 
30155.8303680725, 30155.3583199045, 30155.0736462775, 30154.9785137298, 
30155.0736462775, 30155.3583199045, 30155.8303680725, 30156.4861982101, 
30157.3208190538, 30158.3278786351, 30159.4997126225, 30160.8274026518, 
30162.3008442001, 30163.9088234876, 30165.639102821, 30167.4785137298, 
30169.4130571862, 30171.4280101466, 30173.5080376022, 30175.6373092881, 
30177.7996201611, 30179.9785137298, 30182.1574072985, 30184.3197181714, 
30186.4489898573, 30188.5290173129, 30190.5439702733, 30192.4785137298, 
30194.3179246385, 30196.0482039719, 30197.6561832594, 30199.1296248077, 
30200.457314837, 30201.6291488244, 30202.6362084057, 30203.4708292494, 
30204.126659387, 30204.5987075551, 30204.8833811821, 30204.9785137298, 
30762.0801183004, 30762.0801183004, 30759.9012247317, 30757.7389138587, 
30755.6096421728, 30753.5296147173, 30751.5146617569, 30749.5801183004, 
30747.7407073916, 30746.0104280582, 30744.4024487707, 30742.9290072224, 
30741.6013171932, 30740.4294832058, 30739.4224236245, 30738.5878027807, 
30737.9319726432, 30737.4599244751, 30737.1752508481, 30737.0801183004, 
30737.1752508481, 30737.4599244751, 30737.9319726432, 30738.5878027807, 
30739.4224236245, 30740.4294832058, 30741.6013171932, 30742.9290072224, 
30744.4024487707, 30746.0104280582, 30747.7407073916, 30749.5801183004, 
30751.5146617569, 30753.5296147173, 30755.6096421728, 30757.7389138587, 
30759.9012247317, 30762.0801183004, 30764.2590118691, 30766.4213227421, 
30768.550594428, 30770.6306218835, 30772.6455748439, 30774.5801183004, 
30776.4195292092, 30778.1498085426, 30779.7577878301, 30781.2312293784, 
30782.5589194076, 30783.730753395, 30784.7378129763, 30785.57243382, 
30786.2282639576, 30786.7003121257, 30786.9849857527, 30787.0801183004, 
30786.9849857527, 30786.7003121257, 30786.2282639576, 30785.57243382, 
30784.7378129763, 30783.730753395, 30782.5589194076, 30781.2312293784, 
30779.7577878301, 30778.1498085426, 30776.4195292092, 30774.5801183004, 
30772.6455748439, 30770.6306218835, 30768.550594428, 30766.4213227421, 
30764.2590118691, 30762.0801183004), .Dim = c(74L, 2L))), class = c("XY", 
"POLYGON", "sfg")), structure(list(structure(c(29679.5554137295, 
29679.5554137295, 29679.4602811818, 29679.1756075548, 29678.7035593867, 
29678.0477292492, 29677.2131084054, 29676.2060488241, 29675.0342148367, 
29673.7065248075, 29672.2330832592, 29670.6251039717, 29668.8948246383, 
29667.0554137295, 29665.120870273, 29663.1059173127, 29661.0258898571, 
29658.8966181712, 29656.7343072982, 29654.5554137295, 29652.3765201608, 
29650.2142092878, 29648.0849376019, 29646.0049101464, 29643.989957186, 
29642.0554137295, 29640.2160028207, 29638.4857234873, 29636.8777441998, 
29635.4043026515, 29634.0766126223, 29632.9047786349, 29631.8977190536, 
29631.0630982099, 29630.4072680723, 29629.9352199042, 29629.6505462772, 
29629.5554137295, 29629.6505462772, 29629.9352199042, 29630.4072680723, 
29631.0630982099, 29631.8977190536, 29632.9047786349, 29634.0766126223, 
29635.4043026515, 29636.8777441998, 29638.4857234873, 29640.2160028207, 
29642.0554137295, 29643.989957186, 29646.0049101464, 29648.0849376019, 
29650.2142092878, 29652.3765201608, 29654.5554137295, 29656.7343072982, 
29658.8966181712, 29661.0258898571, 29663.1059173127, 29665.120870273, 
29667.0554137295, 29668.8948246383, 29670.6251039717, 29672.2330832592, 
29673.7065248075, 29675.0342148367, 29676.2060488241, 29677.2131084054, 
29678.0477292492, 29678.7035593867, 29679.1756075548, 29679.4602811818, 
29679.5554137295, 30748.8858183008, 30748.8858183008, 30746.7069247321, 
30744.5446138591, 30742.4153421732, 30740.3353147176, 30738.3203617573, 
30736.3858183008, 30734.546407392, 30732.8161280586, 30731.2081487711, 
30729.7347072228, 30728.4070171935, 30727.2351832062, 30726.2281236249, 
30725.3935027811, 30724.7376726435, 30724.2656244755, 30723.9809508485, 
30723.8858183008, 30723.9809508485, 30724.2656244755, 30724.7376726435, 
30725.3935027811, 30726.2281236249, 30727.2351832062, 30728.4070171935, 
30729.7347072228, 30731.2081487711, 30732.8161280586, 30734.546407392, 
30736.3858183008, 30738.3203617573, 30740.3353147176, 30742.4153421732, 
30744.5446138591, 30746.7069247321, 30748.8858183008, 30751.0647118695, 
30753.2270227424, 30755.3562944283, 30757.4363218839, 30759.4512748443, 
30761.3858183008, 30763.2252292095, 30764.9555085429, 30766.5634878304, 
30768.0369293787, 30769.364619408, 30770.5364533954, 30771.5435129767, 
30772.3781338204, 30773.033963958, 30773.5060121261, 30773.7906857531, 
30773.8858183008, 30773.7906857531, 30773.5060121261, 30773.033963958, 
30772.3781338204, 30771.5435129767, 30770.5364533954, 30769.364619408, 
30768.0369293787, 30766.5634878304, 30764.9555085429, 30763.2252292095, 
30761.3858183008, 30759.4512748443, 30757.4363218839, 30755.3562944283, 
30753.2270227424, 30751.0647118695, 30748.8858183008), .Dim = c(74L, 
2L))), class = c("XY", "POLYGON", "sfg")), structure(list(structure(c(28957.4112137295, 
28957.4112137295, 28957.3160811818, 28957.0314075548, 28956.5593593868, 
28955.9035292492, 28955.0689084054, 28954.0618488241, 28952.8900148368, 
28951.5623248075, 28950.0888832592, 28948.4809039717, 28946.7506246383, 
28944.9112137295, 28942.976670273, 28940.9617173127, 28938.8816898571, 
28936.7524181712, 28934.5901072982, 28932.4112137295, 28930.2323201608, 
28928.0700092879, 28925.940737602, 28923.8607101464, 28921.845757186, 
28919.9112137295, 28918.0718028208, 28916.3415234874, 28914.7335441999, 
28913.2601026516, 28911.9324126223, 28910.7605786349, 28909.7535190536, 
28908.9188982099, 28908.2630680723, 28907.7910199042, 28907.5063462772, 
28907.4112137295, 28907.5063462772, 28907.7910199042, 28908.2630680723, 
28908.9188982099, 28909.7535190536, 28910.7605786349, 28911.9324126223, 
28913.2601026516, 28914.7335441999, 28916.3415234874, 28918.0718028208, 
28919.9112137295, 28921.845757186, 28923.8607101464, 28925.940737602, 
28928.0700092879, 28930.2323201608, 28932.4112137295, 28934.5901072982, 
28936.7524181712, 28938.8816898571, 28940.9617173127, 28942.976670273, 
28944.9112137295, 28946.7506246383, 28948.4809039717, 28950.0888832592, 
28951.5623248075, 28952.8900148368, 28954.0618488241, 28955.0689084054, 
28955.9035292492, 28956.5593593868, 28957.0314075548, 28957.3160811818, 
28957.4112137295, 29355.4129183013, 29355.4129183013, 29353.2340247326, 
29351.0717138596, 29348.9424421737, 29346.8624147182, 29344.8474617578, 
29342.9129183013, 29341.0735073925, 29339.3432280591, 29337.7352487716, 
29336.2618072233, 29334.9341171941, 29333.7622832067, 29332.7552236254, 
29331.9206027817, 29331.2647726441, 29330.792724476, 29330.508050849, 
29330.4129183013, 29330.508050849, 29330.792724476, 29331.2647726441, 
29331.9206027817, 29332.7552236254, 29333.7622832067, 29334.9341171941, 
29336.2618072233, 29337.7352487716, 29339.3432280591, 29341.0735073925, 
29342.9129183013, 29344.8474617578, 29346.8624147182, 29348.9424421737, 
29351.0717138596, 29353.2340247326, 29355.4129183013, 29357.59181187, 
29359.754122743, 29361.8833944289, 29363.9634218844, 29365.9783748448, 
29367.9129183013, 29369.7523292101, 29371.4826085435, 29373.090587831, 
29374.5640293793, 29375.8917194085, 29377.0635533959, 29378.0706129772, 
29378.9052338209, 29379.5610639585, 29380.0331121266, 29380.3177857536, 
29380.4129183013, 29380.3177857536, 29380.0331121266, 29379.5610639585, 
29378.9052338209, 29378.0706129772, 29377.0635533959, 29375.8917194085, 
29374.5640293793, 29373.090587831, 29371.4826085435, 29369.7523292101, 
29367.9129183013, 29365.9783748448, 29363.9634218844, 29361.8833944289, 
29359.754122743, 29357.59181187, 29355.4129183013), .Dim = c(74L, 
2L))), class = c("XY", "POLYGON", "sfg")), structure(list(structure(c(28839.7501137294, 
28839.7501137294, 28839.6549811817, 28839.3703075547, 28838.8982593866, 
28838.242429249, 28837.4078084053, 28836.400748824, 28835.2289148366, 
28833.9012248074, 28832.4277832591, 28830.8198039715, 28829.0895246382, 
28827.2501137294, 28825.3155702729, 28823.3006173125, 28821.220589857, 
28819.0913181711, 28816.9290072981, 28814.7501137294, 28812.5712201607, 
28810.4089092877, 28808.2796376018, 28806.1996101462, 28804.1846571859, 
28802.2501137294, 28800.4107028206, 28798.6804234872, 28797.0724441997, 
28795.5990026514, 28794.2713126222, 28793.0994786348, 28792.0924190535, 
28791.2577982097, 28790.6019680722, 28790.1299199041, 28789.8452462771, 
28789.7501137294, 28789.8452462771, 28790.1299199041, 28790.6019680722, 
28791.2577982097, 28792.0924190535, 28793.0994786348, 28794.2713126222, 
28795.5990026514, 28797.0724441997, 28798.6804234872, 28800.4107028206, 
28802.2501137294, 28804.1846571859, 28806.1996101462, 28808.2796376018, 
28810.4089092877, 28812.5712201607, 28814.7501137294, 28816.9290072981, 
28819.0913181711, 28821.220589857, 28823.3006173125, 28825.3155702729, 
28827.2501137294, 28829.0895246382, 28830.8198039715, 28832.4277832591, 
28833.9012248074, 28835.2289148366, 28836.400748824, 28837.4078084053, 
28838.242429249, 28838.8982593866, 28839.3703075547, 28839.6549811817, 
28839.7501137294, 29203.5306183007, 29203.5306183007, 29201.351724732, 
29199.189413859, 29197.0601421731, 29194.9801147175, 29192.9651617571, 
29191.0306183007, 29189.1912073919, 29187.4609280585, 29185.852948771, 
29184.3795072227, 29183.0518171934, 29181.8799832061, 29180.8729236247, 
29180.038302781, 29179.3824726434, 29178.9104244754, 29178.6257508484, 
29178.5306183007, 29178.6257508484, 29178.9104244754, 29179.3824726434, 
29180.038302781, 29180.8729236247, 29181.8799832061, 29183.0518171934, 
29184.3795072227, 29185.852948771, 29187.4609280585, 29189.1912073919, 
29191.0306183007, 29192.9651617571, 29194.9801147175, 29197.0601421731, 
29199.189413859, 29201.351724732, 29203.5306183007, 29205.7095118694, 
29207.8718227423, 29210.0010944282, 29212.0811218838, 29214.0960748442, 
29216.0306183007, 29217.8700292094, 29219.6003085428, 29221.2082878303, 
29222.6817293786, 29224.0094194079, 29225.1812533953, 29226.1883129766, 
29227.0229338203, 29227.6787639579, 29228.150812126, 29228.435485753, 
29228.5306183007, 29228.435485753, 29228.150812126, 29227.6787639579, 
29227.0229338203, 29226.1883129766, 29225.1812533953, 29224.0094194079, 
29222.6817293786, 29221.2082878303, 29219.6003085428, 29217.8700292094, 
29216.0306183007, 29214.0960748442, 29212.0811218838, 29210.0010944282, 
29207.8718227423, 29205.7095118694, 29203.5306183007), .Dim = c(74L, 
2L))), class = c("XY", "POLYGON", "sfg")), structure(list(structure(c(28671.8010137295, 
28671.8010137295, 28671.7058811818, 28671.4212075548, 28670.9491593868, 
28670.2933292492, 28669.4587084055, 28668.4516488241, 28667.2798148368, 
28665.9521248075, 28664.4786832592, 28662.8707039717, 28661.1404246383, 
28659.3010137295, 28657.3664702731, 28655.3515173127, 28653.2714898571, 
28651.1422181712, 28648.9799072982, 28646.8010137295, 28644.6221201608, 
28642.4598092879, 28640.330537602, 28638.2505101464, 28636.235557186, 
28634.3010137295, 28632.4616028208, 28630.7313234874, 28629.1233441999, 
28627.6499026516, 28626.3222126223, 28625.1503786349, 28624.1433190536, 
28623.3086982099, 28622.6528680723, 28622.1808199042, 28621.8961462772, 
28621.8010137295, 28621.8961462772, 28622.1808199042, 28622.6528680723, 
28623.3086982099, 28624.1433190536, 28625.1503786349, 28626.3222126223, 
28627.6499026516, 28629.1233441999, 28630.7313234874, 28632.4616028208, 
28634.3010137295, 28636.235557186, 28638.2505101464, 28640.330537602, 
28642.4598092879, 28644.6221201608, 28646.8010137295, 28648.9799072982, 
28651.1422181712, 28653.2714898571, 28655.3515173127, 28657.3664702731, 
28659.3010137295, 28661.1404246383, 28662.8707039717, 28664.4786832592, 
28665.9521248075, 28667.2798148368, 28668.4516488241, 28669.4587084055, 
28670.2933292492, 28670.9491593868, 28671.4212075548, 28671.7058811818, 
28671.8010137295, 29300.1820183005, 29300.1820183005, 29298.0031247318, 
29295.8408138588, 29293.711542173, 29291.6315147174, 29289.616561757, 
29287.6820183005, 29285.8426073917, 29284.1123280584, 29282.5043487709, 
29281.0309072225, 29279.7032171933, 29278.5313832059, 29277.5243236246, 
29276.6897027809, 29276.0338726433, 29275.5618244752, 29275.2771508482, 
29275.1820183005, 29275.2771508482, 29275.5618244752, 29276.0338726433, 
29276.6897027809, 29277.5243236246, 29278.5313832059, 29279.7032171933, 
29281.0309072225, 29282.5043487709, 29284.1123280584, 29285.8426073917, 
29287.6820183005, 29289.616561757, 29291.6315147174, 29293.711542173, 
29295.8408138588, 29298.0031247318, 29300.1820183005, 29302.3609118692, 
29304.5232227422, 29306.6524944281, 29308.7325218837, 29310.747474844, 
29312.6820183005, 29314.5214292093, 29316.2517085427, 29317.8596878302, 
29319.3331293785, 29320.6608194077, 29321.8326533951, 29322.8397129764, 
29323.6743338202, 29324.3301639577, 29324.8022121258, 29325.0868857528, 
29325.1820183005, 29325.0868857528, 29324.8022121258, 29324.3301639577, 
29323.6743338202, 29322.8397129764, 29321.8326533951, 29320.6608194077, 
29319.3331293785, 29317.8596878302, 29316.2517085427, 29314.5214292093, 
29312.6820183005, 29310.747474844, 29308.7325218837, 29306.6524944281, 
29304.5232227422, 29302.3609118692, 29300.1820183005), .Dim = c(74L, 
2L))), class = c("XY", "POLYGON", "sfg"))), class = c("sfc_POLYGON", 
"sfc"), precision = 0, bbox = structure(c(xmin = 28621.8010137295, 
ymin = 29178.5306183007, xmax = 30204.9785137298, ymax = 30787.0801183004
), class = "bbox"), crs = structure(list(input = "WGS 84", wkt = "GEOGCRS[\"WGS 84\",\n    DATUM[\"World Geodetic System 1984\",\n        ELLIPSOID[\"WGS 84\",6378137,298.257223563,\n            LENGTHUNIT[\"metre\",1]]],\n    PRIMEM[\"Greenwich\",0,\n        ANGLEUNIT[\"degree\",0.0174532925199433]],\n    CS[ellipsoidal,2],\n        AXIS[\"latitude\",north,\n            ORDER[1],\n            ANGLEUNIT[\"degree\",0.0174532925199433]],\n        AXIS[\"longitude\",east,\n            ORDER[2],\n            ANGLEUNIT[\"degree\",0.0174532925199433]],\n    ID[\"EPSG\",4326]]"), class = "crs"), n_empty = 0L)), sf_column = "geometry", agr = structure(c(TYPE_CD = NA_integer_, 
TYPE_CD_DE = NA_integer_, taxicode = NA_integer_, Popular = NA_integer_
), .Label = c("constant", "aggregate", "identity"), class = "factor"), row.names = c(NA, 
6L), class = c("sf", "data.frame"))

The structures for pie_boundary and taxi_boundary are:

structure(pie_boundary)

Simple feature collection with 35 features and 1 field
Geometry type: POLYGON
Dimension:     XY
Bounding box:  xmin: 103.6656941 ymin: 1.320334642 xmax: 103.9795931 ymax: 1.361757163
Geodetic CRS:  WGS 84
First 10 features:
         ID                       geometry
1   PIE_E_1 POLYGON ((103.973397 1.3397...
2   PIE_E_2 POLYGON ((103.9678606 1.345...
3   PIE_E_3 POLYGON ((103.957766 1.3503...
4   PIE_E_4 POLYGON ((103.955348 1.3487...
5   PIE_E_5 POLYGON ((103.9454989 1.340...

structure(taxi_boundary)

Simple feature collection with 342 features and 4 fields
Geometry type: POLYGON
Dimension:     XY
Bounding box:  xmin: 6126.732114 ymin: 27436.92192 xmax: 45568.51391 ymax: 48973.44612
Geodetic CRS:  WGS 84
First 10 features:
   TYPE_CD TYPE_CD_DE taxicode Popular                       geometry
1     <NA>  TAXI STOP      C09      25 POLYGON ((29926.82531 30391...
2     <NA>  TAXI STOP      C15      25 POLYGON ((30204.97851 30762...
3     <NA>  TAXI STOP      C05      25 POLYGON ((29679.55541 30748...
4     <NA> TAXI STAND      D04      25 POLYGON ((28957.41121 29355...
5     <NA> TAXI STAND      D01      25 POLYGON ((28839.75011 29203...

I suspect that the cause could be the settings of CRS in QGIS, and I recreated the shapefile while setting the project CRS and layer CRS to be EPSG:4326 - WBS84 (similar settings as my previous attempts that produce the longitude and latitude), but the result is still the same.

I have also tried change the CRS of taxi_boundary to the same of PIE_boundary, but it does not change the geometry.

st_transform(taxi_boundary, st_crs(pie_boundary))
Simple feature collection with 342 features and 4 fields
Geometry type: POLYGON
Dimension:     XY
Bounding box:  xmin: 6126.732114 ymin: 27436.92192 xmax: 45568.51391 ymax: 48973.44612
Geodetic CRS:  WGS 84
First 10 features:
   TYPE_CD TYPE_CD_DE taxicode Popular                       geometry
1     <NA>  TAXI STOP      C09      25 POLYGON ((29926.82531 30391...
2     <NA>  TAXI STOP      C15      25 POLYGON ((30204.97851 30762...
3     <NA>  TAXI STOP      C05      25 POLYGON ((29679.55541 30748...
4     <NA> TAXI STAND      D04      25 POLYGON ((28957.41121 29355...

I also tried st_sfc to convert the sfg polygons into a sfc geometry column, but the result does not change the geometry type to longitude and latitude.

Appreciate any help and advice to correct this issue. Thank you.

r

polygon

latitude-longitude

qgis

0 Answers

Your Answer

Accepted video resources