[R-sig-Geo] question on writing shapefiles from OSM data

Gabriel Cotlier g@b|k|m01 @end|ng |rom gm@||@com
Sat Feb 1 19:25:24 CET 2020


Dear users,
I would like to download OSM data and convert it to shapefile and change
coordinates to same as Landsat data.
I'm following the code bellow.
Is this the correct way for saving/writing to swapfile the OSM data?
Thanks a lot for your response.
Best,

library(osmar)
library(osmdata)
library(OpenStreetMap)
library(tmap)

# Paris administrative borders ID
id<-c(7444)
dat2 <- opq_osm_id (type = "relation", id = id) %>%
  opq_string () %>%
  osmdata_sf ()
qtm(dat2$osm_multipolygons)

library(sf)
st_write(dat2$osm_multipolygons, "s.shp")
# change coordinate system to Landsat data
landst_crs= "+proj=utm +zone=36 +datum=WGS84 +units=m +no_defs +ellps=WGS84
+towgs84=0,0,0"
s=readOGR('/Users/gcotlier/Desktop/s.shp')
S <- spTransform(s, CRS(landst_crs))
writeOGR( obj = S, dsn = '/Users/gcotlier/Desktop',layer = "S1", driver =
"ESRI Shapefile")
S1=readOGR('/Users/gcotlier/Desktop/S1.shp')
plot(S1)

	[[alternative HTML version deleted]]



More information about the R-sig-Geo mailing list